Skip to content

Commit

Permalink
renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Sabatini committed Jul 23, 2024
1 parent f55b5ea commit 1b68cf9
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions app/command_handler/move_command_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
from app.command_handler.commands import Move
from app.domain.events import MarsRoverMoved
from app.domain.mars_rover import MarsRover
from app.infrastructure.mars_rover_repository import MarsRoverRepository
from app.infrastructure.mars_rover_repository import InMemoryMarsRoverRepository


class MoveCommandHandler(CommandHandler):
def __init__(self, repo: MarsRoverRepository):
def __init__(self, repo: InMemoryMarsRoverRepository):
self.repo = repo

def handle(self, command: Move) -> MarsRoverMoved:
Expand Down
4 changes: 2 additions & 2 deletions app/command_handler/start_mars_rover_command_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from app.domain.events import MarsRoverStarted
from app.domain.mars_rover import MarsRover
from app.domain.mars_rover_id import MarsRoverId
from app.infrastructure.mars_rover_repository import MarsRoverRepository
from app.infrastructure.mars_rover_repository import InMemoryMarsRoverRepository


class StartMarsRoverCommandHandler(CommandHandler):
def __init__(self, repo: MarsRoverRepository):
def __init__(self, repo: InMemoryMarsRoverRepository):
self.repo = repo

def handle(self, command: StartMarsRover) -> MarsRoverStarted:
Expand Down
4 changes: 2 additions & 2 deletions app/command_handler/turn_left_command_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
from app.command_handler.commands import TurnLeft
from app.domain.events import MarsRoverMoved
from app.domain.mars_rover import MarsRover
from app.infrastructure.mars_rover_repository import MarsRoverRepository
from app.infrastructure.mars_rover_repository import InMemoryMarsRoverRepository


class TurnLeftCommandHandler(CommandHandler):
def __init__(self, repo: MarsRoverRepository):
def __init__(self, repo: InMemoryMarsRoverRepository):
self.repo = repo

def handle(self, command: TurnLeft) -> MarsRoverMoved:
Expand Down
4 changes: 2 additions & 2 deletions app/command_handler/turn_off_command_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
from app.ddd.basics import CommandHandler
from app.domain.events import MarsRoverTurnedOff
from app.domain.mars_rover import MarsRover
from app.infrastructure.mars_rover_repository import MarsRoverRepository
from app.infrastructure.mars_rover_repository import InMemoryMarsRoverRepository


class TurnOffCommandHandler(CommandHandler):
def __init__(self, repo: MarsRoverRepository):
def __init__(self, repo: InMemoryMarsRoverRepository):
self.repo = repo

def handle(self, command: TurnOff) -> MarsRoverTurnedOff:
Expand Down
4 changes: 2 additions & 2 deletions app/command_handler/turn_right_command_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
from app.command_handler.commands import TurnRight
from app.domain.events import MarsRoverMoved, ObstacleFound
from app.domain.mars_rover import MarsRover
from app.infrastructure.mars_rover_repository import MarsRoverRepository
from app.infrastructure.mars_rover_repository import InMemoryMarsRoverRepository


class TurnRightCommandHandler(CommandHandler):
def __init__(self, repo: MarsRoverRepository):
def __init__(self, repo: InMemoryMarsRoverRepository):
self.repo = repo

def handle(self, command: TurnRight) -> ObstacleFound | MarsRoverMoved:
Expand Down
2 changes: 1 addition & 1 deletion app/infrastructure/mars_rover_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
from app.domain.mars_rover import MarsRover


class MarsRoverRepository(InMemoryGenericAggregateRepository[MarsRover]):
class InMemoryMarsRoverRepository(InMemoryGenericAggregateRepository[MarsRover]):
pass
4 changes: 2 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from app.domain.direction import Direction
from app.domain.mars_rover_id import MarsRoverId
from app.infrastructure.mars_rover_repository import MarsRoverRepository
from app.infrastructure.mars_rover_repository import InMemoryMarsRoverRepository
from app.service.mars_rover_runner import MarsRoverRunner


Expand All @@ -28,7 +28,7 @@ def group_by(storage):
world_dimension = (10, 10)
world_obstacles = [(1, 2), (1, 1), (4, 6), (5, 9), (5, 5)]

repository = MarsRoverRepository()
repository = InMemoryMarsRoverRepository()
paths_table = []
obstacles_table = []
mars_rover_ids_table = []
Expand Down
4 changes: 2 additions & 2 deletions app/projection/mars_rover_path_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from app.ddd.basics import Projection
from app.domain.events import MarsRoverMoved
from app.domain.mars_rover import MarsRover
from app.infrastructure.mars_rover_repository import MarsRoverRepository
from app.infrastructure.mars_rover_repository import InMemoryMarsRoverRepository


class MarsRoverPathProjection(Projection):
def __init__(self, repo: MarsRoverRepository, storage: List[Dict]):
def __init__(self, repo: InMemoryMarsRoverRepository, storage: List[Dict]):
self.repo = repo
self.storage = storage

Expand Down
4 changes: 2 additions & 2 deletions app/projection/mars_rover_start_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
from app.domain.events import MarsRoverStarted
from app.domain.mars_rover import MarsRover
from app.domain.mars_rover_id import MarsRoverId
from app.infrastructure.mars_rover_repository import MarsRoverRepository
from app.infrastructure.mars_rover_repository import InMemoryMarsRoverRepository


