def test_teleport_with_smaller_custom_back_track(self): p = [(100, y) for y in range(30, 360)] b = balloon.BalloonState((0, 0, 255), (50, 60), p) b.path_index = 50 b.teleport(40) self.assertEqual(b.path_index, 10)
def test_teleport_with_larger_default_back_track(self): p = [(100, y) for y in range(30, 360)] b = balloon.BalloonState((0, 0, 255), (50, 60), p) b.path_index = 10 b.teleport() self.assertEqual(b.path_index, 0)
def test_update_with_no_collided_bullets(self, mock_spritecollide): mock_spritecollide.return_value = None p = [(100, y) for y in range(30, 360)] b = balloon.BalloonState((0, 0, 255), (50, 60), p) return_value = b.update('fake_bullet_sprites') self.assertIsNone(return_value)
def test_update_with_invalid_type_as_collided_bullets( self, mock_spritecollide): collided_bullets = Mock(spec=int) mock_spritecollide.return_value = [collided_bullets] p = [(100, y) for y in range(30, 360)] b = balloon.BalloonState((0, 0, 255), (50, 60), p) self.assertRaises(NotImplementedError, b.update, 'fake_bullet_sprites')
def test_get_centerX(self): p = [(100, y) for y in range(30, 360)] b = balloon.BalloonState((0, 0, 255), (50, 60), p) b.rect.centery = 120 balloon_context = balloon.Balloon(b) return_value = balloon_context.get_centerY() self.assertEqual(return_value, 120)
def test_move_with_out_of_range_path_index(self): p = [(100, y) for y in range(30, 360)] b = balloon.BalloonState((0, 0, 255), (50, 60), p) b.path_index = 329 self.assertRaises(NotImplementedError, b.move) b.path_index = 500 self.assertRaises(NotImplementedError, b.move)
def test_move_with_valid_path_index(self): p = [(100, y) for y in range(30, 360)] b = balloon.BalloonState((0, 0, 255), (50, 60), p) b.path_index = 10 b.move() self.assertEqual(b.rect.centerx, 100) self.assertEqual(b.rect.centery, 40) self.assertEqual(b.path_index, 11)
def test_update_with_none_is_handle_pop(self, mock_handle_pop, mock_update): mock_update.return_value = None p = [(100, y) for y in range(30, 360)] b = balloon.BalloonState((0, 0, 255), (50, 60), p) balloon_context = balloon.Balloon(b) balloon_context.update('fake_bullet_sprites') self.assertEqual(mock_handle_pop.call_count, 0)
def test_update_with_TeleportationBullet_as_collided_bullets( self, mock_spritecollide): collided_bullets = Mock(spec=bullet.TeleportationBullet) mock_spritecollide.return_value = [collided_bullets] p = [(100, y) for y in range(30, 360)] b = balloon.BalloonState((0, 0, 255), (50, 60), p) return_value = b.update('fake_bullet_sprites') self.assertFalse(return_value)
def test_update_with_ExplosionBullet_as_collided_bullets( self, mock_spritecollide): collided_bullets = Mock(spec=bullet.ExplosionBullet) collided_bullets.pop_power = Mock(spec=int) mock_spritecollide.return_value = [collided_bullets] p = [(100, y) for y in range(30, 360)] b = balloon.BalloonState((0, 0, 255), (50, 60), p) return_value = b.update('fake_bullet_sprites') self.assertIsInstance(return_value, int)
def test_init_with_defaults(self): p = [(100, y) for y in range(30, 360)] b = balloon.BalloonState((0, 0, 255), (50, 60), p) self.assertEqual(b.image.get_width(), 50) self.assertEqual(b.image.get_height(), 60) self.assertEqual(b.image.get_at((10, 10)), (0, 0, 255, 255)) self.assertEqual(b.path_index, 0) self.assertEqual(b.rect.centerx, 100) self.assertEqual(b.rect.centery, 30) self.assertEqual(b.path, p) self.assertEqual(b.bounty, 20)
def test_init(self): p = [(100, y) for y in range(30, 360)] b = balloon.BalloonState((0, 0, 255), (50, 60), p) balloon_context = balloon.Balloon(b) self.assertEqual(balloon_context.current_balloon_state, b)