diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-07-19 17:14:12 +0100 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-07-19 17:31:19 +0100 |
commit | dfaf624b1fb97c2208bf03b9ff314c5566575e5f (patch) | |
tree | e927fd50ea4e087fbb23b8fac9893b36d6f4d11c /morphlib | |
parent | df8eda23514d8a6490c8a891f7deb5fcb9ad856c (diff) | |
download | morph-dfaf624b1fb97c2208bf03b9ff314c5566575e5f.tar.gz |
Require system-kind on system morphologies
Diffstat (limited to 'morphlib')
-rw-r--r-- | morphlib/morph2.py | 1 | ||||
-rw-r--r-- | morphlib/morphologyfactory.py | 4 | ||||
-rw-r--r-- | morphlib/morphologyfactory_tests.py | 9 |
3 files changed, 14 insertions, 0 deletions
diff --git a/morphlib/morph2.py b/morphlib/morph2.py index 394c27c3..b1c027b9 100644 --- a/morphlib/morph2.py +++ b/morphlib/morph2.py @@ -39,6 +39,7 @@ class Morphology(object): ('build-depends', None), ('build-system', 'manual'), ('arch', None), + ('system-kind', None), ] def __init__(self, text): diff --git a/morphlib/morphologyfactory.py b/morphlib/morphologyfactory.py index 4f9f7522..925829e9 100644 --- a/morphlib/morphologyfactory.py +++ b/morphlib/morphologyfactory.py @@ -107,6 +107,10 @@ class MorphologyFactory(object): '(arch is a mandatory field)' % filename) + if not morphology['system-kind']: + raise morphlib.Error('No system-kind defined in system %s ' + '(it is a mandatory field)' % filename) + name = morphology['name'] if morphology['arch'] == 'arm': morphology.builds_artifacts = [name + '-kernel', name + '-rootfs'] diff --git a/morphlib/morphologyfactory_tests.py b/morphlib/morphologyfactory_tests.py index 91768843..cc45bb21 100644 --- a/morphlib/morphologyfactory_tests.py +++ b/morphlib/morphologyfactory_tests.py @@ -16,6 +16,7 @@ import unittest +import morphlib from morphlib.morph2 import Morphology from morphlib.morphologyfactory import (MorphologyFactory, AutodetectError, @@ -59,17 +60,20 @@ class FakeLocalRepo(object): 'system.morph': '''{ "name": "foo-system", "kind": "system", + "system-kind": "%(system_kind)s", "arch": "%(arch)s" }''', } def __init__(self): self.arch = 'unknown' + self.system_kind = 'unknown' def cat(self, sha1, filename): if filename in self.morphologies: values = { 'arch': self.arch, + 'system_kind': self.system_kind, } return self.morphologies[filename] % values elif filename.endswith('.morph'): @@ -221,3 +225,8 @@ class MorphologyFactoryTests(unittest.TestCase): morph = self.mf.get_morphology('reponame', 'sha1', 'system.morph') self.assertEqual(morph.needs_artifact_metadata_cached, False) + def test_fails_if_system_does_not_define_system_kind(self): + self.lr.system_kind = '' + self.assertRaises(morphlib.Error, self.mf.get_morphology, + 'reponame', 'sha1', 'system.morph') + |