def test_class_type(self):
     """Test the correct class is subclassed"""
     entity = loader.factory('Test', self.base_defs)
     assert(issubclass(entity, Entity))
     self.base_defs['free_form'] = True
     entity = loader.factory('Test', self.base_defs)
     assert(issubclass(entity, FreeSchemaEntity))
 def test_class_type(self):
     """Test the correct class is subclassed"""
     entity = loader.factory('Test', self.base_defs)
     assert (issubclass(entity, Entity))
     self.base_defs['free_form'] = True
     entity = loader.factory('Test', self.base_defs)
     assert (issubclass(entity, FreeSchemaEntity))
 def test_depends(self):
     """Test that dependencies are set as expected"""
     Test = loader.factory('Test', self.base_defs)
     self.assertEqual(Test.depends, [])
     d = self.base_defs
     d['depends'] = ['a', 'b']
     Test = loader.factory('Test', d)
     self.assertEqual(Test.depends, ['a', 'b'])
 def test_depends(self):
     """Test that dependencies are set as expected"""
     Test = loader.factory('Test', self.base_defs)
     self.assertEqual(Test.depends, [])
     d = self.base_defs
     d['depends'] = ['a', 'b']
     Test = loader.factory('Test', d)
     self.assertEqual(Test.depends, ['a', 'b'])
    def test_entity(self):
        """Test that an entity works as expected"""
        Test = loader.factory('Test', self.base_defs)
        with self.assertRaises(ValueError):
            t = Test('mytest')
        t = Test('entity', 'foo', 'mytest')
        self.assertDictEqual(t.tags, {'test': 'entity', 'example': 'foo'})
        self.assertEqual(t.key, 'example.org/entity/foo/mytest')
        self.assertEqual(Test.dir('a', 'b'), 'example.org/a/b')
        self.assertEqual(t.astring, 'foo')
        self.assertEqual(t.anenum, 'foo')

        with self.assertRaises(ValueError):
            Test.dir('a', 'b', 'c')
    def test_entity(self):
        """Test that an entity works as expected"""
        Test = loader.factory('Test', self.base_defs)
        with self.assertRaises(ValueError):
            t = Test('mytest')
        t = Test('entity', 'foo', 'mytest')
        self.assertDictEqual(t.tags, {'test': 'entity', 'example': 'foo'})
        self.assertEqual(t.key, 'example.org/entity/foo/mytest')
        self.assertEqual(Test.dir('a', 'b'), 'example.org/a/b')
        self.assertEqual(t.astring, 'foo')
        self.assertEqual(t.anenum, 'foo')

        with self.assertRaises(ValueError):
            Test.dir('a', 'b', 'c')
 def test_properties(self):
     """Test that all properties are statically set correctly"""
     entity = loader.factory('Test', self.base_defs)
     self.assertListEqual(entity._tags, ['test', 'example'])
     self.assertEqual(sorted(entity._schema.keys()),
                      sorted(self.base_defs['schema'].keys()))
 def test_base_path(self):
     """Test that base path is correct"""
     entity = loader.factory('Test', self.base_defs)
     self.assertEqual(entity.base_path(), 'example.org')
 def test_properties(self):
     """Test that all properties are statically set correctly"""
     entity = loader.factory('Test', self.base_defs)
     self.assertListEqual(entity._tags, ['test', 'example'])
     self.assertEqual(sorted(entity._schema.keys()), sorted(self.base_defs['schema'].keys()))
 def test_base_path(self):
     """Test that base path is correct"""
     entity = loader.factory('Test', self.base_defs)
     self.assertEqual(entity.base_path(), 'example.org')