def test_run_xml_case(self): log_file = os.tempnam(None, "stasis_") print "LOG FILE: %s" % log_file case_lib = stasis.TestCaseLibrary(self.cv) tc = case_lib.load("case_pass_2.xml") series = stasis.TestSeries(tc.getName()) series.append(tc) log_reporter = stasis.LogTestCaseReporter(debug=2, logfile=log_file) console_reporter = stasis.ConsoleTestCaseReporter() series.addReporter(log_reporter) series.addReporter(console_reporter) run_dispatch = stasis.RunDispatcher(series, self.rr) run_dispatch.run() fd = open(log_file, 'r') pass_count = 0 lines = fd.readlines() for line in lines: if re.search(" PASS ", line): pass_count += 1 continue self.assertEqual(pass_count, 1)
def test_run_module_archive_case(self): log_file = os.tempnam(None, "stasis_") print "LOG FILE: %s" % log_file case_lib = stasis.TestCaseLibrary(self.cv) tc = case_lib.load("stasis_unittest", "test_case_func_archive") series = stasis.TestSeries(tc.getName()) series.append(tc) log_reporter = stasis.LogTestCaseReporter(debug=3, logfile=log_file) console_reporter = stasis.ConsoleTestCaseReporter() series.addReporter(log_reporter) series.addReporter(console_reporter) run_dispatch = stasis.RunDispatcher(series, self.rr, \ {"archive_file_name":"stasis_unittest+test_case_func_archive.tar.bz2"},\ timeout=60) run_dispatch.run() fd = open(log_file, 'r') pass_count = 0 lines = fd.readlines() for line in lines: if re.search(" PASS ", line): pass_count += 1 continue self.assertEqual(pass_count, 1)
def test_run_python_archive_case(self): log_file = os.tempnam(None, "stasis_") print "LOG FILE: %s" % log_file case_lib = stasis.TestCaseLibrary(self.cv, "stasis_examples") tc = case_lib.load("test_case_setup_python.xml") series = stasis.TestSeries(tc.getName()) series.append(tc) log_reporter = stasis.LogTestCaseReporter(debug=3, logfile=log_file) console_reporter = stasis.ConsoleTestCaseReporter() series.addReporter(log_reporter) series.addReporter(console_reporter) run_dispatch = stasis.RunDispatcher(series, self.rr, \ {"archive_file_name":"archive_setup.tar.gz"}, timeout=60) run_dispatch.run() fd = open(log_file, 'r') found_count = 0 pass_count = 0 lines = fd.readlines() for line in lines: if re.search(" PASS ", line): pass_count += 1 elif re.search("^found ", line): found_count += 1 self.assertEqual(pass_count, 1) self.assertEqual(found_count, 3)
def test_run_module_case(self): log_file = os.tempnam(None, "stasis_") print "LOG FILE: %s" % log_file case_lib = stasis.TestCaseLibrary(self.cv) #tc = case_lib.loadFromModule("stasis_unittest", "test_case_pass_func") tc = case_lib.load("stasis_unittest", "test_case_pass_func") #runner = stasis.Runner(tc, {}) #run_seq = stasis.RunSequence([runner]) #sequence = stasis.TestSequence(tc.getName(), '', run_seq, # tc.getParamList()) series = stasis.TestSeries(tc.getName()) series.append(tc) log_reporter = stasis.LogTestCaseReporter(debug=2, logfile=log_file) console_reporter = stasis.ConsoleTestCaseReporter() series.addReporter(log_reporter) series.addReporter(console_reporter) run_dispatch = stasis.RunDispatcher(series, self.rr) #runner = stasis.Runner(sequence, {}) #runner.run() run_dispatch.run() fd = open(log_file, 'r') pass_count = 0 lines = fd.readlines() for line in lines: if re.search(" PASS ", line): pass_count += 1 continue self.assertEqual(pass_count, 1)
def test_xml_python_types(self): log_file = os.tempnam(None, "stasis_") print "LOG FILE: %s" % log_file case_lib = stasis.TestCaseLibrary(self.cv) tc = case_lib.load("case_types_param_python.xml") series = stasis.TestSeries(tc.getName()) series.append(tc) log_reporter = stasis.LogTestCaseReporter(debug=3, logfile=log_file) console_reporter = stasis.ConsoleTestCaseReporter() series.addReporter(log_reporter) series.addReporter(console_reporter) run_dispatch = stasis.RunDispatcher(series, self.rr, \ {"name":"string","count":5,"queue":['a','b','c']}) run_dispatch.run() fd = open(log_file, 'r') pass_count = 0 fail_count = 0 lines = fd.readlines() for line in lines: if re.search("PASS TYPE ", line): pass_count += 1 continue if re.search("FAIL TYPE ", line): fail_count += 1 continue self.assertEqual(pass_count, 3) self.assertEqual(fail_count, 0)
def test_run_conf_arg_case(self): log_file = os.tempnam(None, "stasis_") print "LOG FILE: %s" % log_file case_lib = stasis.TestCaseLibrary(self.cv) tc = case_lib.load("case_conf_arg.xml") series = stasis.TestSeries(tc.getName()) series.append(tc) log_reporter = stasis.LogTestCaseReporter(debug=3, logfile=log_file) console_reporter = stasis.ConsoleTestCaseReporter() series.addReporter(log_reporter) series.addReporter(console_reporter) run_dispatch = stasis.RunDispatcher(series, self.rr) run_dispatch.run() fd = open(log_file, 'r') pass_count = 0 conf_count = 0 value_count = 0 lines = fd.readlines() for line in lines: if re.search(" PASS ", line): pass_count += 1 elif re.search("^CASE_CONF_ARG", line): conf_count += 1 if re.search(": value [12]", line): value_count += 1 self.assertEqual(tc.values['conf_arg_1'], "value 1") self.assertEqual(tc.values['conf_arg_2'], "value 2") self.assertEqual(tc.getProperty('suite_name'), "stasis_unittest") self.assertEqual(tc.getProperty('version'), '1') self.assertEqual(pass_count, 1) self.assertEqual(value_count, 2) self.assertEqual(conf_count, 3)