From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
update test_model and test_rest
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
---
tests/test_model.py | 15 +++++++++++++++
tests/test_rest.py | 12 ++++++++++++
2 files changed, 27 insertions(+)
diff --git a/tests/test_model.py b/tests/test_model.py
index 30daafa..d773c00 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -702,10 +702,25 @@ def test_vm_edit(self):
vms = inst.vms_get_list()
self.assertTrue('kimchi-vm1' in vms)
+ # update vm ticket when vm is not running
+ inst.vm_update(u'kimchi-vm1',
+ {"ticket": {"passwd":
"123456"}})
+
inst.vm_start('kimchi-vm1')
rollback.prependDefer(self._rollback_wrapper, inst.vm_poweroff,
'kimchi-vm1')
+ vm_info = inst.vm_lookup(u'kimchi-vm1')
+ self.assertEquals('123456',
vm_info['ticket']["passwd"])
+ self.assertEquals(None, vm_info['ticket']["expire"])
+
+ # update vm ticket when vm is running
+ inst.vm_update(u'kimchi-vm1',
+ {"ticket": {"passwd": "abcdef",
"expire": 20}})
+ vm_info = inst.vm_lookup(u'kimchi-vm1')
+ self.assertEquals('abcdef',
vm_info['ticket']["passwd"])
+ self.assertGreaterEqual(20, vm_info['ticket']['expire'])
+
info = inst.vm_lookup('kimchi-vm1')
self.assertEquals('running', info['state'])
diff --git a/tests/test_rest.py b/tests/test_rest.py
index 54209ef..6f93941 100644
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -218,9 +218,21 @@ def test_edit_vm(self):
resp = self.request('/vms/vm-1', req, 'PUT')
self.assertEquals(200, resp.status)
+ req = json.dumps({"ticket": {'passwd': "abcdef"}})
+ resp = self.request('/vms/vm-1', req, 'PUT')
+ info = json.loads(resp.read())
+ self.assertEquals('abcdef',
info["ticket"]["passwd"])
+ self.assertEquals(None, info["ticket"]["expire"])
+
resp = self.request('/vms/vm-1/poweroff', '{}', 'POST')
self.assertEquals(200, resp.status)
+ req = json.dumps({"ticket": {'passwd': "123456",
"expire": 20}})
+ resp = self.request('/vms/vm-1', req, 'PUT')
+ info = json.loads(resp.read())
+ self.assertEquals('123456',
info["ticket"]["passwd"])
+ self.assertGreaterEqual(20, info["ticket"]["expire"])
+
req = json.dumps({'name': 12})
resp = self.request('/vms/vm-1', req, 'PUT')
self.assertEquals(400, resp.status)
--
1.9.3