def test_leave_updates_occupied_to_false(self): # arrange lilly_pad_centre = Point(1, 1) pad = LillyPad(lilly_pad_centre, 2) # act pad.leave() # assert assert pad.currently_occupied is False
def test_visit_updates_the_visited_list(self): # arrange lilly_pad_centre = Point(1, 1) pad = LillyPad(lilly_pad_centre, 2) frog_id = 2 # act pad.visit(frog_id) # assert assert frog_id in pad.visited_frogs
def test_occupied_returns_false_when_lilly_pad_not_occupied(self): # arrange lilly_pad_centre = Point(1, 1) pad = LillyPad(lilly_pad_centre, 2) pad.currently_occupied = False # act result = pad.occupied() # assert assert result is False
def test_within_reach_returns_false_when_frog_cannot_reach_lilly_pad(self): # arrange frog_circle = Circle(Point(20, 20), 2) lilly_pad_centre = Point(1, 1) pad = LillyPad(lilly_pad_centre, 2) # act result = pad.within_reach(frog_circle) # assert assert result is False
def test_find_possible_pads_returns_no_pads_if_nearby_pad_occupied(self): # arrange position = Point(2, 2) frog = Frog(position, 5, 0) pad = LillyPad(Point(2, 4), 1) pad.currently_occupied = True # act possible_pads = frog._find_possible_lilly_pads([pad]) # assert assert len(possible_pads) == 0
def test_visit_updates_occupied_to_true(self): # arrange lilly_pad_centre = Point(1, 1) pad = LillyPad(lilly_pad_centre, 2) frog_id = 2 # act pad.visit(frog_id) # assert assert pad.currently_occupied is True
def test_visited_by_returns_false_when_frog_not_visited(self): # arrange centre = Point(1, 1) pad = LillyPad(centre, 2) frog_id = 2 pad.visited_frogs = [frog_id+1] # act result = pad.visited_by(frog_id) # assert assert result is False
def test_lilly_pad_has_circle_attribute_in_expected_position(self): # arrange centre = Point(1, 1) # act pad = LillyPad(centre, 2) # assert assert pad.circle.centre_point == centre
def test_lilly_pad_has_circle_attribute_of_expected_size(self): # arrange centre = Point(1, 1) radius = 2 # act pad = LillyPad(centre, radius) # assert assert pad.circle.radius == radius
def test_find_possible_lilly_pads_returns_empty_list_when_none_are_available( self): # arrange position = Point(20, 20) frog = Frog(position, 1, 0) pad = LillyPad(Point(2, 4), 1) # act possible_pads = frog._find_possible_lilly_pads([pad]) # assert assert len(possible_pads) == 0
def test_find_possible_lilly_pads_returns_list_of_lilly_pads_when_some_are_available( self): # arrange position = Point(2, 2) frog = Frog(position, 1, 0) pad = LillyPad(Point(2, 4), 1) # act possible_pads = frog._find_possible_lilly_pads([pad]) # assert assert pad in possible_pads
def _create_centre_lilly_pad(self): position = self.pond.circle.centre_point radius = self._choose_radius(LillyPad.min_radius, LillyPad.max_radius) return LillyPad(position, radius, centre_pad=True)
def _create_lilly_pad(self): radius = self._choose_radius(LillyPad.min_radius, LillyPad.max_radius) position = self._choose_lilly_pad_position(radius) return LillyPad(position, radius)