diff options
author | Lars Wirzenius <liw@liw.fi> | 2011-09-29 11:59:59 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2011-09-29 11:59:59 +0100 |
commit | 036533d4c0ed3549b3b34af052709c840603ea9a (patch) | |
tree | ff29cd7b5024e7f20cd21227c182bdc76fa9744a /morphlib | |
parent | 8e76dabb40404874560b1f32a32b22e41d156598 (diff) | |
download | morph-036533d4c0ed3549b3b34af052709c840603ea9a.tar.gz |
Remove "source" field from chunk morphologies.
Diffstat (limited to 'morphlib')
-rw-r--r-- | morphlib/morphology.py | 40 | ||||
-rw-r--r-- | morphlib/morphology_tests.py | 53 |
2 files changed, 1 insertions, 92 deletions
diff --git a/morphlib/morphology.py b/morphlib/morphology.py index d31a000c..86658fb8 100644 --- a/morphlib/morphology.py +++ b/morphlib/morphology.py @@ -47,7 +47,6 @@ class Morphology(object): if self.kind == 'chunk': self._validate_chunk() - self.source['repo'] = self._join_with_baseurl(self.source['repo']) elif self.kind == 'stratum': self._validate_stratum() for source in self.sources.itervalues(): @@ -59,35 +58,10 @@ class Morphology(object): self.filename = self._fp.name def _validate_chunk(self): - valid_toplevel_keys = ['name', 'kind', 'source', 'configure-commands', + valid_toplevel_keys = ['name', 'kind', 'configure-commands', 'build-commands', 'test-commands', 'install-commands'] - if 'source' not in self._dict: - raise self._error('chunks must have "source" field') - - if type(self.source) != dict: - raise self._error('"source" must be a dictionary') - - if len(self.source) == 0: - raise self._error('"source" must not be empty') - - if 'repo' not in self.source: - raise self._error('"source" must contain "repo"') - - if not self.source['repo']: - raise self._error('"source" must contain non-empty "repo"') - - if 'ref' not in self.source: - raise self._error('"source" must contain "ref"') - - if not self.source['ref']: - raise self._error('"source" must contain non-empty "ref"') - - for key in self.source.keys(): - if key not in ('repo', 'ref'): - raise self._error('unknown key "%s" in "source"' % key) - cmdlists = [ (self.configure_commands, 'configure-commands'), (self.build_commands, 'build-commands'), @@ -149,10 +123,6 @@ class Morphology(object): return self._dict['kind'] @property - def source(self): - return self._dict['source'] - - @property def sources(self): return self._dict['sources'] @@ -172,14 +142,6 @@ class Morphology(object): def install_commands(self): return self._dict.get('install-commands', []) - @property - def manifest(self): - if self.kind == 'chunk': - return [(self.source['repo'], self.source['ref'])] - else: - return [(source['repo'], source['ref']) - for source in self.sources.itervalues()] - def _join_with_baseurl(self, url): is_relative = (':' not in url or '/' not in url or diff --git a/morphlib/morphology_tests.py b/morphlib/morphology_tests.py index 7a38bff4..d7e256dd 100644 --- a/morphlib/morphology_tests.py +++ b/morphlib/morphology_tests.py @@ -59,9 +59,6 @@ class MorphologyTests(unittest.TestCase): def test_raises_exception_for_kind_that_has_unknown_kind(self): self.assertRaisesSchemaError({ 'name': 'hello', 'kind': 'x' }) - def test_raises_exception_for_chunk_without_source(self): - self.assertRaisesSchemaError({ 'name': 'hello', 'kind': 'chunk' }) - def test_raises_exception_for_chunk_with_nondict_source(self): self.assertRaisesSchemaError({ 'name': 'hello', @@ -230,11 +227,6 @@ class MorphologyTests(unittest.TestCase): { "name": "hello", "kind": "chunk", - "source": - { - "repo": "foo", - "ref": "ref" - }, "configure-commands": ["./configure"], "build-commands": ["make"], "test-commands": ["make check"], @@ -383,43 +375,6 @@ class MorphologyTests(unittest.TestCase): self.assertEqual(morph.filename, 'mockfile') -class ChunkRepoTests(unittest.TestCase): - - def chunk(self, repo): - return morphlib.morphology.Morphology( - MockFile(''' - { - "name": "hello", - "kind": "chunk", - "source": - { - "repo": "%s", - "ref": "HEAD" - }, - "configure-commands": ["./configure"], - "build-commands": ["make"], - "test-commands": ["make check"], - "install-commands": ["make install"] - }''' % repo), - baseurl='git://git.baserock.org/') - - def test_returns_repo_with_schema_as_is(self): - self.assertEqual(self.chunk('git://git.baserock.org/foo/').manifest, - [('git://git.baserock.org/foo/', 'HEAD')]) - - def test_prepends_baseurl_to_repo_without_schema(self): - self.assertEqual(self.chunk('foo').manifest, - [('git://git.baserock.org/foo/', 'HEAD')]) - - def test_leaves_absolute_repo_in_source_dict_as_is(self): - chunk = self.chunk('git://git.baserock.org/foo/') - self.assertEqual(chunk.source['repo'], 'git://git.baserock.org/foo/') - - def test_makes_relative_repo_url_absolute_in_source_dict(self): - chunk = self.chunk('foo') - self.assertEqual(chunk.source['repo'], 'git://git.baserock.org/foo/') - - class StratumRepoTests(unittest.TestCase): def stratum(self, repo): @@ -438,14 +393,6 @@ class StratumRepoTests(unittest.TestCase): }''' % repo), baseurl='git://git.baserock.org/') - def test_returns_repo_with_schema_as_is(self): - self.assertEqual(self.stratum('git://git.baserock.org/foo/').manifest, - [('git://git.baserock.org/foo/', 'HEAD')]) - - def test_prepends_baseurl_to_repo_without_schema(self): - self.assertEqual(self.stratum('foo').manifest, - [('git://git.baserock.org/foo/', 'HEAD')]) - def test_leaves_absolute_repo_in_source_dict_as_is(self): stratum = self.stratum('git://git.baserock.org/foo/') self.assertEqual(stratum.sources['foo']['repo'], |