From 81dca25a4f8375a4ba5d13f1edd5031c4d0bdf51 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 15 Nov 2019 21:29:57 +0100 Subject: [PATCH] rover: add Commander class --- rover/rover.py | 4 ++++ rover/test_rover.py | 21 ++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) 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()