/usr/share/pyshared/collada/tests/test_source.py is in python-collada 0.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | import numpy
import collada
from collada.util import unittest
from collada.xmlutil import etree
fromstring = etree.fromstring
tostring = etree.tostring
class TestSource(unittest.TestCase):
def setUp(self):
self.dummy = collada.Collada(validate_output=True)
def test_float_source_saving(self):
floatsource = collada.source.FloatSource("myfloatsource", numpy.array([0.1,0.2,0.3]), ('X', 'Y', 'X'))
self.assertEqual(floatsource.id, "myfloatsource")
self.assertEqual(len(floatsource), 1)
self.assertTupleEqual(floatsource.components, ('X', 'Y', 'X'))
self.assertIsNotNone(str(floatsource))
floatsource.id = "yourfloatsource"
floatsource.components = ('S', 'T')
floatsource.data = numpy.array([0.4, 0.5, 0.6, 0.7, 0.8, 0.9])
floatsource.save()
loaded_floatsource = collada.source.Source.load(self.dummy, {}, fromstring(tostring(floatsource.xmlnode)))
self.assertTrue(isinstance(loaded_floatsource, collada.source.FloatSource))
self.assertEqual(floatsource.id, "yourfloatsource")
self.assertEqual(len(floatsource), 3)
self.assertTupleEqual(floatsource.components, ('S', 'T'))
def test_idref_source_saving(self):
idrefsource = collada.source.IDRefSource("myidrefsource",
numpy.array(['Ref1', 'Ref2'], dtype=numpy.string_),
('MORPH_TARGET',))
self.assertEqual(idrefsource.id, "myidrefsource")
self.assertEqual(len(idrefsource), 2)
self.assertTupleEqual(idrefsource.components, ('MORPH_TARGET',))
self.assertIsNotNone(str(idrefsource))
idrefsource.id = "youridrefsource"
idrefsource.components = ('JOINT_TARGET', 'WHATEVER_TARGET')
idrefsource.data = numpy.array(['Ref5', 'Ref6', 'Ref7', 'Ref8', 'Ref9', 'Ref10'], dtype=numpy.string_)
idrefsource.save()
loaded_idrefsource = collada.source.Source.load(self.dummy, {}, fromstring(tostring(idrefsource.xmlnode)))
self.assertTrue(isinstance(loaded_idrefsource, collada.source.IDRefSource))
self.assertEqual(loaded_idrefsource.id, "youridrefsource")
self.assertEqual(len(loaded_idrefsource), 3)
self.assertTupleEqual(loaded_idrefsource.components, ('JOINT_TARGET', 'WHATEVER_TARGET'))
def test_name_source_saving(self):
namesource = collada.source.NameSource("mynamesource",
numpy.array(['Name1', 'Name2'], dtype=numpy.string_),
('JOINT',))
self.assertEqual(namesource.id, "mynamesource")
self.assertEqual(len(namesource), 2)
self.assertTupleEqual(namesource.components, ('JOINT',))
self.assertIsNotNone(str(namesource))
namesource.id = "yournamesource"
namesource.components = ('WEIGHT', 'WHATEVER')
namesource.data = numpy.array(['Name1', 'Name2', 'Name3', 'Name4', 'Name5', 'Name6'], dtype=numpy.string_)
namesource.save()
loaded_namesource = collada.source.Source.load(self.dummy, {}, fromstring(tostring(namesource.xmlnode)))
self.assertTrue(isinstance(loaded_namesource, collada.source.NameSource))
self.assertEqual(loaded_namesource.id, "yournamesource")
self.assertEqual(len(loaded_namesource), 3)
self.assertTupleEqual(loaded_namesource.components, ('WEIGHT', 'WHATEVER'))
if __name__ == '__main__':
unittest.main()
|