def test_temp_entity_raise(self): with self.assertRaises( TypeError, msg='Should raise if __init__ called with too few args'): protocol.TempEntity(protocol.TE_BLOOD) with self.assertRaises( TypeError, msg='Should raise if __init__ called with too many args'): position = 0, 0, 0 bad_arg = 16 protocol.TempEntity(protocol.TE_EXPLOSION1, position, bad_arg)
def test_temp_entity_explosions(self): type = protocol.TE_EXPLOSION1 position = 0, 0, 0 te0 = protocol.TempEntity(type, position) protocol.TempEntity.write(self.buff, te0) self.buff.seek(0) te1 = protocol.TempEntity.read(self.buff) self.assertEqual(te0.position, te1.position, 'Position should be equal')
def test_temp_entity_trails(self): type = protocol.TE_RAILTRAIL position = 0, 0, 0 position2 = 16, -128, 255 te0 = protocol.TempEntity(type, position, position2) protocol.TempEntity.write(self.buff, te0) self.buff.seek(0) te1 = protocol.TempEntity.read(self.buff) self.assertEqual(te0.position, te1.position, 'Position should be equal') self.assertEqual(te0.position2, te1.position2, 'Position2 should be equal')
def test_temp_entity_blue_hyperblaster(self): type = protocol.TE_BLUEHYPERBLASTER position = 0, 0, 0 direction = -0.5, 0.0, 0.75 te0 = protocol.TempEntity(type, position, direction) protocol.TempEntity.write(self.buff, te0) self.buff.seek(0) te1 = protocol.TempEntity.read(self.buff) self.assertEqual(te0.position, te1.position, 'Position should be equal') self.assertEqual(te0.direction, te1.direction, 'Direction should be equal')
def test_temp_entity_particles(self): type = protocol.TE_BLOOD position = 0, 0, 0 direction = 16 te0 = protocol.TempEntity(type, position, direction) protocol.TempEntity.write(self.buff, te0) self.buff.seek(0) te1 = protocol.TempEntity.read(self.buff) self.assertEqual(te0.position, te1.position, 'Position should be equal') self.assertEqual(te0.direction, te1.direction, 'Direction should be equal')
def test_temp_entity_splashes(self): type = protocol.TE_SPLASH count = 8 position = -16, 255, 0 direction = 16 te0 = protocol.TempEntity(type, count, position, direction) protocol.TempEntity.write(self.buff, te0) self.buff.seek(0) te1 = protocol.TempEntity.read(self.buff) self.assertEqual(te0.count, te1.count, 'Count should be equal') self.assertEqual(te0.position, te1.position, 'Position should be equal') self.assertEqual(te0.direction, te1.direction, 'Direction should be equal')