Example #1
0
 def testDestroyBullet(self):
     """Test destroying bullet"""
     bullets = Bullets(self.event_manager)
     sector = Sector()
     direction = 0
     bullets.create_bullet(sector, direction)
     bullets.destroy_bullet(bullets.bullets[0])
     self.assertTrue(len(bullets.bullets) == 0)
     self.assertTrue(isinstance(self.event_tester.last_event(), BulletDestroyedEvent))
Example #2
0
 def testCreateBullet(self):
     """Test creating bullet"""
     bullets = Bullets(self.event_manager)
     sector = Sector()
     direction = 0
     bullets.create_bullet(sector, direction)
     self.assertTrue(len(bullets.bullets) == 1)
     self.assertEquals(bullets.bullets[0].sector, sector)
     self.assertEqual(bullets.bullets[0].direction, direction)
Example #3
0
    def testNotifyTickEvent(self):
        """Test notifying bullets about tick event"""
        bullets = Bullets(self.event_manager)

        def register_move_bullets_call():
            register_move_bullets_call.called = True

        bullets.move_bullets = register_move_bullets_call
        bullets.move_bullets.called = False
        event = TickEvent()
        bullets.notify(event)
        # there are no bullets -> False
        self.assertFalse(bullets.move_bullets.called)
        bullets.create_bullet(Sector(), 0)
        bullets.notify(event)
        self.assertTrue(bullets.move_bullets.called)
Example #4
0
 def testMoveBullets(self):
     """Test moving bullets"""
     bullets = Bullets(self.event_manager)
     bullets.move_bullets()
     self.assertTrue(isinstance(self.event_tester.last_event(), BulletsMoveEvent))