summaryrefslogtreecommitdiff
path: root/morphlib/morphologyfactory_tests.py
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2013-08-07 12:00:49 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2013-08-07 13:41:40 +0100
commit40be81b74d63e1ba7bd3e10a78c79d3829673172 (patch)
tree1c88237b7431c734ec515df2067ad15e06327c80 /morphlib/morphologyfactory_tests.py
parent66291811c81ed21f5005ba35e68898c73edd88bd (diff)
downloadmorph-40be81b74d63e1ba7bd3e10a78c79d3829673172.tar.gz
morphologyfactory: move empty stratum check here
It is better to test whether a straum is empty here, since it will be noticed earlier in the build, as soon as the morphologies are loaded, rather than after they have all been parsed. It is also conceptually nicer to put it here, since the morphologyfactory was written to perform this kind of validation. On a more practical note, the validation is moved here so that the test for this error isn't masked by the test for no build dependencies. To ensure tests still pass, we alter the stratum morphology used by other unit tests to no longer be empty, and add an empty one to test.
Diffstat (limited to 'morphlib/morphologyfactory_tests.py')
-rw-r--r--morphlib/morphologyfactory_tests.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/morphlib/morphologyfactory_tests.py b/morphlib/morphologyfactory_tests.py
index 7a3dc343..de1be017 100644
--- a/morphlib/morphologyfactory_tests.py
+++ b/morphlib/morphologyfactory_tests.py
@@ -57,7 +57,15 @@ class FakeLocalRepo(object):
}''',
'stratum.morph': '''{
"name": "stratum",
- "kind": "stratum"
+ "kind": "stratum",
+ "chunks": [
+ {
+ "name": "chunk",
+ "repo": "test:repo",
+ "ref": "sha1",
+ "build-depends": []
+ }
+ ]
}''',
'stratum-no-chunk-bdeps.morph': '''{
"name": "stratum-no-chunk-bdeps",
@@ -71,6 +79,10 @@ class FakeLocalRepo(object):
}
]
}''',
+ 'stratum-empty.morph': '''{
+ "name": "stratum-empty",
+ "kind": "stratum"
+ }''',
'system.morph': '''{
"name": "system",
"kind": "system",
@@ -278,3 +290,8 @@ class MorphologyFactoryTests(unittest.TestCase):
self.mf.get_morphology, 'reponame', 'sha1',
'stratum-no-chunk-bdeps.morph')
+ def test_fails_on_empty_stratum(self):
+ self.assertRaises(
+ morphlib.morphologyfactory.EmptyStratumError,
+ self.mf.get_morphology, 'reponame', 'sha1', 'stratum-empty.morph')
+