def test_correct_position_in_border(self): for i in range(0, 1000): from data.Disc import Disc Disc.load_image = Mock() po = Disc( random.randint(self.MIN_RANDOM_POSITION, self.MAX_RANDOM_POSITION), random.randint(self.MIN_RANDOM_POSITION, self.MAX_RANDOM_POSITION), 1, random.randint(self.MIN_RANDOM_RADIUS, self.MAX_RANDOM_RADIUS), [(25, 50), (25, 50)]) xmin, xmax = po._borders[0] ymin, ymax = po._borders[1] po.correct_position_in_borders() self.assertTrue(po._pos.x - po._radius >= xmin and po._pos.x + po._radius <= xmax and po._pos.y - po._radius >= ymin and po._pos.y + po._radius <= ymax)
def test_correct_position_post_collision(self): from data.Mallet import Mallet from data.Disc import Disc mock = Mock() mock.playerColor = 1 Mallet.load_image = Mock() Disc.load_image = Mock() m = Mallet(10, 35, 35, 1, mock, [(0, 100), (0, 100)]) d = Disc(37, 37, 1, 10, [(0, 100), (0, 100)]) m.correct_position_post_collision(d) distance_vector = m.pos - d.pos self.assertTrue(distance_vector.length >= m.radius + d.radius) m = Mallet(10, 35, 35, 1, mock, [(0, 100), (0, 100)]) d = Disc(37, 37, 1, 10, [(0, 100), (0, 100)]) d.correct_position_post_collision(m) distance_vector = m.pos - d.pos self.assertTrue(distance_vector.length >= m.radius + d.radius)