From 0710a1529a7af7e33179c71a30d362dd46281d3f Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Fri, 8 Aug 2014 09:58:59 +0000 Subject: unittests: Make the unittests use morphloader This commit removes all use of morph2 from the unittests, replacing it with morphloader/morph3. It also converts the test morphologies to YAML. --- morphlib/cachekeycomputer_tests.py | 118 +++++++++++++++++-------------------- 1 file changed, 55 insertions(+), 63 deletions(-) (limited to 'morphlib/cachekeycomputer_tests.py') diff --git a/morphlib/cachekeycomputer_tests.py b/morphlib/cachekeycomputer_tests.py index 9e18b19d..8558db6d 100644 --- a/morphlib/cachekeycomputer_tests.py +++ b/morphlib/cachekeycomputer_tests.py @@ -32,73 +32,60 @@ class DummyBuildEnvironment: class CacheKeyComputerTests(unittest.TestCase): def setUp(self): + loader = morphlib.morphloader.MorphologyLoader() self.source_pool = morphlib.sourcepool.SourcePool() for name, text in { - 'chunk.morph': '''{ - "name": "chunk", - "kind": "chunk", - "description": "A test chunk" - }''', - 'chunk2.morph': '''{ - "name": "chunk2", - "kind": "chunk", - "description": "A test chunk" - }''', - 'chunk3.morph': '''{ - "name": "chunk3", - "kind": "chunk", - "description": "A test chunk" - }''', - 'stratum.morph': '''{ - "name": "stratum", - "kind": "stratum", - "chunks": [ - { - "name": "chunk", - "repo": "repo", - "ref": "original/ref", - "build-depends": [] - } - ] - }''', - 'stratum2.morph': '''{ - "name": "stratum2", - "kind": "stratum", - "chunks": [ - { - "name": "chunk2", - "repo": "repo", - "ref": "original/ref", - "build-depends": [] - }, - { - "name": "chunk3", - "repo": "repo", - "ref": "original/ref", - "build-depends": [] - } - ] - }''', - 'system.morph': '''{ - "name": "system", - "kind": "system", - "strata": [ - { - "morph": "stratum", - "repo": "repo", - "ref": "original/ref" - }, - { - "morph": "stratum2", - "repo": "repo", - "ref": "original/ref" - } - ] - }''', + 'chunk.morph': ''' + name: chunk + kind: chunk + description: A test chunk + ''', + 'chunk2.morph': ''' + name: chunk2 + kind: chunk + description: A test chunk + ''', + 'chunk3.morph': ''' + name: chunk3 + kind: chunk + description: A test chunk + ''', + 'stratum.morph': ''' + name: stratum + kind: stratum + build-depends: [] + chunks: + - name: chunk + repo: repo + ref: original/ref + build-depends: [] + ''', + 'stratum2.morph': ''' + name: stratum2 + kind: stratum + build-depends: [] + chunks: + - name: chunk2 + repo: repo + ref: original/ref + build-depends: [] + - name: chunk3 + repo: repo + ref: original/ref + build-depends: [] + ''', + 'system.morph': ''' + name: system + kind: system + arch: testarch + strata: + - morph: stratum + - morph: stratum2 + ''', }.iteritems(): source = morphlib.source.Source( 'repo', 'original/ref', 'sha', 'tree', - morphlib.morph2.Morphology(text), name) + loader.load_from_string(text), name) self.source_pool.add(source) # FIXME: This should use MorphologyFactory m = source.morphology @@ -202,7 +189,12 @@ class CacheKeyComputerTests(unittest.TestCase): self.assertEqual(old_sha, new_sha) def test_same_morphology_added_to_source_pool_only_appears_once(self): - m = morphlib.morph2.Morphology('{"name": "chunk", "kind": "chunk"}') + loader = morphlib.morphloader.MorphologyLoader() + m = loader.load_from_string( + ''' + name: chunk + kind: chunk + ''') src = morphlib.source.Source('repo', 'original/ref', 'sha', 'tree', m, 'chunk.morph') sp = morphlib.sourcepool.SourcePool() -- cgit v1.2.1