Exemplo n.º 1
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
Exemplo n.º 2
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
Exemplo n.º 3
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
Exemplo n.º 4
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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 9
0
 def __init__(self, frog_pond: FrogPond):
     master = Tk()
     self.buffer = 50
     size = (frog_pond.get_pond_circle().radius + self.buffer) * 2
     self.frog_pond = frog_pond
     self.canvas = Canvas(master, width=size, height=size, bg="forestgreen")
     self._draw_board()
     self.canvas.pack()
     master.mainloop()
Exemplo n.º 10
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
Exemplo n.º 11
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
Exemplo n.º 12
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)
Exemplo n.º 13
0
 def __init__(self, config):
     self.frog_pond = FrogPond(config)
     self.vis = Visualise(self.frog_pond)