rover: add Commander class

This commit is contained in:
Bruno BELANYI 2019-11-15 21:29:57 +01:00
parent 4a79fd4c7f
commit 81dca25a4f
2 changed files with 24 additions and 1 deletions

View file

@ -56,3 +56,7 @@ class Rover(BaseModel):
def turn_right(self):
self._turn(1)
class Commander(BaseModel):
rover: Rover = Rover()

View file

@ -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()