diff options
author | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2014-08-08 09:00:34 +0000 |
---|---|---|
committer | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2014-08-14 13:28:50 +0000 |
commit | 4984492dc11888ae35452c437d666cb64dce1a87 (patch) | |
tree | f069c04ec9ef7a00ac99bbbca03be7fe5e1ecaf3 /morphlib/morphologyfactory_tests.py | |
parent | 9e35ea90a1f2c41c3808633e76930f86da6336e5 (diff) | |
download | morph-4984492dc11888ae35452c437d666cb64dce1a87.tar.gz |
morphologyfactory: Use morphloader not morph2
This commit reworks morphologyfactory to stop using morph2. It removes
the validation that is already handled by morphloader, and uses
morphloader to load the morphology rather than using morph2. The unit
tests are also changed to turn the example morphologies into YAML, and
also to check for the correct exceptions.
Diffstat (limited to 'morphlib/morphologyfactory_tests.py')
-rw-r--r-- | morphlib/morphologyfactory_tests.py | 165 |
1 files changed, 73 insertions, 92 deletions
diff --git a/morphlib/morphologyfactory_tests.py b/morphlib/morphologyfactory_tests.py index 47bf3153..347d93f7 100644 --- a/morphlib/morphologyfactory_tests.py +++ b/morphlib/morphologyfactory_tests.py @@ -17,7 +17,6 @@ import unittest import morphlib -from morphlib.morph2 import Morphology from morphlib.morphologyfactory import (MorphologyFactory, MorphologyNotFoundError, NotcachedError) @@ -41,94 +40,76 @@ class FakeRemoteRepoCache(object): class FakeLocalRepo(object): morphologies = { - 'chunk.morph': '''{ - "name": "chunk", - "kind": "chunk", - "build-system": "bar" - }''', - 'chunk-split.morph': '''{ - "name": "chunk-split", - "kind": "chunk", - "build-system": "bar", - "products": [ - { - "artifact": "chunk-split-runtime", - "include": [] - }, - { - "artifact": "chunk-split-devel", - "include": [] - } - ] - }''', - 'stratum.morph': '''{ - "name": "stratum", - "kind": "stratum", - "chunks": [ - { - "name": "chunk", - "repo": "test:repo", - "ref": "sha1", - "build-mode": "bootstrap", - "build-depends": [] - } - ] - }''', - 'stratum-no-chunk-bdeps.morph': '''{ - "name": "stratum-no-chunk-bdeps", - "kind": "stratum", - "chunks": [ - { - "name": "chunk", - "repo": "test:repo", - "ref": "sha1", - "build-mode": "bootstrap" - } - ] - }''', - 'stratum-no-bdeps-no-bootstrap.morph': '''{ - "name": "stratum-no-bdeps-no-bootstrap", - "kind": "stratum", - "chunks": [ - { - "name": "chunk", - "repo": "test:repo", - "ref": "sha1", - "build-depends": [] - } - ] - }''', - 'stratum-bdeps-no-bootstrap.morph': '''{ - "name": "stratum-bdeps-no-bootstrap", - "kind": "stratum", - "build-depends": [ - { - "morph": "stratum" - } - ], - "chunks": [ - { - "name": "chunk", - "repo": "test:repo", - "ref": "sha1", - "build-depends": [] - } - ] - }''', - 'stratum-empty.morph': '''{ - "name": "stratum-empty", - "kind": "stratum" - }''', - 'system.morph': '''{ - "name": "system", - "kind": "system", - "arch": "%(arch)s" - }''', - 'parse-error.morph': '''{ "name"''', - 'name-mismatch.morph': '''{ - "name": "fred", - "kind": "stratum" - }''', + 'chunk.morph': ''' + name: chunk + kind: chunk + build-system: bar + ''', + 'chunk-split.morph': ''' + name: chunk-split + kind: chunk + build-system: bar + products: + - artifact: chunk-split-runtime + include: [] + - artifact: chunk-split-devel + include: [] + ''', + 'stratum.morph': ''' + name: stratum + kind: stratum + chunks: + - name: chunk + repo: test:repo + ref: sha1 + build-mode: bootstrap + build-depends: [] + ''', + 'stratum-no-chunk-bdeps.morph': ''' + name: stratum-no-chunk-bdeps + kind: stratum + chunks: + - name: chunk + repo: test:repo + ref: sha1 + build-mode: bootstrap + ''', + 'stratum-no-bdeps-no-bootstrap.morph': ''' + name: stratum-no-bdeps-no-bootstrap + kind: stratum + chunks: + - name: chunk + repo: test:repo + ref: sha1 + build-depends: [] + ''', + 'stratum-bdeps-no-bootstrap.morph': ''' + name: stratum-bdeps-no-bootstrap + kind: stratum + build-depends: + - morph: stratum + chunks: + - name: chunk + repo: test:repo + ref: sha1 + build-depends: [] + ''', + 'stratum-empty.morph': ''' + name: stratum-empty + kind: stratum + ''', + 'system.morph': ''' + name: system + kind: system + arch: %(arch)s + strata: + - morph: stratum + ''', + 'parse-error.morph': ''' name''', + 'name-mismatch.morph': ''' + name: fred + kind: stratum + ''', } def __init__(self): @@ -313,13 +294,13 @@ class MorphologyFactoryTests(unittest.TestCase): 'reponame', 'sha1', 'parse-error.morph') def test_fails_on_no_chunk_bdeps(self): - self.assertRaises(morphlib.morphologyfactory.NoChunkBuildDependsError, + self.assertRaises(morphlib.morphloader.NoBuildDependenciesError, self.mf.get_morphology, 'reponame', 'sha1', 'stratum-no-chunk-bdeps.morph') def test_fails_on_no_bdeps_or_bootstrap(self): self.assertRaises( - morphlib.morphologyfactory.NoStratumBuildDependsError, + morphlib.morphloader.NoStratumBuildDependenciesError, self.mf.get_morphology, 'reponame', 'sha1', 'stratum-no-bdeps-no-bootstrap.morph') @@ -330,6 +311,6 @@ class MorphologyFactoryTests(unittest.TestCase): def test_fails_on_empty_stratum(self): self.assertRaises( - morphlib.morphologyfactory.EmptyStratumError, + morphlib.morphloader.EmptyStratumError, self.mf.get_morphology, 'reponame', 'sha1', 'stratum-empty.morph') |