From 6b0703a908e82dddd6c1a0cc8a944ba46ad96657 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Tue, 3 Jul 2012 17:04:09 +0000 Subject: tests: fix up for change in artifact name This fixes references to a system artifact without the -rootfs appended and adds a unit test for resolving an arm system artifact. --- morphlib/artifactresolver_tests.py | 28 ++++++++++++++++++++++++++-- morphlib/cachekeycomputer_tests.py | 8 ++++---- 2 files changed, 30 insertions(+), 6 deletions(-) (limited to 'morphlib') diff --git a/morphlib/artifactresolver_tests.py b/morphlib/artifactresolver_tests.py index 467c882d..5dc7f29a 100644 --- a/morphlib/artifactresolver_tests.py +++ b/morphlib/artifactresolver_tests.py @@ -187,10 +187,34 @@ class ArtifactResolverTests(unittest.TestCase): artifacts = self.resolver.resolve_artifacts(pool) self.assertEqual(artifacts[0].source, system) - self.assertEqual(artifacts[0].name, 'foo') + self.assertEqual(artifacts[0].name, 'foo-rootfs') self.assertEqual(artifacts[0].dependencies, []) self.assertEqual(artifacts[0].dependents, []) + def test_resolve_a_single_empty_arm_system(self): + pool = morphlib.sourcepool.SourcePool() + + morph = morphlib.morph2.Morphology( + ''' + { + "name": "foo", + "kind": "system", + "arch": "arm" + } + ''') + system = morphlib.source.Source( + 'repo', 'original/ref', 'sha1', morph, 'foo.morph') + pool.add(system) + + artifacts = self.resolver.resolve_artifacts(pool) + + self.assertTrue(any((a.source == system and a.name == 'foo-rootfs' and + a.dependencies == [] and a.dependents == []) + for a in artifacts)) + self.assertTrue(any((a.source == system and a.name == 'foo-kernel' and + a.dependencies == [] and a.dependents == []) + for a in artifacts)) + def test_resolve_stratum_and_chunk_with_no_subartifacts(self): pool = morphlib.sourcepool.SourcePool() @@ -447,7 +471,7 @@ class ArtifactResolverTests(unittest.TestCase): self.assertEqual(artifacts[0].dependents, [artifacts[1], artifacts[2]]) self.assertEqual(artifacts[1].source, system) - self.assertEqual(artifacts[1].name, 'system') + self.assertEqual(artifacts[1].name, 'system-rootfs') self.assertEqual(artifacts[1].dependencies, [artifacts[0], artifacts[2]]) self.assertEqual(artifacts[1].dependents, []) diff --git a/morphlib/cachekeycomputer_tests.py b/morphlib/cachekeycomputer_tests.py index 807fbe89..82d3e6e5 100644 --- a/morphlib/cachekeycomputer_tests.py +++ b/morphlib/cachekeycomputer_tests.py @@ -117,7 +117,7 @@ class CacheKeyComputerTests(unittest.TestCase): self.ckc._hash_list = inccount(self.ckc._hash_list, 'list') self.ckc._hash_tuple = inccount(self.ckc._hash_tuple, 'tuple') - artifact = self._find_artifact('system') + artifact = self._find_artifact('system-rootfs') self.ckc.compute_key(artifact) self.assertNotEqual(runcount['thing'], 0) @@ -130,12 +130,12 @@ class CacheKeyComputerTests(unittest.TestCase): return len(s) == 64 and all([c in validchars for c in s]) def test_compute_key_returns_sha256(self): - artifact = self._find_artifact('system') + artifact = self._find_artifact('system-rootfs') self.assertTrue(self._valid_sha256( self.ckc.compute_key(artifact))) def test_different_env_gives_different_key(self): - artifact = self._find_artifact('system') + artifact = self._find_artifact('system-rootfs') oldsha = self.ckc.compute_key(artifact) build_env = DummyBuildEnvironment({ "USER": "foouser", @@ -150,7 +150,7 @@ class CacheKeyComputerTests(unittest.TestCase): self.assertNotEqual(oldsha, ckc.compute_key(artifact)) def test_same_morphology_text_but_changed_sha1_gives_same_cache_key(self): - old_artifact = self._find_artifact('system') + old_artifact = self._find_artifact('system-rootfs') morphology = old_artifact.source.morphology new_source = morphlib.source.Source('repo', 'original/ref', 'newsha', morphology, -- cgit v1.2.1