diff options
author | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-01-19 15:32:58 +0000 |
---|---|---|
committer | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-01-20 18:31:51 +0000 |
commit | c73ca82e0c67ba3d05f47f61766f8838d0e9d8d4 (patch) | |
tree | fb3fb2f063af4167da1c287d67e4ae2d818e7748 /morphlib/morphology_tests.py | |
parent | 55751d6de5927c3bbcdd21321f7c3a6655e87a76 (diff) | |
download | morph-c73ca82e0c67ba3d05f47f61766f8838d0e9d8d4.tar.gz |
Port everything to using Treeish objects instead of (repo, ref).
This affects pretty much every part of morph, so this might not be fully
working and stable yet.
This commit also introduces the "update-gits" command that can be used
to update all cached repositories from the list of base URLs. The tree
walk when resolving the Treeish objects in Builder.get_cache_id() is a
bit similar to what we do in BuildDependencyGraph, maybe we can merge
that one day.
Diffstat (limited to 'morphlib/morphology_tests.py')
-rw-r--r-- | morphlib/morphology_tests.py | 82 |
1 files changed, 32 insertions, 50 deletions
diff --git a/morphlib/morphology_tests.py b/morphlib/morphology_tests.py index 2df42315..db771fbb 100644 --- a/morphlib/morphology_tests.py +++ b/morphlib/morphology_tests.py @@ -14,13 +14,17 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -import json import StringIO import unittest import morphlib +class FakeTreeish(object): + + pass + + class MockFile(StringIO.StringIO): def __init__(self, *args, **kwargs): @@ -30,19 +34,31 @@ class MockFile(StringIO.StringIO): class MorphologyTests(unittest.TestCase): + def test_constructor_with_treeish(self): + faketreeish = FakeTreeish() + morph = morphlib.morphology.Morphology( + faketreeish, + MockFile(''' + { + "name": "hello", + "kind": "chunk" + }''')) + self.assertEqual(morph.treeish, faketreeish) + def test_fails_invalid_chunk_morphology(self): def failtest(): - morph = morphlib.morphology.Morphology( - 'repo', 'ref', - MockFile(''' - { - "name": "hello", - }''')) + morphlib.morphology.Morphology( + FakeTreeish(), + MockFile(''' + { + "name": "hello", + }''')) self.assertRaises(ValueError, failtest) def test_accepts_valid_chunk_morphology(self): + faketreeish = FakeTreeish() morph = morphlib.morphology.Morphology( - 'repo', 'ref', + faketreeish, MockFile(''' { "name": "hello", @@ -69,8 +85,7 @@ class MorphologyTests(unittest.TestCase): } }''')) - self.assertEqual(morph.repo, 'repo') - self.assertEqual(morph.ref, 'ref') + self.assertEqual(morph.treeish, faketreeish) self.assertEqual(morph.filename, 'mockfile') self.assertEqual(morph.name, 'hello') self.assertEqual(morph.kind, 'chunk') @@ -92,7 +107,7 @@ class MorphologyTests(unittest.TestCase): def test_build_system_defaults_to_None(self): morph = morphlib.morphology.Morphology( - 'repo', 'ref', + FakeTreeish(), MockFile(''' { "name": "hello", @@ -102,7 +117,7 @@ class MorphologyTests(unittest.TestCase): def test_max_jobs_defaults_to_None(self): morph = morphlib.morphology.Morphology( - 'repo', 'ref', + FakeTreeish(), MockFile(''' { "name": "hello", @@ -112,7 +127,7 @@ class MorphologyTests(unittest.TestCase): def test_accepts_valid_stratum_morphology(self): morph = morphlib.morphology.Morphology( - 'repo', 'ref', + FakeTreeish(), MockFile(''' { "name": "hello", @@ -124,22 +139,21 @@ class MorphologyTests(unittest.TestCase): "ref": "ref" } ] - }'''), - baseurl='git://example.com') + }''')) self.assertEqual(morph.kind, 'stratum') self.assertEqual(morph.filename, 'mockfile') self.assertEqual(morph.sources, [ { u'name': u'foo', - u'repo': u'git://example.com/foo/', - u'ref': u'ref' + u'repo': u'foo', + u'ref': u'ref', }, ]) def test_accepts_valid_system_morphology(self): morph = morphlib.morphology.Morphology( - 'repo', 'ref', + FakeTreeish(), MockFile(''' { "name": "hello", @@ -158,35 +172,3 @@ class MorphologyTests(unittest.TestCase): self.assertEqual(morph.disk_size, '1G') self.assertEqual(morph.strata, ['foo', 'bar']) self.assertEqual(morph.test_stories, ['test-1', 'test-2']) - - -class StratumRepoTests(unittest.TestCase): - - def stratum(self, repo): - return morphlib.morphology.Morphology( - 'repo', 'ref', - MockFile(''' - { - "name": "hello", - "kind": "stratum", - "sources": - [ - { - "name": "foo", - "repo": "%s", - "ref": "HEAD" - } - ] - }''' % repo), - baseurl='git://git.baserock.org/') - - def test_leaves_absolute_repo_in_source_dict_as_is(self): - stratum = self.stratum('git://git.baserock.org/foo/') - self.assertEqual(stratum.sources[0]['repo'], - 'git://git.baserock.org/foo/') - - def test_makes_relative_repo_url_absolute_in_source_dict(self): - stratum = self.stratum('foo') - self.assertEqual(stratum.sources[0]['repo'], - 'git://git.baserock.org/foo/') - |