Add missing formats to volumeid and image name
Also, when the format uses something unrecognized, die with more descriptive error message. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
9c1418eb0a
commit
195b13d434
5 changed files with 126 additions and 36 deletions
|
|
@ -5,9 +5,12 @@ import mock
|
|||
import os
|
||||
import sys
|
||||
import unittest
|
||||
import tempfile
|
||||
import shutil
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
||||
|
||||
from pungi import compose
|
||||
from pungi import util
|
||||
|
||||
|
||||
|
|
@ -80,5 +83,46 @@ class TestGetVariantData(unittest.TestCase):
|
|||
self.assertItemsEqual(result, [])
|
||||
|
||||
|
||||
class TestVolumeIdGenerator(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp_dir = tempfile.mkdtemp()
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.tmp_dir)
|
||||
|
||||
@mock.patch('pungi.compose.ComposeInfo')
|
||||
def test_get_volid(self, ci):
|
||||
all_keys = [
|
||||
(['arch', 'compose_id', 'date', 'disc_type'], 'x86_64-compose_id-20160107-'),
|
||||
(['label', 'label_major_version', 'release_short', 'respin'], 'RC-1.0-1-rel_short2-2'),
|
||||
(['type', 'type_suffix', 'variant', 'version'], 'nightly-.n-Server-6.0')
|
||||
]
|
||||
for keys, expected in all_keys:
|
||||
format = '-'.join(['%(' + k + ')s' for k in keys])
|
||||
conf = {
|
||||
'release_short': 'rel_short2',
|
||||
'release_version': '6.0',
|
||||
'release_is_layered': False,
|
||||
'image_volid_formats': [format]
|
||||
}
|
||||
variant = mock.Mock(uid='Server', type='variant')
|
||||
ci.return_value.compose.respin = 2
|
||||
ci.return_value.compose.id = 'compose_id'
|
||||
ci.return_value.compose.date = '20160107'
|
||||
ci.return_value.compose.type = 'nightly'
|
||||
ci.return_value.compose.type_suffix = '.n'
|
||||
ci.return_value.compose.label = 'RC-1.0'
|
||||
ci.return_value.compose.label_major_version = '1'
|
||||
|
||||
ci.return_value.release.version = '3.0'
|
||||
ci.return_value.release.short = 'rel_short'
|
||||
|
||||
c = compose.Compose(conf, self.tmp_dir)
|
||||
|
||||
volid = util.get_volid(c, 'x86_64', variant, escape_spaces=False, disc_type=False)
|
||||
|
||||
self.assertEqual(volid, expected)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue