Fix atomic/ostree config validations

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-04-01 07:28:59 +02:00
parent 4ec8ad5de8
commit e5f37016e0
4 changed files with 75 additions and 6 deletions

View File

@ -14,13 +14,13 @@ from ..wrappers import kojiwrapper, iso, lorax
class AtomicInstallerPhase(ConfigGuardedPhase): class AtomicInstallerPhase(ConfigGuardedPhase):
name = 'atomic' name = 'atomic'
config_options = ( config_options = [
{ {
"name": "atomic", "name": "atomic",
"expected_types": [dict], "expected_types": [list],
"optional": True, "optional": True,
} }
) ]
def __init__(self, compose): def __init__(self, compose):
super(AtomicInstallerPhase, self).__init__(compose) super(AtomicInstallerPhase, self).__init__(compose)

View File

@ -13,13 +13,13 @@ from ..wrappers import scm, kojiwrapper
class OSTreePhase(ConfigGuardedPhase): class OSTreePhase(ConfigGuardedPhase):
name = 'ostree' name = 'ostree'
config_options = ( config_options = [
{ {
"name": "ostree", "name": "ostree",
"expected_types": [dict], "expected_types": [list],
"optional": True, "optional": True,
} }
) ]
def __init__(self, compose): def __init__(self, compose):
super(OSTreePhase, self).__init__(compose) super(OSTreePhase, self).__init__(compose)

View File

@ -16,6 +16,46 @@ from pungi.phases import atomic_installer as atomic
class AtomicInstallerPhaseTest(helpers.PungiTestCase): class AtomicInstallerPhaseTest(helpers.PungiTestCase):
def test_validate(self):
compose = helpers.DummyCompose(self.topdir, {
'atomic': [
("^Atomic$", {
"x86_64": {
"source_repo_from": "Everything",
"release": None,
"filename": "%(release_short)s-%(variant)s-%(arch)s-%(version)s-%(compose_date)s.iso",
"installpkgs": ["fedora-productimg-atomic"],
"add_template": ["/spin-kickstarts/atomic-installer/lorax-configure-repo.tmpl"],
"add_template_var": [
"ostree_osname=fedora-atomic",
"ostree_ref=fedora-atomic/Rawhide/x86_64/docker-host",
],
"add_arch_template": ["/spin-kickstarts/atomic-installer/lorax-embed-repo.tmpl"],
"add_arch_template_var": [
"ostree_repo=https://kojipkgs.fedoraproject.org/compose/atomic/Rawhide/",
"ostree_osname=fedora-atomic",
"ostree_ref=fedora-atomic/Rawhide/x86_64/docker-host",
]
}
})
]
})
phase = atomic.AtomicInstallerPhase(compose)
try:
phase.validate()
except:
self.fail('Correct config must validate')
def test_validate_bad_conf(self):
compose = helpers.DummyCompose(self.topdir, {
'atomic': 'yes please'
})
phase = atomic.AtomicInstallerPhase(compose)
with self.assertRaises(ValueError):
phase.validate()
@mock.patch('pungi.phases.atomic_installer.ThreadPool') @mock.patch('pungi.phases.atomic_installer.ThreadPool')
def test_run(self, ThreadPool): def test_run(self, ThreadPool):
cfg = mock.Mock() cfg = mock.Mock()

View File

@ -16,6 +16,35 @@ from pungi.phases import ostree
class OSTreePhaseTest(helpers.PungiTestCase): class OSTreePhaseTest(helpers.PungiTestCase):
def test_validate(self):
compose = helpers.DummyCompose(self.topdir, {
'ostree': [
("^Atomic$", {
"x86_64": {
"treefile": "fedora-atomic-docker-host.json",
"config_url": "https://git.fedorahosted.org/git/fedora-atomic.git",
"source_repo_from": "Everything",
"atomic_repo": "/mnt/koji/compose/atomic/Rawhide/"
}
})
]
})
phase = ostree.OSTreePhase(compose)
try:
phase.validate()
except:
self.fail('Correct config must validate')
def test_validate_bad_conf(self):
compose = helpers.DummyCompose(self.topdir, {
'ostree': 'yes please'
})
phase = ostree.OSTreePhase(compose)
with self.assertRaises(ValueError):
phase.validate()
@mock.patch('pungi.phases.ostree.ThreadPool') @mock.patch('pungi.phases.ostree.ThreadPool')
def test_run(self, ThreadPool): def test_run(self, ThreadPool):
cfg = mock.Mock() cfg = mock.Mock()