diff --git a/rover/rover.py b/rover/rover.py index d7bf29d..eaae800 100644 --- a/rover/rover.py +++ b/rover/rover.py @@ -56,3 +56,7 @@ class Rover(BaseModel): def turn_right(self): self._turn(1) + + +class Commander(BaseModel): + rover: Rover = Rover() diff --git a/rover/test_rover.py b/rover/test_rover.py index 49d605d..a43634b 100644 --- a/rover/test_rover.py +++ b/rover/test_rover.py @@ -1,4 +1,4 @@ -from rover import Direction, Rover, Vector +from rover import Commander, Direction, Rover, Vector def test_rover_constructor(): @@ -168,3 +168,22 @@ def test_rover_can_turn_right(): rov = Rover(dir=Direction.NORTH) rov.turn_right() assert rov.dir == Direction.EAST + + +def test_commander_constructor(): + com = Commander( + rover=Rover( + pos=Vector(x=12, y=27), planet_size=Vector(x=100, y=100), dir=Direction.WEST + ) + ) + assert ( + com.rover.pos == Vector(x=12, y=27) + and com.rover.planet_size == Vector(x=100, y=100) + and com.rover.dir == Direction.WEST + ) + + +def test_commander_default_values(): + com = Commander() + + assert com.rover == Rover()