rover: add Commander class
This commit is contained in:
parent
4a79fd4c7f
commit
81dca25a4f
|
@ -56,3 +56,7 @@ class Rover(BaseModel):
|
|||
|
||||
def turn_right(self):
|
||||
self._turn(1)
|
||||
|
||||
|
||||
class Commander(BaseModel):
|
||||
rover: Rover = Rover()
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue