コード例 #1
0
ファイル: test_frog_pond.py プロジェクト: hellicott/FrogPond
 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
コード例 #2
0
ファイル: test_frog_pond.py プロジェクト: hellicott/FrogPond
 def test_create_frog_returns_frog_type(self):
     # arrange
     fp = FrogPond(self.config)
     # act
     frog = fp._create_frog(0)
     # assert
     assert type(frog) == Frog
コード例 #3
0
ファイル: test_frog_pond.py プロジェクト: hellicott/FrogPond
 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
コード例 #4
0
ファイル: test_frog_pond.py プロジェクト: hellicott/FrogPond
 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
コード例 #5
0
ファイル: test_frog_pond.py プロジェクト: hellicott/FrogPond
 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
ファイル: test_frog_pond.py プロジェクト: hellicott/FrogPond
 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
ファイル: test_frog_pond.py プロジェクト: hellicott/FrogPond
 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
ファイル: test_frog_pond.py プロジェクト: hellicott/FrogPond
 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
ファイル: visualise.py プロジェクト: hellicott/FrogPond
 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()
コード例 #10
0
ファイル: test_frog_pond.py プロジェクト: hellicott/FrogPond
 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
コード例 #11
0
ファイル: test_frog_pond.py プロジェクト: hellicott/FrogPond
 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
コード例 #12
0
ファイル: test_frog_pond.py プロジェクト: hellicott/FrogPond
 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)
コード例 #13
0
 def __init__(self, config):
     self.frog_pond = FrogPond(config)
     self.vis = Visualise(self.frog_pond)