summaryrefslogtreecommitdiff
path: root/morphlib/morphology_tests.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2011-10-04 13:42:59 +0100
committerLars Wirzenius <liw@liw.fi>2011-10-04 13:42:59 +0100
commitc44c15f7190841497d565f43128b73abe6f9cbfc (patch)
treeb03041d251e2a1873d6420644aabe8218d95f39b /morphlib/morphology_tests.py
parentc45e1325b9930c0008f9cfdbae2c527b3d62de6e (diff)
downloadmorph-c44c15f7190841497d565f43128b73abe6f9cbfc.tar.gz
Remove morphology validation.
The implementation was painful to write, more painful to maintain, and that clashed badly with the need to be able to make changes easily during an exploratory, experimental phase of development. Validation should come back later, when things stabilize.
Diffstat (limited to 'morphlib/morphology_tests.py')
-rw-r--r--morphlib/morphology_tests.py328
1 files changed, 12 insertions, 316 deletions
diff --git a/morphlib/morphology_tests.py b/morphlib/morphology_tests.py
index 2982bb27..243fd89f 100644
--- a/morphlib/morphology_tests.py
+++ b/morphlib/morphology_tests.py
@@ -30,199 +30,8 @@ class MockFile(StringIO.StringIO):
class MorphologyTests(unittest.TestCase):
- def assertRaisesSchemaError(self, morph_dict):
- f = MockFile(json.dumps(morph_dict))
- self.assertRaises(morphlib.morphology.SchemaError,
- morphlib.morphology.Morphology, f)
-
- def test_raises_exception_for_empty_file(self):
- self.assertRaises(ValueError,
- morphlib.morphology.Morphology,
- MockFile())
-
- def test_raises_exception_for_file_without_kind_field(self):
- self.assertRaisesSchemaError({})
-
- def test_raises_exception_for_chunk_with_unknown_keys_only(self):
- self.assertRaisesSchemaError({ 'x': 'y' })
-
- def test_raises_exception_if_name_only(self):
- self.assertRaisesSchemaError({ 'name': 'hello' })
-
- def test_raises_exception_if_name_is_empty(self):
- self.assertRaisesSchemaError({ 'name': '', 'kind': 'chunk',
- 'sources': { 'repo': 'x', 'ref': 'y' }})
-
- def test_raises_exception_if_kind_only(self):
- self.assertRaisesSchemaError({ 'kind': 'chunk' })
-
- def test_raises_exception_for_kind_that_has_unknown_kind(self):
- self.assertRaisesSchemaError({ 'name': 'hello', 'kind': 'x' })
-
- def test_raises_exception_for_chunk_with_nondict_source(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'chunk',
- 'source': [],
- })
-
- def test_raises_exception_for_chunk_with_empty_source(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'chunk',
- 'source': {},
- })
-
- def test_raises_exception_for_chunk_without_repo_in_source(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'chunk',
- 'source': {
- 'x': 'y'
- },
- })
-
- def test_raises_exception_for_chunk_with_empty_repo_in_source(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'chunk',
- 'source': {
- 'repo': '',
- 'ref': 'master'
- },
- })
-
- def test_raises_exception_for_chunk_without_ref_in_source(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'chunk',
- 'source': {
- 'repo': 'foo',
- },
- })
-
- def test_raises_exception_for_chunk_with_empty_ref_in_source(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'chunk',
- 'source': {
- 'repo': 'foo',
- 'ref': ''
- },
- })
-
- def test_raises_exception_for_chunk_with_unknown_keys_in_source(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'chunk',
- 'source': {
- 'repo': 'foo',
- 'ref': 'master',
- 'x': 'y'
- },
- })
-
- def test_raises_exception_for_chunk_with_unknown_keys(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'chunk',
- 'source': {
- 'repo': 'foo',
- 'ref': 'master'
- },
- 'x': 'y'
- })
-
- def test_raises_exception_for_nonlist_configure_commands(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'chunk',
- 'source': {
- 'repo': 'foo',
- 'ref': 'master'
- },
- 'configure-commands': 0,
- })
-
- def test_raises_exception_for_list_of_nonstring_configure_commands(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'chunk',
- 'source': {
- 'repo': 'foo',
- 'ref': 'master'
- },
- 'configure-commands': [0],
- })
-
- def test_raises_exception_for_nonlist_build_commands(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'chunk',
- 'source': {
- 'repo': 'foo',
- 'ref': 'master'
- },
- 'build-commands': 0,
- })
-
- def test_raises_exception_for_list_of_nonstring_build_commands(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'chunk',
- 'source': {
- 'repo': 'foo',
- 'ref': 'master'
- },
- 'build-commands': [0],
- })
-
- def test_raises_exception_for_nonlist_test_commands(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'chunk',
- 'source': {
- 'repo': 'foo',
- 'ref': 'master'
- },
- 'test-commands': 0,
- })
-
- def test_raises_exception_for_list_of_nonstring_test_commands(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'chunk',
- 'source': {
- 'repo': 'foo',
- 'ref': 'master'
- },
- 'build-commands': [0],
- })
-
- def test_raises_exception_for_nonlist_install_commands(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'chunk',
- 'source': {
- 'repo': 'foo',
- 'ref': 'master'
- },
- 'install-commands': 0,
- })
-
- def test_raises_exception_for_list_of_nonstring_install_commands(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'chunk',
- 'source': {
- 'repo': 'foo',
- 'ref': 'master'
- },
- 'install-commands': [0],
- })
-
def test_accepts_valid_chunk_morphology(self):
- chunk = morphlib.morphology.Morphology(
+ morph = morphlib.morphology.Morphology(
MockFile('''
{
"name": "hello",
@@ -232,130 +41,13 @@ class MorphologyTests(unittest.TestCase):
"test-commands": ["make check"],
"install-commands": ["make install"]
}'''))
- self.assertEqual(chunk.kind, 'chunk')
- self.assertEqual(chunk.filename, 'mockfile')
-
- def test_raises_exception_for_stratum_without_sources(self):
- self.assertRaisesSchemaError({ 'name': 'hello', 'kind': 'stratum' })
-
- def test_raises_exception_for_stratum_with_nondict_sources(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'stratum',
- 'sources': [],
- })
-
- def test_raises_exception_for_stratum_with_empty_sources(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'stratum',
- 'sources': {},
- })
-
- def test_raises_exception_for_stratum_with_bad_children_in_sources(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'stratum',
- 'sources': {
- 'foo': 0,
- },
- })
-
- def test_raises_exception_for_stratum_without_repo_in_sources(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'stratum',
- 'sources': {
- 'foo': {
- 'ref': 'master'
- }
- },
- })
-
- def test_raises_exception_for_stratum_with_empty_repo_in_sources(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'stratum',
- 'sources': {
- 'foo': {
- 'repo': '',
- 'ref': 'master'
- }
- },
- })
-
- def test_raises_exception_for_stratum_with_nonstring_repo_in_sources(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'stratum',
- 'sources': {
- 'foo': {
- 'repo': 0,
- 'ref': 'master'
- }
- },
- })
-
- def test_raises_exception_for_stratum_without_ref_in_sources(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'stratum',
- 'sources': {
- 'foo': {
- 'repo': 'foo',
- }
- },
- })
-
- def test_raises_exception_for_stratum_with_empty_ref_in_sources(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'stratum',
- 'sources': {
- 'foo': {
- 'repo': 'foo',
- 'ref': ''
- }
- },
- })
-
- def test_raises_exception_for_stratum_with_nonstring_ref_in_sources(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'stratum',
- 'sources': {
- 'foo': {
- 'repo': 'foo',
- 'ref': 0
- }
- },
- })
-
- def test_raises_exception_for_stratum_with_unknown_keys_in_sources(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'stratum',
- 'sources': {
- 'foo': {
- 'repo': 'foo',
- 'ref': 'master',
- 'x': 'y'
- }
- },
- })
-
- def test_raises_exception_for_stratum_with_unknown_keys(self):
- self.assertRaisesSchemaError({
- 'name': 'hello',
- 'kind': 'stratum',
- 'sources': {
- 'foo': {
- 'repo': 'foo',
- 'ref': 'master'
- }
- },
- 'x': 'y'
- })
+ self.assertEqual(morph.name, 'hello')
+ self.assertEqual(morph.kind, 'chunk')
+ self.assertEqual(morph.filename, 'mockfile')
+ self.assertEqual(morph.configure_commands, ['./configure'])
+ self.assertEqual(morph.build_commands, ['make'])
+ self.assertEqual(morph.test_commands, ['make check'])
+ self.assertEqual(morph.install_commands, ['make install'])
def test_accepts_valid_stratum_morphology(self):
morph = morphlib.morphology.Morphology(
@@ -373,6 +65,10 @@ class MorphologyTests(unittest.TestCase):
}'''))
self.assertEqual(morph.kind, 'stratum')
self.assertEqual(morph.filename, 'mockfile')
+ self.assertEqual(morph.sources,
+ {
+ 'foo': { 'repo': 'foo/', 'ref': 'ref' },
+ })
def test_accepts_valid_system_morphology(self):
morph = morphlib.morphology.Morphology(