diff --git a/README b/README new file mode 120000 index 0000000..42061c0 --- /dev/null +++ b/README @@ -0,0 +1 @@ +README.md \ No newline at end of file diff --git a/cromulent/model.py b/cromulent/model.py index 80982c4..0250c24 100644 --- a/cromulent/model.py +++ b/cromulent/model.py @@ -258,6 +258,8 @@ def __setattr__(self, which, value): ok = self._check_prop(which, value) if not ok: raise DataError("Can't set non-standard field '%s' on resource of type '%s'" % (which, self._type)) + else: + ok = 1 # Allow per class setter functions to do extra magic if hasattr(self, which) and hasattr(self, 'set_%s' % which): diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..dc9eaf9 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,9 @@ +[wheel] +universal = 1 + +[check-manifest] +ignore = + .travis.yml + tox.ini + .gitignore + diff --git a/setup.py b/setup.py index 1f866cf..7cfa642 100644 --- a/setup.py +++ b/setup.py @@ -24,8 +24,8 @@ "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 2", - "License :: OSI Approved :: Apache License", - "Development Status :: pre-Alpha", + "License :: OSI Approved :: Apache Software License", + "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Operating System :: OS Independent", "Topic :: Software Development :: Libraries :: Python Modules", diff --git a/tests/test_model.py b/tests/test_model.py index b9fec0d..4d4cd4e 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -79,6 +79,8 @@ def test_toFile(self): self.assertTrue(os.path.isfile('tests/InformationObject/collection.json')) shutil.rmtree('tests/InformationObject') + + class TestProcessTSV(unittest.TestCase): def test_process_tsv(self): @@ -199,6 +201,22 @@ def test_set_magic_resource_inverse(self): artist._set_magic_resource('parent_of', son) self.assertEqual(son.parent, artist) + def test_validation_unknown(self): + model.factory.validate_properties = True + artist = model.Person('00001', 'Jane Doe') + self.assertRaises(model.DataError, artist.__setattr__, 'unknown_property', 1) + + def test_validation_wrong_type(self): + model.factory.validate_properties = True + artist = model.Person('00001', 'Jane Doe') + self.assertRaises(model.DataError, artist.__setattr__, 'parent_of', 'Bad Value') + + def test_validation_off(self): + model.factory.validate_properties = False + artist = model.Person('00001', 'Jane Doe') + artist.unknown_property = 1 + self.assertEqual(artist.unknown_property, 1) + if __name__ == '__main__': unittest.main()