def test_colide_meteorit_top(self): """ Test collision with top part of meteorite """ my_meteorit = meteorit.Meteorit(source='pictures/meteor_smaller.png', pos=(100, 100)) rocket_x_collision_threshold = my_meteorit.x - rocket.ROCKET_WIDTH + meteorit.COLLISION_TOP_LEFT_OFFSET rocket_y_collision_threshold = my_meteorit.y - rocket.ROCKET_HEIGHT + meteorit.COLLISION_TOP_BOTTOM_OFFSET test_rocket = rocket.Rocket(pos=(rocket_x_collision_threshold + 1, rocket_y_collision_threshold + 1)) self.assertTrue(my_meteorit.collide_meteorit(test_rocket), msg='Collision with top meteorit wasn\'t detected !')
def test_activate_explosion_when_one_in_progress(self): my_rocket = rocket.Rocket(pos=(60, 20)) my_rocket.collision_in_progress = True my_rocket.new_collision_detected = True my_rocket.collision_complete = False my_rocket._Rocket__explode = Mock(name='explode') my_rocket.activate_explosion() my_rocket._Rocket__explode.assert_not_called() self.assertTrue(my_rocket.new_collision_detected, msg='New collision state was cleared!') self.assertTrue(my_rocket.collision_in_progress, msg='Collision process didn\'t start!') self.assertFalse(my_rocket.collision_complete, msg='Collision finished already!')
def test_default_rocket(self): my_rocket = rocket.Rocket(pos=(60, 20)) # self.assertIsNone(self.param.action, msg='action is "None" by default') # self.assertTrue(True, msg='(test 01) Verifying that assert works.') self.assertIsNotNone(my_rocket, msg='Rocket obj is None!') self.assertFalse( my_rocket.new_collision_detected, msg='There is new collision when new Rocket is created !') self.assertFalse( my_rocket.collision_in_progress, msg='There is collision in progress when Rocket is created!') self.assertFalse( my_rocket.collision_complete, msg='There is collision completed when Rocket is created!')