From 2a071ef057c953e81e1b8bd9b714373b4dbb26c2 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Tue, 28 Aug 2012 17:20:04 +0100 Subject: Strata should be referred to with full repo/ref/morph triplets This removes the requirement that all strata must be in the same repo as the system morphology. Both the system "strata" field and the stratum "build-depends" field are affected. --- morphlib/artifactresolver_tests.py | 63 +++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 21 deletions(-) (limited to 'morphlib/artifactresolver_tests.py') diff --git a/morphlib/artifactresolver_tests.py b/morphlib/artifactresolver_tests.py index 952ffd85..65a9be7d 100644 --- a/morphlib/artifactresolver_tests.py +++ b/morphlib/artifactresolver_tests.py @@ -51,19 +51,26 @@ class FakeChunkMorphology(morphlib.morph2.Morphology): class FakeStratumMorphology(morphlib.morph2.Morphology): - def __init__(self, name, source_list=[], build_depends=[]): - assert(isinstance(source_list, list)) - assert(isinstance(build_depends, list)) - - if source_list: - chunks = [] - for source_name, morph, repo, ref in source_list: - chunks.append({ - 'name': source_name, - 'morph': morph, - 'repo': repo, - 'ref': ref - }) + def __init__(self, name, chunks_list=[], build_depends_list=[]): + assert(isinstance(chunks_list, list)) + assert(isinstance(build_depends_list, list)) + + chunks = [] + for source_name, morph, repo, ref in chunks_list: + chunks.append({ + 'name': source_name, + 'morph': morph, + 'repo': repo, + 'ref': ref + }) + build_depends = [] + for morph, repo, ref in build_depends_list: + build_depends.append({ + 'morph': morph, + 'repo': repo, + 'ref': ref + }) + if chunks: text = (''' { "name": "%s", @@ -367,7 +374,8 @@ class ArtifactResolverTests(unittest.TestCase): 'repo', 'ref', 'sha1', morph, 'stratum1.morph') pool.add(stratum1) - morph = FakeStratumMorphology('stratum2', [], ['stratum1']) + morph = FakeStratumMorphology( + 'stratum2', [], [('stratum1', 'repo', 'ref')]) stratum2 = morphlib.source.Source( 'repo', 'ref', 'sha1', morph, 'stratum2.morph') pool.add(stratum2) @@ -398,7 +406,9 @@ class ArtifactResolverTests(unittest.TestCase): 'stratum2', [ ('chunk1', 'chunk1', 'repo', 'original/ref'), ('chunk2', 'chunk2', 'repo', 'original/ref') - ], ['stratum1']) + ], [ + ('stratum1', 'repo', 'original/ref') + ]) stratum2 = morphlib.source.Source( 'repo', 'original/ref', 'sha1', morph, 'stratum2.morph') pool.add(stratum2) @@ -454,8 +464,16 @@ class ArtifactResolverTests(unittest.TestCase): "name": "system", "kind": "system", "strata": [ - "stratum1", - "stratum2" + { + "repo": "repo", + "ref": "ref", + "morph": "stratum1" + }, + { + "repo": "repo", + "ref": "ref", + "morph": "stratum2" + } ] } ''') @@ -464,7 +482,8 @@ class ArtifactResolverTests(unittest.TestCase): 'repo', 'ref', 'sha1', morph, 'system.morph') pool.add(system) - morph = FakeStratumMorphology('stratum2', [], ['stratum1']) + morph = FakeStratumMorphology( + 'stratum2', [], [('stratum1', 'repo', 'ref')]) stratum2 = morphlib.source.Source( 'repo', 'ref', 'sha1', morph, 'stratum2.morph') pool.add(stratum2) @@ -592,12 +611,14 @@ class ArtifactResolverTests(unittest.TestCase): def test_detection_of_mutual_dependency_between_two_strata(self): pool = morphlib.sourcepool.SourcePool() - morph = FakeStratumMorphology('stratum1', [], ['stratum2']) + morph = FakeStratumMorphology( + 'stratum1', [], [('stratum2', 'repo', 'original/ref')]) stratum1 = morphlib.source.Source( 'repo', 'original/ref', 'sha1', morph, 'stratum1.morph') pool.add(stratum1) - morph = FakeStratumMorphology('stratum2', [], ['stratum1']) + morph = FakeStratumMorphology( + 'stratum2', [], [('stratum1', 'repo', 'original/ref')]) stratum2 = morphlib.source.Source( 'repo', 'original/ref', 'sha1', morph, 'stratum2.morph') pool.add(stratum2) @@ -621,7 +642,7 @@ class ArtifactResolverTests(unittest.TestCase): 'stratum2', [ ('chunk2', 'chunk2', 'repo', 'original/ref'), ('chunk1', 'chunk1', 'repo', 'original/ref') - ], ['stratum1']) + ], [('stratum1', 'repo', 'original/ref')]) stratum2 = morphlib.source.Source( 'repo', 'original/ref', 'sha1', morph, 'stratum2.morph') pool.add(stratum2) -- cgit v1.2.1