QA: Make Query tests test for '?' values
[ganeti-local] / qa / qa_utils.py
index bcef97f..b43ef2a 100644 (file)
@@ -514,7 +514,22 @@ def _List(listcmd, fields, names):
                           utils.ShellQuoteArgs(cmd)).splitlines()
 
 
-def GenericQueryTest(cmd, fields, namefield="name", test_unknown=True):
+def _AssertListNoUnknownValues(listcmd, fields):
+  """Assert that the list command does not output unknown values.
+
+  """
+  master = qa_config.GetMasterNode()
+
+  cmd = [listcmd, "list", "--output", ",".join(fields)]
+
+  output = GetCommandOutput(master.primary,
+                            utils.ShellQuoteArgs(cmd)).splitlines()
+  for line in output:
+    AssertNotIn('?', line)
+
+
+def GenericQueryTest(cmd, fields, namefield="name", test_unknown=True,
+                     test_values_unknown=True):
   """Runs a number of tests on query commands.
 
   @param cmd: Command name
@@ -550,6 +565,9 @@ def GenericQueryTest(cmd, fields, namefield="name", test_unknown=True):
     AssertCommand([cmd, "list", "this.name.certainly.does.not.exist"],
                   fail=True)
 
+  if test_values_unknown:
+    _AssertListNoUnknownValues(cmd, fields)
+
   # Check exit code for listing unknown field
   AssertEqual(AssertRedirectedCommand([cmd, "list",
                                        "--output=field/does/not/exist"],