| |
@@ -8,12 +8,14 @@
|
| |
import mock
|
| |
import json
|
| |
|
| |
+ import copy
|
| |
import os
|
| |
import sys
|
| |
|
| |
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
|
| |
|
| |
from tests import helpers
|
| |
+ from pungi import checks
|
| |
from pungi.phases import osbs
|
| |
|
| |
|
| |
@@ -192,10 +194,28 @@
|
| |
mock.call.koji_proxy.getBuild(54321),
|
| |
mock.call.koji_proxy.listArchives(54321)])
|
| |
|
| |
- def _assertRepoFile(self):
|
| |
- with open(self.topdir + '/work/global/tmp-Server/compose-rpms-1.repo') as f:
|
| |
- lines = f.read().split('\n')
|
| |
- self.assertIn('baseurl=http://root/compose/Server/$baseurl/os', lines)
|
| |
+ def _assertRepoFile(self, variants=None):
|
| |
+ variants = variants or ['Server']
|
| |
+ for variant in variants:
|
| |
+ with open(self.topdir + '/work/global/tmp-%s/compose-rpms-1.repo' % variant) as f:
|
| |
+ lines = f.read().split('\n')
|
| |
+ self.assertIn('baseurl=http://root/compose/%s/$basearch/os' % variant, lines)
|
| |
+
|
| |
+ def _assertConfigCorrect(self, cfg):
|
| |
+ config = copy.deepcopy(self.compose.conf)
|
| |
+ config['osbs'] = {
|
| |
+ '^Server$': cfg
|
| |
+ }
|
| |
+ self.assertEqual(([], []), checks.validate(config))
|
| |
+
|
| |
+ def _assertConfigMissing(self, cfg, key):
|
| |
+ config = copy.deepcopy(self.compose.conf)
|
| |
+ config['osbs'] = {
|
| |
+ '^Server$': cfg
|
| |
+ }
|
| |
+ self.assertEqual(
|
| |
+ (['Failed validation in osbs.^Server$: \'%s\' is a required property' % key], []),
|
| |
+ checks.validate(config))
|
| |
|
| |
@mock.patch('pungi.util.resolve_git_url')
|
| |
@mock.patch('pungi.phases.osbs.kojiwrapper.KojiWrapper')
|
| |
@@ -205,11 +225,13 @@
|
| |
'target': 'f24-docker-candidate',
|
| |
}
|
| |
self._setupMock(KojiWrapper, resolve_git_url)
|
| |
+ self._assertConfigCorrect(cfg)
|
| |
|
| |
self.t.process((self.compose, self.compose.variants['Server'], cfg), 1)
|
| |
|
| |
self._assertCorrectCalls({})
|
| |
self._assertCorrectMetadata()
|
| |
+ self._assertRepoFile()
|
| |
|
| |
@mock.patch('pungi.util.resolve_git_url')
|
| |
@mock.patch('pungi.phases.osbs.kojiwrapper.KojiWrapper')
|
| |
@@ -220,11 +242,13 @@
|
| |
'failable': ['*']
|
| |
}
|
| |
self._setupMock(KojiWrapper, resolve_git_url)
|
| |
+ self._assertConfigCorrect(cfg)
|
| |
|
| |
self.t.process((self.compose, self.compose.variants['Server'], cfg), 1)
|
| |
|
| |
self._assertCorrectCalls({})
|
| |
self._assertCorrectMetadata()
|
| |
+ self._assertRepoFile()
|
| |
|
| |
@mock.patch('pungi.util.resolve_git_url')
|
| |
@mock.patch('pungi.phases.osbs.kojiwrapper.KojiWrapper')
|
| |
@@ -236,39 +260,104 @@
|
| |
'version': '1.0',
|
| |
}
|
| |
self._setupMock(KojiWrapper, resolve_git_url)
|
| |
+ self._assertConfigCorrect(cfg)
|
| |
|
| |
self.t.process((self.compose, self.compose.variants['Server'], cfg), 1)
|
| |
|
| |
self._assertCorrectCalls({'name': 'my-name', 'version': '1.0'})
|
| |
self._assertCorrectMetadata()
|
| |
+ self._assertRepoFile()
|
| |
|
| |
@mock.patch('pungi.util.resolve_git_url')
|
| |
@mock.patch('pungi.phases.osbs.kojiwrapper.KojiWrapper')
|
| |
- def test_run_with_missing_url(self, KojiWrapper, resolve_git_url):
|
| |
+ def test_run_with_extra_repos(self, KojiWrapper, resolve_git_url):
|
| |
cfg = {
|
| |
+ 'url': 'git://example.com/repo?#HEAD',
|
| |
'target': 'f24-docker-candidate',
|
| |
'name': 'my-name',
|
| |
+ 'version': '1.0',
|
| |
+ 'repo': 'http://pkgs.example.com/my.repo',
|
| |
+ 'repo_from': 'Everything',
|
| |
}
|
| |
self._setupMock(KojiWrapper, resolve_git_url)
|
| |
+ self._assertConfigCorrect(cfg)
|
| |
|
| |
- with self.assertRaises(RuntimeError) as ctx:
|
| |
- self.t.process((self.compose, self.compose.variants['Server'], cfg), 1)
|
| |
+ self.t.process((self.compose, self.compose.variants['Server'], cfg), 1)
|
| |
+
|
| |
+ options = {
|
| |
+ 'name': 'my-name',
|
| |
+ 'version': '1.0',
|
| |
+ 'yum_repourls': [
|
| |
+ 'http://root/work/global/tmp-Server/compose-rpms-1.repo',
|
| |
+ 'http://root/work/global/tmp-Everything/compose-rpms-1.repo',
|
| |
+ 'http://pkgs.example.com/my.repo',
|
| |
+ ]
|
| |
+ }
|
| |
+ self._assertCorrectCalls(options)
|
| |
+ self._assertCorrectMetadata()
|
| |
+ self._assertRepoFile(['Server', 'Everything'])
|
| |
+
|
| |
+ @mock.patch('pungi.util.resolve_git_url')
|
| |
+ @mock.patch('pungi.phases.osbs.kojiwrapper.KojiWrapper')
|
| |
+ def test_run_with_extra_repos_in_list(self, KojiWrapper, resolve_git_url):
|
| |
+ cfg = {
|
| |
+ 'url': 'git://example.com/repo?#HEAD',
|
| |
+ 'target': 'f24-docker-candidate',
|
| |
+ 'name': 'my-name',
|
| |
+ 'version': '1.0',
|
| |
+ 'repo': ['http://pkgs.example.com/my.repo'],
|
| |
+ 'repo_from': ['Everything', 'Client'],
|
| |
+ }
|
| |
+ self._assertConfigCorrect(cfg)
|
| |
+ self._setupMock(KojiWrapper, resolve_git_url)
|
| |
|
| |
- self.assertIn("missing config key 'url' for Server", str(ctx.exception))
|
| |
+ self.t.process((self.compose, self.compose.variants['Server'], cfg), 1)
|
| |
+
|
| |
+ options = {
|
| |
+ 'name': 'my-name',
|
| |
+ 'version': '1.0',
|
| |
+ 'yum_repourls': [
|
| |
+ 'http://root/work/global/tmp-Server/compose-rpms-1.repo',
|
| |
+ 'http://root/work/global/tmp-Everything/compose-rpms-1.repo',
|
| |
+ 'http://root/work/global/tmp-Client/compose-rpms-1.repo',
|
| |
+ 'http://pkgs.example.com/my.repo',
|
| |
+ ]
|
| |
+ }
|
| |
+ self._assertCorrectCalls(options)
|
| |
+ self._assertCorrectMetadata()
|
| |
+ self._assertRepoFile(['Server', 'Everything', 'Client'])
|
| |
|
| |
@mock.patch('pungi.util.resolve_git_url')
|
| |
@mock.patch('pungi.phases.osbs.kojiwrapper.KojiWrapper')
|
| |
- def test_run_with_missing_target(self, KojiWrapper, resolve_git_url):
|
| |
+ def test_run_with_extra_repos_missing_variant(self, KojiWrapper, resolve_git_url):
|
| |
cfg = {
|
| |
'url': 'git://example.com/repo?#HEAD',
|
| |
+ 'target': 'f24-docker-candidate',
|
| |
'name': 'my-name',
|
| |
+ 'version': '1.0',
|
| |
+ 'repo_from': 'Gold',
|
| |
}
|
| |
+ self._assertConfigCorrect(cfg)
|
| |
self._setupMock(KojiWrapper, resolve_git_url)
|
| |
|
| |
with self.assertRaises(RuntimeError) as ctx:
|
| |
self.t.process((self.compose, self.compose.variants['Server'], cfg), 1)
|
| |
|
| |
- self.assertIn("missing config key 'target' for Server", str(ctx.exception))
|
| |
+ self.assertIn('no variant Gold', str(ctx.exception))
|
| |
+
|
| |
+ def test_run_with_missing_url(self):
|
| |
+ cfg = {
|
| |
+ 'target': 'f24-docker-candidate',
|
| |
+ 'name': 'my-name',
|
| |
+ }
|
| |
+ self._assertConfigMissing(cfg, 'url')
|
| |
+
|
| |
+ def test_run_with_missing_target(self):
|
| |
+ cfg = {
|
| |
+ 'url': 'git://example.com/repo?#HEAD',
|
| |
+ 'name': 'my-name',
|
| |
+ }
|
| |
+ self._assertConfigMissing(cfg, 'target')
|
| |
|
| |
@mock.patch('pungi.util.resolve_git_url')
|
| |
@mock.patch('pungi.phases.osbs.kojiwrapper.KojiWrapper')
|
| |
@@ -277,6 +366,7 @@
|
| |
'url': 'git://example.com/repo?#HEAD',
|
| |
'target': 'fedora-24-docker-candidate',
|
| |
}
|
| |
+ self._assertConfigCorrect(cfg)
|
| |
self._setupMock(KojiWrapper, resolve_git_url)
|
| |
self.wrapper.watch_task.return_value = 1
|
| |
|
| |
@@ -293,6 +383,7 @@
|
| |
'target': 'fedora-24-docker-candidate',
|
| |
'failable': ['*']
|
| |
}
|
| |
+ self._assertConfigCorrect(cfg)
|
| |
self._setupMock(KojiWrapper, resolve_git_url)
|
| |
self.wrapper.watch_task.return_value = 1
|
| |
|
| |
@@ -306,6 +397,7 @@
|
| |
'target': 'fedora-24-docker-candidate',
|
| |
'scratch': True,
|
| |
}
|
| |
+ self._assertConfigCorrect(cfg)
|
| |
self._setupMock(KojiWrapper, resolve_git_url)
|
| |
|
| |
self.t.process((self.compose, self.compose.variants['Server'], cfg), 1)
|
| |
The same way live_media and image_build accept additional external repos or variants list, there is now a
repo
andrepo_from
configuration key to add these.Additional commits clean up and improve the unit tests a little by validating the configuration and checking the generated
.repo
files.Fixes: #486