Extend unittest for gnt-os info changes
authorDimitris Bliablias <bl.dimitris@gmail.com>
Fri, 7 Mar 2014 11:44:10 +0000 (13:44 +0200)
committerMichele Tartara <mtartara@google.com>
Fri, 21 Mar 2014 10:22:35 +0000 (10:22 +0000)
Extend unit test ganeti.query_unittest.py, to correspond to the
changes made in the 'gnt-os info' output.

Signed-off-by: Dimitris Bliablias <bl.dimitris@gmail.com>
Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>

test/py/ganeti.query_unittest.py

index cdbfd95..22cdc89 100755 (executable)
@@ -1151,6 +1151,25 @@ class TestOsQuery(unittest.TestCase):
     variants = ["v00", "plain", "v3", "var0", "v33", "v20"]
     api_versions = [10, 0, 15, 5]
     parameters = ["zpar3", "apar9"]
+    os_hvps = {
+      "os+variant1": {
+        "kvm": {
+          "acpi": False,
+          "migration_downtime": 35,}
+        },
+      "os+variant2": {
+        "xen": {
+          "acpi": "noirq",
+          "console": "com1",}
+        },
+      }
+    osparameters = {
+      "os+variant3": {
+        "img_id": "Debian",
+        "img_passwd": "1234",
+        "img_format": "diskdump",
+        },
+      }
 
     assert variants != sorted(variants) and variants != utils.NiceSort(variants)
     assert (api_versions != sorted(api_versions) and
@@ -1161,17 +1180,19 @@ class TestOsQuery(unittest.TestCase):
     data = [
       query.OsInfo(name="debian", valid=False, hidden=False, blacklisted=False,
                    variants=set(), api_versions=set(), parameters=set(),
-                   node_status={ "some": "status", }),
+                   node_status={ "some": "status", }, os_hvp={}, osparams={}),
       query.OsInfo(name="dos", valid=True, hidden=False, blacklisted=True,
                    variants=set(variants),
                    api_versions=set(api_versions),
                    parameters=set(parameters),
-                   node_status={ "some": "other", "status": None, }),
+                   node_status={ "some": "other", "status": None, },
+                   os_hvp=os_hvps, osparams=osparameters),
       ]
 
 
     q = self._Create(["name", "valid", "hidden", "blacklisted", "variants",
-                      "api_versions", "parameters", "node_status"])
+                      "api_versions", "parameters", "node_status", "os_hvp",
+                      "osparams"])
     self.assertEqual(q.RequestedData(), set([]))
     self.assertEqual(q.Query(data),
                      [[(constants.RS_NORMAL, "debian"),
@@ -1181,7 +1202,9 @@ class TestOsQuery(unittest.TestCase):
                        (constants.RS_NORMAL, []),
                        (constants.RS_NORMAL, []),
                        (constants.RS_NORMAL, []),
-                       (constants.RS_NORMAL, {"some": "status"})],
+                       (constants.RS_NORMAL, {"some": "status"}),
+                       (constants.RS_NORMAL, {}),
+                       (constants.RS_NORMAL, {})],
                       [(constants.RS_NORMAL, "dos"),
                        (constants.RS_NORMAL, True),
                        (constants.RS_NORMAL, False),
@@ -1191,7 +1214,9 @@ class TestOsQuery(unittest.TestCase):
                        (constants.RS_NORMAL, [0, 5, 10, 15]),
                        (constants.RS_NORMAL, ["apar9", "zpar3"]),
                        (constants.RS_NORMAL,
-                        { "some": "other", "status": None, })
+                        { "some": "other", "status": None, }),
+                       (constants.RS_NORMAL, os_hvps),
+                       (constants.RS_NORMAL, osparameters)
                        ]])