예제 #1
0
 def test_create_lilly_pad_returns_lilly_pad_type(self):
     # arrange
     fp = FrogPond(self.config)
     # act
     pad = fp._create_lilly_pad()
     # assert
     assert type(pad) == LillyPad
예제 #2
0
 def test_choose_frog_start_point_returns_point(self):
     # arrange
     fp = FrogPond(self.config)
     # act
     point = fp._choose_frog_start_point()
     # assert
     assert type(point) == Point
예제 #3
0
 def test_create_centre_lilly_pad_returns_lillypad_in_centre_of_pond(self):
     # arrange
     fp = FrogPond(self.config)
     # act
     centre_pad = fp._create_centre_lilly_pad()
     # assert
     assert centre_pad.circle.centre_point == fp.pond.circle.centre_point
예제 #4
0
 def test_create_frog_returns_frog_type(self):
     # arrange
     fp = FrogPond(self.config)
     # act
     frog = fp._create_frog(0)
     # assert
     assert type(frog) == Frog
예제 #5
0
 def test_set_constraints_sets_frog_max_range(self):
     # arrange
     self.config.frog_max_jump_distance = 7
     fp = FrogPond(self.config)
     # act
     fp._set_constraints()
     # assert
     assert Frog.max_range == 7
예제 #6
0
 def test_set_constraints_sets_pond_radius(self):
     # arrange
     self.config.pond_radius = 10
     fp = FrogPond(self.config)
     # act
     fp._set_constraints()
     # assert
     assert Pond.radius == 10
예제 #7
0
 def test_set_constraints_sets_lilly_pad_max_radius(self):
     # arrange
     self.config.lilly_pad_radius_max_percentage_of_pond_size = 10
     self.config.pond_radius = 100
     fp = FrogPond(self.config)
     # act
     fp._set_constraints()
     # assert
     assert LillyPad.max_radius == 10
예제 #8
0
 def test_set_constraints_sets_lilly_pad_min_radius(self):
     # arrange
     min_percent = 2
     self.config.pond_radius = 100
     fp = FrogPond(self.config)
     # act
     fp._set_constraints()
     # assert
     assert LillyPad.min_radius == min_percent
예제 #9
0
 def test_is_overlapping_current_lilly_pads_returns_false_when_not_overlapping(self):
     # arrange
     fp = FrogPond(self.config)
     centre_pad = fp._create_centre_lilly_pad()
     pad1 = fp._create_lilly_pad()
     fp.lilly_pads = [centre_pad, pad1]
     overlapping_pad = Circle(Point(10000, 100000), 1)
     # act
     result = fp._is_overlapping_current_lilly_pads(overlapping_pad)
     # assert
     assert result is False
예제 #10
0
 def test_is_overlapping_current_lilly_pads_returns_true_when_overlapping(self):
     # arrange
     fp = FrogPond(self.config)
     centre_pad = fp._create_centre_lilly_pad()
     pad1 = fp._create_lilly_pad()
     fp.lilly_pads = [centre_pad, pad1]
     overlapping_pad = Circle(pad1.circle.centre_point, 3)
     # act
     result = fp._is_overlapping_current_lilly_pads(overlapping_pad)
     # assert
     assert result is True
예제 #11
0
 def test_choose_lilly_pad_position_returns_position_which_does_not_overlap_other_pads(self):
     # arrange
     fp = FrogPond(self.config)
     centre_pad = fp._create_centre_lilly_pad()
     pad1 = fp._create_lilly_pad()
     fp.lilly_pads = [centre_pad, pad1]
     pad2_radius = 3
     # act
     pad2_position = fp._choose_lilly_pad_position(pad2_radius)
     # assert
     pad2 = Circle(pad2_position, pad2_radius)
     assert not pad2.intersects_circle(pad1.circle) \
         and not pad2.intersects_circle(centre_pad.circle)
예제 #12
0
 def __init__(self, config):
     self.frog_pond = FrogPond(config)
     self.vis = Visualise(self.frog_pond)