This patch adds two tests to check if templates are being created with
default disk format value (qcow2) or if the template is being created
correctly with the format value passed.
Template update tests already exist.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo(a)linux.vnet.ibm.com>
---
tests/test_template.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/tests/test_template.py b/tests/test_template.py
index 4446025..23a24fb 100644
--- a/tests/test_template.py
+++ b/tests/test_template.py
@@ -86,6 +86,9 @@ class TemplateTests(unittest.TestCase):
tmpl = json.loads(self.request('/templates/test').read())
self.assertEquals(sorted(tmpl.keys()), sorted(keys))
+ # Verify if default disk format was configured
+ self.assertEquals(tmpl['disks'][0]['format'], 'qcow2')
+
# Clone a template
resp = self.request('/templates/test/clone', '{}',
'POST')
self.assertEquals(303, resp.status)
@@ -113,6 +116,15 @@ class TemplateTests(unittest.TestCase):
self.assertEquals(201, resp.status)
os.remove('/tmp/mock.img')
+ # Test disk format
+ t = {'name': 'test-format', 'cdrom':
'/tmp/mock.iso',
+ 'disks': [{'index': 0, 'size': 10, 'format':
'vmdk'}]}
+ req = json.dumps(t)
+ resp = self.request('/templates', req, 'POST')
+ self.assertEquals(201, resp.status)
+ tmpl = json.loads(self.request('/templates/test-format').read())
+ self.assertEquals(tmpl['disks'][0]['format'], 'vmdk')
+
def test_customized_tmpl(self):
# Create a template
t = {'name': 'test', 'cdrom': '/tmp/mock.iso'}
--
2.1.0