summaryrefslogtreecommitdiff
path: root/morphlib/artifactresolver_tests.py
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-07-18 16:34:56 +0100
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-07-18 17:29:59 +0100
commitb068b7fa1331a7c6e2ef0632d9566310bfa58b9d (patch)
treea5ba4624e87860920059cc4a4b931c75a5b5d778 /morphlib/artifactresolver_tests.py
parent0a1c41a539adee00cf4eefa81d4ab8841b65b10f (diff)
downloadmorph-b068b7fa1331a7c6e2ef0632d9566310bfa58b9d.tar.gz
Have MorphologyFactory set Morphology.builds_artifacts
This way we can have one place in the code where we determine what artifacts get built from a specific morphology, rather than spreading the information around the code base. From now on, everything is supposed to use the builds_artifacts attribute to get the list of artifacts. ArtifactResolver has been changed to do that. Some of the tests are now a bit messier, and should really be changed to create Morphology objects using MorphologyFactory, but that's a change for another day.
Diffstat (limited to 'morphlib/artifactresolver_tests.py')
-rw-r--r--morphlib/artifactresolver_tests.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/morphlib/artifactresolver_tests.py b/morphlib/artifactresolver_tests.py
index 5dc7f29a..055343dc 100644
--- a/morphlib/artifactresolver_tests.py
+++ b/morphlib/artifactresolver_tests.py
@@ -37,6 +37,7 @@ class FakeChunkMorphology(morphlib.morph2.Morphology):
"chunks": %s
}
''' % (name, json.dumps(artifacts)))
+ self.builds_artifacts = artifact_names
else:
text = ('''
{
@@ -44,8 +45,9 @@ class FakeChunkMorphology(morphlib.morph2.Morphology):
"kind": "chunk"
}
''' % name)
+ self.builds_artifacts = [name]
morphlib.morph2.Morphology.__init__(self, text)
-
+
class FakeStratumMorphology(morphlib.morph2.Morphology):
@@ -81,6 +83,7 @@ class FakeStratumMorphology(morphlib.morph2.Morphology):
}
''' % (name,
json.dumps(build_depends)))
+ self.builds_artifacts = [name]
morphlib.morph2.Morphology.__init__(self, text)
@@ -136,6 +139,7 @@ class ArtifactResolverTests(unittest.TestCase):
pool.add(source)
artifacts = self.resolver.resolve_artifacts(pool)
+ artifacts.sort(key=lambda a: a.name)
self.assertEqual(len(artifacts), 2)
@@ -159,6 +163,7 @@ class ArtifactResolverTests(unittest.TestCase):
"kind": "stratum"
}
''')
+ morph.builds_artifacts = ['foo']
stratum = morphlib.source.Source(
'repo', 'original/ref', 'sha1', morph, 'foo.morph')
pool.add(stratum)
@@ -180,6 +185,7 @@ class ArtifactResolverTests(unittest.TestCase):
"kind": "system"
}
''')
+ morph.builds_artifacts = ['foo-rootfs']
system = morphlib.source.Source(
'repo', 'original/ref', 'sha1', morph, 'foo.morph')
pool.add(system)
@@ -202,6 +208,7 @@ class ArtifactResolverTests(unittest.TestCase):
"arch": "arm"
}
''')
+ morph.builds_artifacts = ['foo-rootfs', 'foo-kernel']
system = morphlib.source.Source(
'repo', 'original/ref', 'sha1', morph, 'foo.morph')
pool.add(system)
@@ -452,6 +459,7 @@ class ArtifactResolverTests(unittest.TestCase):
]
}
''')
+ morph.builds_artifacts = ['system-rootfs']
system = morphlib.source.Source(
'repo', 'ref', 'sha1', morph, 'system.morph')
pool.add(system)
@@ -514,6 +522,7 @@ class ArtifactResolverTests(unittest.TestCase):
]
}
''')
+ morph.builds_artifacts = ['stratum']
stratum = morphlib.source.Source(
'repo', 'original/ref', 'sha1', morph, 'stratum.morph')
pool.add(stratum)
@@ -660,6 +669,7 @@ class ArtifactResolverTests(unittest.TestCase):
]
}
''')
+ morph.builds_artifacts = ['stratum']
stratum = morphlib.source.Source(
'repo', 'original/ref', 'sha1', morph, 'stratum.morph')
pool.add(stratum)
@@ -708,6 +718,7 @@ class ArtifactResolverTests(unittest.TestCase):
]
}
''')
+ morph.builds_artifacts = ['stratum']
stratum = morphlib.source.Source(
'repo', 'original/ref', 'sha1', morph, 'stratum.morph')
pool.add(stratum)
@@ -743,6 +754,7 @@ class ArtifactResolverTests(unittest.TestCase):
]
}
''')
+ morph.builds_artifacts = ['stratum']
stratum = morphlib.source.Source(
'repo', 'original/ref', 'sha1', morph, 'stratum.morph')
pool.add(stratum)