From: Nikos Skalkotos <skalk...@grnet.gr>

Add LUInstanceSetParams tests for removing individual public & private
parameters, as well as, for clearing out public & private parameters.

Signed-off-by: Nikos Skalkotos <skalk...@grnet.gr>
Signed-off-by: Yiannis Tsiouris <ts...@grnet.gr>
---
 test/py/cmdlib/instance_unittest.py | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/test/py/cmdlib/instance_unittest.py 
b/test/py/cmdlib/instance_unittest.py
index d725015..3701805 100644
--- a/test/py/cmdlib/instance_unittest.py
+++ b/test/py/cmdlib/instance_unittest.py
@@ -2237,6 +2237,42 @@ class TestLUInstanceSetParams(CmdlibTestCase):
                          })
     self.ExecOpCode(op)
 
+  def testRemoveOsParam(self):
+    os_param = self.os.supported_parameters[0]
+    self.inst.osparams[os_param] = "test_param_val"
+    op = self.CopyOpCode(self.op, remove_osparams=[
+                                    self.os.supported_parameters[0]])
+    self.ExecOpCode(op)
+    self.assertFalse(os_param in self.inst.osparams)
+
+  def testClearOsParams(self):
+    os = self.cfg.CreateOs(supported_parameters=["param1", "param2"])
+    inst = self.cfg.AddNewInstance(osparams={
+                                     os.supported_parameters[0]: "val0",
+                                     os.supported_parameters[1]: "val1"})
+
+    op = self.CopyOpCode(self.op, clear_osparams=True, instance_name=inst.name)
+    self.ExecOpCode(op)
+    self.assertEqual(len(inst.osparams), 0)
+
+  def testRemovePrivateOsParam(self):
+    os_param = self.os.supported_parameters[0]
+    self.inst.osparams_private[os_param] = "test_param_val"
+    op = self.CopyOpCode(self.op, remove_osparams_private=[
+                                    self.os.supported_parameters[0]])
+    self.ExecOpCode(op)
+    self.assertFalse(os_param in self.inst.osparams_private)
+
+  def testClearPrivateOsParams(self):
+    os = self.cfg.CreateOs(supported_parameters=["param1", "param2"])
+    inst = self.cfg.AddNewInstance(osparams={
+                                     os.supported_parameters[0]: "val0",
+                                     os.supported_parameters[1]: "val1"})
+
+    op = self.CopyOpCode(self.op, clear_osparams=True, instance_name=inst.name)
+    self.ExecOpCode(op)
+    self.assertEqual(len(inst.osparams), 0)
+
   def testIncreaseMemoryTooMuch(self):
     op = self.CopyOpCode(self.running_op,
                          beparams={
-- 
2.10.2

Reply via email to