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 a574a45 commit 9f8941c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
6 changes: 3 additions & 3 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def group_by(storage):

runner = (
MarsRoverRunner(repository=repository,
path_projection_storage=paths_table,
obstacles_projection_storage=obstacles_table,
mars_rover_projection_storage=mars_rover_ids_table)
mars_rover_path_view=paths_table,
obstacle_view=obstacles_table,
mars_rover_start_view=mars_rover_ids_table)
.with_initial_point(x=0, y=0)
.with_initial_direction(direction=Direction.NORTH)
.with_world(world_dimension=world_dimension, obstacles=world_obstacles)
Expand Down
12 changes: 6 additions & 6 deletions app/service/mars_rover_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
class MarsRoverRunner:
def __init__(self,
repository: MarsRoverRepository,
path_projection_storage: List[Dict],
obstacles_projection_storage: List[Dict],
mars_rover_projection_storage: List[MarsRoverId]):
mars_rover_path_view: List[Dict],
obstacle_view: List[Dict],
mars_rover_start_view: List[MarsRoverId]):
self.command_dispatcher: InMemoryCommandDispatcher = (
create_command_dispatcher(mars_rover_repo=repository,
path_projection_storage=path_projection_storage,
obstacles_projection_storage=obstacles_projection_storage,
mars_rover_storage=mars_rover_projection_storage)
mars_rover_path_view=mars_rover_path_view,
obstacle_view=obstacle_view,
mars_rover_start_view=mars_rover_start_view)
)
self.command_map = {"R": TurnRight, "L": TurnLeft, "M": Move}

Expand Down
14 changes: 7 additions & 7 deletions app/workflow_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@


def create_command_dispatcher(mars_rover_repo: MarsRoverRepository,
mars_rover_storage: List[MarsRoverId],
path_projection_storage: List[Dict],
obstacles_projection_storage: List[Dict]) -> InMemoryCommandDispatcher:
mars_rover_start_view: List[MarsRoverId],
mars_rover_path_view: List[Dict],
obstacle_view: List[Dict]) -> InMemoryCommandDispatcher:
turn_right_command_handler = TurnRightCommandHandler(repo=mars_rover_repo)
turn_left_command_handler = TurnLeftCommandHandler(repo=mars_rover_repo)
move_command_handler = MoveCommandHandler(repo=mars_rover_repo)
start_command_handler = StartMarsRoverCommandHandler(repo=mars_rover_repo)
turn_off_command_handler = TurnOffCommandHandler(repo=mars_rover_repo)
notify_obstacle_command_handler = NotifyObstacleCommandHandler()

rover_path_projection = MarsRoverPathProjection(repo=mars_rover_repo, storage=path_projection_storage)
rover_start_projection = MarsRoverStartProjection(repo=mars_rover_repo,
paths_storage=path_projection_storage,
mars_rover_storage=mars_rover_storage)
rover_obstacles_projection = MarsRoverObstaclesProjection(storage=obstacles_projection_storage)
paths_storage=mars_rover_path_view,
mars_rover_storage=mars_rover_start_view)
rover_path_projection = MarsRoverPathProjection(repo=mars_rover_repo, storage=mars_rover_path_view)
rover_obstacles_projection = MarsRoverObstaclesProjection(storage=obstacle_view)

obstacle_found_policy = NotifyObstacleFoundPolicy()
turn_off_policy = TurnOffPolicy()
Expand Down
36 changes: 18 additions & 18 deletions test/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@
class TestE2E(unittest.TestCase):
def test_execute_some_commands(self):
repo = MarsRoverRepository()
paths = []
obstacles = []
mars_rover_ids = []
mars_rover_start_view = []
mars_rover_path_view = []
obstacle_view = []

runner = (
MarsRoverRunner(repository=repo,
path_projection_storage=paths,
obstacles_projection_storage=obstacles,
mars_rover_projection_storage=mars_rover_ids)
mars_rover_start_view=mars_rover_start_view,
mars_rover_path_view=mars_rover_path_view,
obstacle_view=obstacle_view)
.with_initial_point(x=0, y=0)
.with_initial_direction(direction=Direction.NORTH)
.with_world(world_dimension=(4, 4),
obstacles=[])
)
runner.start()

id = mars_rover_ids[0]
id = mars_rover_start_view[0]

runner.run(id, "RMLMM")

Expand All @@ -35,21 +35,21 @@ def test_execute_some_commands(self):
self.assertEqual("MOVING", actual.status.value)

expected_path = ["0:0:N", "0:0:E", "1:0:E", "1:0:N", "1:1:N", "1:2:N"]
self._assert_paths(expected=expected_path, actual=paths)
self._assert_paths(expected=expected_path, actual=mars_rover_path_view)

self.assertListEqual([], obstacles)
self.assertListEqual([], obstacle_view)

def test_hit_obstacle(self):
repo = MarsRoverRepository()
paths = []
obstacles = []
mars_rover_ids = []
mars_rover_start_view = []
mars_rover_path_view = []
obstacle_view = []

runner = (
MarsRoverRunner(repository=repo,
path_projection_storage=paths,
obstacles_projection_storage=obstacles,
mars_rover_projection_storage=mars_rover_ids)
mars_rover_start_view=mars_rover_start_view,
mars_rover_path_view=mars_rover_path_view,
obstacle_view=obstacle_view)
.with_initial_point(x=0, y=0)
.with_initial_direction(direction=Direction.NORTH)
.with_world(world_dimension=(4, 4),
Expand All @@ -58,7 +58,7 @@ def test_hit_obstacle(self):

runner.start()

id = mars_rover_ids[0]
id = mars_rover_start_view[0]

runner.run(id, "RMMLMMMMMM")

Expand All @@ -67,9 +67,9 @@ def test_hit_obstacle(self):
self.assertEqual("TURNED_OFF", actual.status.value)

expected_path = ["0:0:N", "0:0:E", "1:0:E", "2:0:E", "2:0:N", "2:1:N"]
self._assert_paths(expected=expected_path, actual=paths)
self._assert_paths(expected=expected_path, actual=mars_rover_path_view)

obstacles_found = [o["obstacle"] for o in obstacles]
obstacles_found = [o["obstacle"] for o in obstacle_view]
self.assertEqual([(2, 2)], obstacles_found)

def _assert_paths(self, expected, actual):
Expand Down

0 comments on commit 9f8941c

Please sign in to comment.