summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Coldrick <adam.coldrick@codethink.co.uk>2014-07-03 13:45:38 +0000
committerAdam Coldrick <adam.coldrick@codethink.co.uk>2014-07-03 13:45:38 +0000
commitee15b000c64170660a30069c7dbcb1a784af4de5 (patch)
treec508400e694924433ac9215facc2173ddd4b2d71
parent024334ef6ce645a9691d954c1bcbcc37f56ce133 (diff)
downloadmorph-ee15b000c64170660a30069c7dbcb1a784af4de5.tar.gz
Update the unit tests to deal with sources havin two repos
-rw-r--r--morphlib/artifact_tests.py3
-rw-r--r--morphlib/artifactresolver_tests.py75
-rw-r--r--morphlib/cachekeycomputer_tests.py8
-rw-r--r--morphlib/localartifactcache_tests.py3
-rw-r--r--morphlib/remoteartifactcache_tests.py3
-rw-r--r--morphlib/source_tests.py6
6 files changed, 64 insertions, 34 deletions
diff --git a/morphlib/artifact_tests.py b/morphlib/artifact_tests.py
index d4b15cba..9b796849 100644
--- a/morphlib/artifact_tests.py
+++ b/morphlib/artifact_tests.py
@@ -42,7 +42,8 @@ class ArtifactTests(unittest.TestCase):
}
''')
self.source = morphlib.source.Source(
- 'repo', 'ref', 'sha1', 'tree', morph, 'chunk.morph')
+ 'repo', 'ref', 'sha1', 'tree', morph,
+ 'chunk.morph', 'repo', 'ref')
self.artifact_name = 'chunk-runtime'
self.artifact = morphlib.artifact.Artifact(
self.source, self.artifact_name)
diff --git a/morphlib/artifactresolver_tests.py b/morphlib/artifactresolver_tests.py
index 4e57f672..777cf34b 100644
--- a/morphlib/artifactresolver_tests.py
+++ b/morphlib/artifactresolver_tests.py
@@ -110,7 +110,8 @@ class ArtifactResolverTests(unittest.TestCase):
morph = FakeChunkMorphology('chunk')
source = morphlib.source.Source(
- 'repo', 'ref', 'sha1', 'tree', morph, 'chunk.morph')
+ 'repo', 'ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'chunk.morph')
pool.add(source)
artifacts = self.resolver.resolve_artifacts(pool)
@@ -129,7 +130,8 @@ class ArtifactResolverTests(unittest.TestCase):
morph = FakeChunkMorphology('chunk', ['chunk-foobar'])
source = morphlib.source.Source(
- 'repo', 'ref', 'sha1', 'tree', morph, 'chunk.morph')
+ 'repo', 'ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'chunk.morph')
pool.add(source)
artifacts = self.resolver.resolve_artifacts(pool)
@@ -147,7 +149,8 @@ class ArtifactResolverTests(unittest.TestCase):
morph = FakeChunkMorphology('chunk', ['chunk-baz', 'chunk-qux'])
source = morphlib.source.Source(
- 'repo', 'ref', 'sha1', 'tree', morph, 'chunk.morph')
+ 'repo', 'ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'chunk.morph')
pool.add(source)
artifacts = self.resolver.resolve_artifacts(pool)
@@ -167,13 +170,15 @@ class ArtifactResolverTests(unittest.TestCase):
morph = FakeChunkMorphology('chunk')
chunk = morphlib.source.Source(
- 'repo', 'ref', 'sha1', 'tree', morph, 'chunk.morph')
+ 'repo', 'ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'chunk.morph')
pool.add(chunk)
morph = FakeStratumMorphology(
'stratum', chunks=[('chunk', 'chunk', 'repo', 'ref')])
stratum = morphlib.source.Source(
- 'repo', 'ref', 'sha1', 'tree', morph, 'stratum.morph')
+ 'repo', 'ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'stratum.morph')
pool.add(stratum)
artifacts = self.resolver.resolve_artifacts(pool)
@@ -201,13 +206,15 @@ class ArtifactResolverTests(unittest.TestCase):
morph = FakeChunkMorphology('chunk')
chunk = morphlib.source.Source(
- 'repo', 'ref', 'sha1', 'tree', morph, 'chunk.morph')
+ 'repo', 'ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'chunk.morph')
pool.add(chunk)
morph = FakeStratumMorphology(
'stratum', chunks=[('chunk', 'chunk.morph', 'repo', 'ref')])
stratum = morphlib.source.Source(
- 'repo', 'ref', 'sha1', 'tree', morph, 'stratum.morph')
+ 'repo', 'ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'stratum.morph')
pool.add(stratum)
artifacts = self.resolver.resolve_artifacts(pool)
@@ -235,7 +242,8 @@ class ArtifactResolverTests(unittest.TestCase):
morph = FakeChunkMorphology('chunk', ['chunk-foo', 'chunk-bar'])
chunk = morphlib.source.Source(
- 'repo', 'ref', 'sha1', 'tree', morph, 'chunk.morph')
+ 'repo', 'ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'chunk.morph')
pool.add(chunk)
morph = FakeStratumMorphology(
@@ -244,7 +252,8 @@ class ArtifactResolverTests(unittest.TestCase):
('chunk', 'chunk', 'repo', 'ref'),
])
stratum = morphlib.source.Source(
- 'repo', 'ref', 'sha1', 'tree', morph, 'stratum.morph')
+ 'repo', 'ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'stratum.morph')
pool.add(stratum)
artifacts = self.resolver.resolve_artifacts(pool)
@@ -272,14 +281,16 @@ class ArtifactResolverTests(unittest.TestCase):
morph = FakeChunkMorphology('chunk1')
chunk1 = morphlib.source.Source(
- 'repo', 'original/ref', 'sha1', 'tree', morph, 'chunk1.morph')
+ 'repo', 'original/ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'chunk1.morph')
pool.add(chunk1)
morph = FakeStratumMorphology(
'stratum1',
chunks=[('chunk1', 'chunk1', 'repo', 'original/ref')])
stratum1 = morphlib.source.Source(
- 'repo', 'ref', 'sha1', 'tree', morph, 'stratum1.morph')
+ 'repo', 'ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'stratum1.morph')
pool.add(stratum1)
morph = morphlib.morph2.Morphology(
@@ -303,12 +314,14 @@ class ArtifactResolverTests(unittest.TestCase):
''')
morph.builds_artifacts = ['system-rootfs']
system = morphlib.source.Source(
- 'repo', 'ref', 'sha1', 'tree', morph, 'system.morph')
+ 'repo', 'ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'system.morph')
pool.add(system)
morph = FakeChunkMorphology('chunk2')
chunk2 = morphlib.source.Source(
- 'repo', 'original/ref', 'sha1', 'tree', morph, 'chunk2.morph')
+ 'repo', 'original/ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'chunk2.morph')
pool.add(chunk2)
morph = FakeStratumMorphology(
@@ -316,7 +329,8 @@ class ArtifactResolverTests(unittest.TestCase):
chunks=[('chunk2', 'chunk2', 'repo', 'original/ref')],
build_depends=[('stratum1', 'repo', 'ref')])
stratum2 = morphlib.source.Source(
- 'repo', 'ref', 'sha1', 'tree', morph, 'stratum2.morph')
+ 'repo', 'ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'stratum2.morph')
pool.add(stratum2)
artifacts = self.resolver.resolve_artifacts(pool)
@@ -403,22 +417,26 @@ class ArtifactResolverTests(unittest.TestCase):
''')
morph.builds_artifacts = ['stratum']
stratum = morphlib.source.Source(
- 'repo', 'original/ref', 'sha1', 'tree', morph, 'stratum.morph')
+ 'repo', 'original/ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'stratum.morph')
pool.add(stratum)
morph = FakeChunkMorphology('chunk1')
chunk1 = morphlib.source.Source(
- 'repo', 'original/ref', 'sha1', 'tree', morph, 'chunk1.morph')
+ 'repo', 'original/ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'chunk1.morph')
pool.add(chunk1)
morph = FakeChunkMorphology('chunk2')
chunk2 = morphlib.source.Source(
- 'repo', 'original/ref', 'sha1', 'tree', morph, 'chunk2.morph')
+ 'repo', 'original/ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'chunk2.morph')
pool.add(chunk2)
morph = FakeChunkMorphology('chunk3')
chunk3 = morphlib.source.Source(
- 'repo', 'original/ref', 'sha1', 'tree', morph, 'chunk3.morph')
+ 'repo', 'original/ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'chunk3.morph')
pool.add(chunk3)
artifacts = self.resolver.resolve_artifacts(pool)
@@ -459,7 +477,8 @@ class ArtifactResolverTests(unittest.TestCase):
chunks=[],
build_depends=[('stratum2', 'repo', 'original/ref')])
stratum1 = morphlib.source.Source(
- 'repo', 'original/ref', 'sha1', 'tree', morph, 'stratum1.morph')
+ 'repo', 'original/ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'stratum1.morph')
pool.add(stratum1)
morph = FakeStratumMorphology(
@@ -467,7 +486,8 @@ class ArtifactResolverTests(unittest.TestCase):
chunks=[],
build_depends=[('stratum1', 'repo', 'original/ref')])
stratum2 = morphlib.source.Source(
- 'repo', 'original/ref', 'sha1', 'tree', morph, 'stratum2.morph')
+ 'repo', 'original/ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'stratum2.morph')
pool.add(stratum2)
self.assertRaises(morphlib.artifactresolver.MutualDependencyError,
@@ -500,17 +520,20 @@ class ArtifactResolverTests(unittest.TestCase):
''')
morph.builds_artifacts = ['stratum']
stratum = morphlib.source.Source(
- 'repo', 'original/ref', 'sha1', 'tree', morph, 'stratum.morph')
+ 'repo', 'original/ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'stratum.morph')
pool.add(stratum)
morph = FakeChunkMorphology('chunk1')
chunk1 = morphlib.source.Source(
- 'repo', 'original/ref', 'sha1', 'tree', morph, 'chunk1.morph')
+ 'repo', 'original/ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'chunk1.morph')
pool.add(chunk1)
morph = FakeChunkMorphology('chunk2')
chunk2 = morphlib.source.Source(
- 'repo', 'original/ref', 'sha1', 'tree', morph, 'chunk2.morph')
+ 'repo', 'original/ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'chunk2.morph')
pool.add(chunk2)
self.assertRaises(morphlib.artifactresolver.DependencyOrderError,
@@ -536,12 +559,14 @@ class ArtifactResolverTests(unittest.TestCase):
''')
morph.builds_artifacts = ['stratum']
stratum = morphlib.source.Source(
- 'repo', 'original/ref', 'sha1', 'tree', morph, 'stratum.morph')
+ 'repo', 'original/ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'stratum.morph')
pool.add(stratum)
morph = FakeChunkMorphology('chunk')
chunk = morphlib.source.Source(
- 'repo', 'original/ref', 'sha1', 'tree', morph, 'chunk.morph')
+ 'repo', 'original/ref', 'sha1', 'tree', morph,
+ 'repo', 'ref', 'chunk.morph')
pool.add(chunk)
self.assertRaises(morphlib.artifactresolver.DependencyFormatError,
diff --git a/morphlib/cachekeycomputer_tests.py b/morphlib/cachekeycomputer_tests.py
index dd10307f..fb3c2782 100644
--- a/morphlib/cachekeycomputer_tests.py
+++ b/morphlib/cachekeycomputer_tests.py
@@ -95,7 +95,8 @@ class CacheKeyComputerTests(unittest.TestCase):
}.iteritems():
source = morphlib.source.Source(
'repo', 'original/ref', 'sha', 'tree',
- morphlib.morph2.Morphology(text), name)
+ morphlib.morph2.Morphology(text), 'repo',
+ 'original/ref', name)
self.source_pool.add(source)
# FIXME: This should use MorphologyFactory
m = source.morphology
@@ -179,7 +180,8 @@ class CacheKeyComputerTests(unittest.TestCase):
old_artifact = self._find_artifact('system-rootfs')
morphology = old_artifact.source.morphology
new_source = morphlib.source.Source('repo', 'original/ref', 'newsha',
- 'tree', morphology,
+ 'tree', morphology, 'repo',
+ 'original/ref',
old_artifact.source.filename)
sp = morphlib.sourcepool.SourcePool()
for source in self.source_pool:
@@ -201,7 +203,7 @@ class CacheKeyComputerTests(unittest.TestCase):
def test_same_morphology_added_to_source_pool_only_appears_once(self):
m = morphlib.morph2.Morphology('{"name": "chunk", "kind": "chunk"}')
src = morphlib.source.Source('repo', 'original/ref', 'sha', 'tree', m,
- 'chunk.morph')
+ 'repo', 'original/ref', 'chunk.morph')
sp = morphlib.sourcepool.SourcePool()
sp.add(src)
sp.add(src)
diff --git a/morphlib/localartifactcache_tests.py b/morphlib/localartifactcache_tests.py
index f400a645..d02ba3db 100644
--- a/morphlib/localartifactcache_tests.py
+++ b/morphlib/localartifactcache_tests.py
@@ -46,7 +46,8 @@ class LocalArtifactCacheTests(unittest.TestCase):
}
''')
self.source = morphlib.source.Source(
- 'repo', 'ref', 'sha1', 'tree', morph, 'chunk.morph')
+ 'repo', 'ref', 'sha1', 'tree', morph,
+ 'chunk.morph', 'repo', 'ref')
self.runtime_artifact = morphlib.artifact.Artifact(
self.source, 'chunk-runtime')
self.runtime_artifact.cache_key = '0'*64
diff --git a/morphlib/remoteartifactcache_tests.py b/morphlib/remoteartifactcache_tests.py
index d11bf264..ed97ad68 100644
--- a/morphlib/remoteartifactcache_tests.py
+++ b/morphlib/remoteartifactcache_tests.py
@@ -46,7 +46,8 @@ class RemoteArtifactCacheTests(unittest.TestCase):
}
''')
self.source = morphlib.source.Source(
- 'repo', 'ref', 'sha1', 'tree', morph, 'chunk.morph')
+ 'repo', 'ref', 'sha1', 'tree', morph,
+ 'chunk.morph', 'repo', 'ref')
self.runtime_artifact = morphlib.artifact.Artifact(
self.source, 'chunk-runtime')
self.runtime_artifact.cache_key = 'CHUNK-RUNTIME'
diff --git a/morphlib/source_tests.py b/morphlib/source_tests.py
index 6643f0fc..b8b8b8a5 100644
--- a/morphlib/source_tests.py
+++ b/morphlib/source_tests.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012 Codethink Limited
+# Copyright (C) 2012-2014 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -37,10 +37,10 @@ class SourceTests(unittest.TestCase):
self.filename = 'foo.morph'
self.source = morphlib.source.Source(
self.repo_name, self.original_ref, self.sha1, self.tree,
- self.morphology, self.filename)
+ self.morphology, self.repo_name, self.original_ref, self.filename)
self.other = morphlib.source.Source(
self.repo_name, self.original_ref, self.sha1, self.tree,
- self.morphology, self.filename)
+ self.morphology, self.repo_name, self.original_ref, self.filename)
def test_sets_repo_name(self):
self.assertEqual(self.source.repo_name, self.repo_name)