def test_create_schema():
    r"""Test create_schema."""
    assert_raises(RuntimeError, ObjMetaschemaType.create_schema, overwrite=False)
    temp = os.path.join(tempfile.gettempdir(), 'temp_schema')
    old_schema = ObjMetaschemaType.get_schema()
    try:
        shutil.move(ObjMetaschemaType._schema_file, temp)
        new_schema = ObjMetaschemaType.get_schema()
        assert_equal(old_schema, new_schema)
    except BaseException:  # pragma: debug
        shutil.move(temp, ObjMetaschemaType._schema_file)
        raise
    shutil.move(temp, ObjMetaschemaType._schema_file)
 def after_class_creation(cls):
     r"""Actions to be taken during class construction."""
     parent.TestPlyMetaschemaType.after_class_creation(cls)
     cls._value = _test_value
     cls._fulldef = {'type': cls.get_import_cls().name}
     cls._typedef = {'type': cls._fulldef['type']}
     cls._valid_encoded = [cls._fulldef]
     cls._valid_decoded = [cls._value,
                           ObjMetaschemaType.ObjDict(**_test_value),
                           {'vertices': cls._value['vertices'],
                            'faces': [[{'vertex_index': 0},
                                       {'vertex_index': 1},
                                       {'vertex_index': 2}]]}]
     # TODO: Add tests for faces with just texcoord or normal?
     cls._invalid_encoded = [{}]
     cls._invalid_decoded = [{'vertices': [{k: 0.0 for k in 'xyz'}],
                              'faces': [[{'vertex_index': 0},
                                         {'vertex_index': 1},
                                         {'vertex_index': 2}]]},
                             {'vertices': [], 'faces': None,
                              'lines': [[None]],
                              'surfaces': [{'vertex_indices': [[]]}]},
                             {'vertices': cls._value['vertices'],
                              'texcoords': cls._value['texcoords'],
                              'normals': cls._value['normals'],
                              'faces': [[{'vertex_index': 0,
                                          'texcoord_index': 100,
                                          'normal_index': 100},
                                         {'vertex_index': 1},
                                         {'vertex_index': 2}]]},
                             None]
     cls._compatible_objects = [(cls._value, cls._value, None)]
Ejemplo n.º 3
0
 def __init__(self, *args, **kwargs):
     super(TestObjMetaschemaType, self).__init__(*args, **kwargs)
     self._value = _test_value
     self._fulldef = {'type': self.import_cls.name}
     self._typedef = {'type': self.import_cls.name}
     self._valid_encoded = [self._fulldef]
     self._valid_decoded = [
         self._value,
         ObjMetaschemaType.ObjDict(**_test_value), {
             'vertices':
             self._value['vertices'],
             'faces': [[{
                 'vertex_index': 0
             }, {
                 'vertex_index': 1
             }, {
                 'vertex_index': 2
             }]]
         }
     ]
     self._invalid_encoded = [{}]
     self._invalid_decoded = [{
         'vertices': [{k: 0.0
                       for k in 'xyz'}],
         'faces': [[{
             'vertex_index': 0
         }, {
             'vertex_index': 1
         }, {
             'vertex_index': 2
         }]]
     }, {
         'vertices': [],
         'faces': None,
         'lines': [[None]],
         'surfaces': [{
             'vertex_indices': [[]]
         }]
     }, {
         'vertices':
         self._value['vertices'],
         'texcoords':
         self._value['texcoords'],
         'normals':
         self._value['normals'],
         'faces': [[{
             'vertex_index': 0,
             'texcoord_index': 100,
             'normal_index': 100
         }, {
             'vertex_index': 1
         }, {
             'vertex_index': 2
         }]]
     }, None]
     self._compatible_objects = [(self._value, self._value, None)]
Ejemplo n.º 4
0
 def valid_decoded(self, value, obj_test_value):
     r"""list: Objects that are valid under this type."""
     out = [
         value,
         ObjMetaschemaType.ObjDict(**obj_test_value), {
             'vertices':
             value['vertices'],
             'faces': [[{
                 'vertex_index': 0
             }, {
                 'vertex_index': 1
             }, {
                 'vertex_index': 2
             }]]
         }
     ]
     if ObjMetaschemaType.trimesh:
         out.append(
             ObjMetaschemaType.ObjDict(**obj_test_value).as_trimesh())
     return out