def test_update(self): from lepton import ParticleSystem system = ParticleSystem() group1 = TestGroup() group2 = TestGroup() system.add_group(group1) system.add_group(group2) self.failIf(group1.updated) self.failIf(group2.updated) system.update(0.05) self.failUnless(group1.updated) self.failUnless(group2.updated)
def test_draw(self): from lepton import ParticleSystem system = ParticleSystem() group1 = TestGroup() group2 = TestGroup() system.add_group(group1) system.add_group(group2) self.failIf(group1.drawn) self.failIf(group2.drawn) system.draw() self.failUnless(group1.drawn) self.failUnless(group2.drawn)
def test_add_remove_group(self): """""" from lepton import ParticleSystem system = ParticleSystem() self.failIf(system.groups) test_group = object() system.add_group(test_group) self.assertEqual(len(system.groups), 1) system.remove_group(test_group) self.assertEqual(len(system.groups), 0) self.assertRaises(ValueError, system.remove_group, test_group)
def test_run_ahead(self): from lepton import ParticleSystem system = ParticleSystem() group1 = TestGroup() group2 = TestGroup() system.add_group(group1) system.add_group(group2) self.failIf(group1.updated) self.failIf(group2.updated) system.run_ahead(2, 30) self.assertEqual(group1.updated, 60) self.assertEqual(group1.time_delta, 1.0 / 30.0) self.assertEqual(group2.updated, 60) self.assertEqual(group2.time_delta, 1.0 / 30.0) self.failIf(group1.drawn) self.failIf(group2.drawn)
def test_len_contains_iter(self): """Test built in __len__, __contains__, __iter__""" from lepton import ParticleSystem system = ParticleSystem() test_group = object() self.assertFalse(test_group in system) self.assertEqual(list(iter(system)), []) system.add_group(test_group) self.assertEqual(len(system), 1) self.assertEqual(len(system.groups), len(system)) self.assertTrue(test_group in system) self.assertEqual(list(iter(system)), [test_group]) another_group = object() self.assertFalse(another_group in system) system.add_group(another_group) self.assertTrue(another_group in system) self.assertEqual(list(iter(system)), [test_group, another_group])