class MarsRoverStartProjection(Projection):
def __init__(self,
repo: MarsRoverRepository,
repo: InMemoryMarsRoverRepository,
paths_storage: List[Dict],
mars_rover_storage: List[MarsRoverId]):
self.repo = repo
Expand Down
4 changes: 2 additions & 2 deletions app/service/mars_rover_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
from app.domain.obstacles import Obstacles
from app.domain.point import Point
from app.domain.world import World
from app.infrastructure.mars_rover_repository import MarsRoverRepository
from app.infrastructure.mars_rover_repository import InMemoryMarsRoverRepository
from app.workflow_factory import create_command_dispatcher


class MarsRoverRunner:
def __init__(self,
repository: MarsRoverRepository,
repository: InMemoryMarsRoverRepository,
mars_rover_path_view: List[Dict],
obstacle_view: List[Dict],
mars_rover_start_view: List[MarsRoverId]):
Expand Down
4 changes: 2 additions & 2 deletions app/workflow_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
from app.ddd.command_dispatcher import InMemoryCommandDispatcher, InMemoryCommandDispatcherBuilder
from app.domain.events import MarsRoverMoved, ObstacleFound, MarsRoverStarted
from app.domain.mars_rover_id import MarsRoverId
from app.infrastructure.mars_rover_repository import MarsRoverRepository
from app.infrastructure.mars_rover_repository import InMemoryMarsRoverRepository
from app.policy.policies import NotifyObstacleFoundPolicy, TurnOffPolicy
from app.projection.mars_rover_ostacles_projection import MarsRoverObstaclesProjection
from app.projection.mars_rover_path_projection import MarsRoverPathProjection
from app.projection.mars_rover_start_projection import MarsRoverStartProjection


def create_command_dispatcher(mars_rover_repo: MarsRoverRepository,
def create_command_dispatcher(mars_rover_repo: InMemoryMarsRoverRepository,
mars_rover_start_view: List[MarsRoverId],
mars_rover_path_view: List[Dict],
obstacle_view: List[Dict]) -> InMemoryCommandDispatcher:
Expand Down
6 changes: 3 additions & 3 deletions test/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
from app.domain.direction import Direction
from app.domain.mars_rover import MarsRover
from app.domain.mars_rover_id import MarsRoverId
from app.infrastructure.mars_rover_repository import MarsRoverRepository
from app.infrastructure.mars_rover_repository import InMemoryMarsRoverRepository
from app.service.mars_rover_runner import MarsRoverRunner


class TestE2E(unittest.TestCase):
def test_execute_some_commands(self):
repo = MarsRoverRepository()
repo = InMemoryMarsRoverRepository()
mars_rover_start_view = []
mars_rover_path_view = []
obstacle_view = []
Expand Down Expand Up @@ -40,7 +40,7 @@ def test_execute_some_commands(self):
self.assertListEqual([], obstacle_view)

def test_hit_obstacle(self):
repo = MarsRoverRepository()
repo = InMemoryMarsRoverRepository()
mars_rover_start_view = []
mars_rover_path_view = []
obstacle_view = []
Expand Down
6 changes: 3 additions & 3 deletions test/unit/test_command_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
from app.domain.point import Point
from app.domain.world import World
from app.factory import create_mars_rover
from app.infrastructure.mars_rover_repository import MarsRoverRepository
from app.infrastructure.mars_rover_repository import InMemoryMarsRoverRepository


class TestMarsCommandHandler(unittest.TestCase):
def test_start_command_handler(self):
repo = MarsRoverRepository()
repo = InMemoryMarsRoverRepository()
start_rover: StartMarsRover = _start_rover_command()

event = StartMarsRoverCommandHandler(repo=repo).handle(command=start_rover)
Expand Down Expand Up @@ -61,7 +61,7 @@ def test_move_command_handler(self):
self._assert_aggregate(event, repo)

def _setup(self):
repo = MarsRoverRepository()
repo = InMemoryMarsRoverRepository()
mars_rover: MarsRover = create_mars_rover()
repo.save(mars_rover)
return repo, mars_rover.id
Expand Down
6 changes: 3 additions & 3 deletions test/unit/test_mars_rover_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@

from app.ddd.generic_aggregate_repository import ConcurrencyException
from app.factory import create_mars_rover
from app.infrastructure.mars_rover_repository import MarsRoverRepository
from app.infrastructure.mars_rover_repository import InMemoryMarsRoverRepository


class TestMarsRoverRepository(unittest.TestCase):
def test_save_mars_rover_aggregate(self):
mars_rover = create_mars_rover()
repository = MarsRoverRepository()
repository = InMemoryMarsRoverRepository()
repository.save(mars_rover)

actual = repository.get_by_id(mars_rover.id)

self.assertIsNotNone(actual)

def test_save_same_version(self):
repository = MarsRoverRepository()
repository = InMemoryMarsRoverRepository()

mars_rover = create_mars_rover()
repository.save(mars_rover)
Expand Down

0 comments on commit 1b68cf9

Please sign in to comment.