summaryrefslogtreecommitdiff
path: root/morphlib/blobs_tests.py
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-01-31 16:38:18 +0000
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-01-31 16:42:41 +0000
commitc2104eb199916f9ef7e7b77d0eebf33619ed3ea9 (patch)
tree01eb904eda1461bf70ecf97aa8f6445d0bbfbb07 /morphlib/blobs_tests.py
parentab965be42d10f2608dc883ee0cc34a1cd0fe5058 (diff)
downloadmorph-c2104eb199916f9ef7e7b77d0eebf33619ed3ea9.tar.gz
Properly unpack dependencies into the staging area in build-single.
This requires build-single to take a dependency context tuple when building chunks of a stratum. This context tuple is the surrounding stratum which is used to construct the dependency graph in the worker and then do a breadth-first search to collect all dependencies that need to be added to the staging area. Implementing this required a few hash/eq changes in Blob, Morphology and Treeish as well as a few adjustments in the corresponding unit tests.
Diffstat (limited to 'morphlib/blobs_tests.py')
-rw-r--r--morphlib/blobs_tests.py42
1 files changed, 28 insertions, 14 deletions
diff --git a/morphlib/blobs_tests.py b/morphlib/blobs_tests.py
index f92658ee..b1062459 100644
--- a/morphlib/blobs_tests.py
+++ b/morphlib/blobs_tests.py
@@ -19,25 +19,27 @@ import unittest
import morphlib
+class FakeChunkMorph(object):
+ @property
+ def kind(self):
+ return 'chunk'
+
+
+class FakeStratumMorph(object):
+ @property
+ def kind(self):
+ return 'stratum'
+
+
class BlobsTests(unittest.TestCase):
def test_create_a_chunk_blob(self):
- class FakeChunkMorph(object):
- @property
- def kind(self):
- return 'chunk'
-
morph = FakeChunkMorph()
chunk = morphlib.blobs.Blob.create_blob(morph)
self.assertTrue(isinstance(chunk, morphlib.blobs.Chunk))
self.assertEqual(morph, chunk.morph)
def test_create_a_stratum_blob(self):
- class FakeStratumMorph(object):
- @property
- def kind(self):
- return 'stratum'
-
morph = FakeStratumMorph()
stratum = morphlib.blobs.Blob.create_blob(morph)
self.assertTrue(isinstance(stratum, morphlib.blobs.Stratum))
@@ -68,9 +70,9 @@ class BlobsTests(unittest.TestCase):
self.assertRaises(TypeError, morphlib.blobs.Blob.create_blob, morph)
def test_blob_with_parents(self):
- blob1 = morphlib.blobs.Blob(None)
- blob2 = morphlib.blobs.Blob(None)
- blob3 = morphlib.blobs.Blob(None)
+ blob1 = morphlib.blobs.Blob(FakeChunkMorph())
+ blob2 = morphlib.blobs.Blob(FakeStratumMorph())
+ blob3 = morphlib.blobs.Blob(FakeStratumMorph())
self.assertEqual(len(blob1.parents), 0)
@@ -105,7 +107,7 @@ class BlobsTests(unittest.TestCase):
self.assertTrue(blob2 in blob1.dependencies)
self.assertTrue(blob1 in blob2.dependents)
-
+
self.assertTrue(blob1.depends_on(blob2))
blob2.add_dependency(blob1)
@@ -138,6 +140,18 @@ class BlobsTests(unittest.TestCase):
self.assertFalse(blob1.depends_on(blob2))
self.assertFalse(blob2.depends_on(blob1))
+ def test_hashing_and_equality_checks(self):
+ morph = FakeChunkMorph()
+ blob1 = morphlib.blobs.Blob.create_blob(morph)
+ blob2 = morphlib.blobs.Blob.create_blob(morph)
+ blob3 = morphlib.blobs.Blob.create_blob(FakeChunkMorph())
+
+ self.assertEqual(hash(blob1), hash(blob2))
+ self.assertEqual(blob1, blob2)
+
+ self.assertNotEqual(hash(blob1), hash(blob3))
+ self.assertNotEqual(blob1, blob3)
+
def test_chunks(self):
settings = { 'git-base-url': [] }
loader = morphlib.morphologyloader.MorphologyLoader(settings)