Esempio n. 1
0
    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)
Esempio n. 2
0
    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)
Esempio n. 3
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)
Esempio n. 4
0
    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')
Esempio n. 5
0
    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)
Esempio n. 6
0
    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)
Esempio n. 7
0
    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)
Esempio n. 8
0
    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)
Esempio n. 9
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)
Esempio n. 10
0
    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)
Esempio n. 11
0
    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)
Esempio n. 12
0
 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)