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_seqence_add_path(self): log_file = os.tempnam(None, "stasis_") case_lib = stasis.TestCaseLibrary(self.cv) params = { "zlmserver": "zlmserver.novell.com", "key": "my_key", "var_zlmserver": "var_zlmserver.novell.com" } for key in self.arg_dict.iterkeys(): params[key] = self.arg_dict[key] sequence_lib = stasis.TestSequenceLibrary(self.cv, self.sv, case_lib) sequence_lib.addConfFile( os.path.expanduser("~/stasis/unittest/add_path.conf")) sequence = sequence_lib.load("seq_add_path_1.xml") log_reporter = stasis.LogTestCaseReporter(3, logfile=log_file) sequence.addReporter(log_reporter) runner = stasis.Runner(sequence, params) runner.run(wait_before_kill=3) begin_count = 0 pass_count = 0 total = 10 fd = open(log_file, 'r') for line in fd.readlines(): if re.search(" BEGIN ", line): begin_count += 1 if re.search(" PASS ", line): pass_count += 1 fd.close() self.assertEqual(pass_count, total) self.assertEqual(begin_count, total)
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_seq_pass_param_fail(self): log_file = os.tempnam(None, "stasis_") print "LOG FILE: %s" % log_file case_lib = stasis.TestCaseLibrary(self.cv) sequence_lib = stasis.TestSequenceLibrary(case_lib) #value = {"string_2":"two", "string_22":"twotwo", "int_22":"22"} series = sequence_lib.load("seq_param_pass.xml") log_reporter = stasis.LogTestCaseReporter(debug=3, logfile=log_file) console_reporter = stasis.ConsoleTestCaseReporter() series.addReporter(log_reporter) series.addReporter(console_reporter) dispatcher = stasis.RunDispatcher(series, self.rr) dispatcher.run() fd = open(log_file, 'r') fail_count = 0 missing_count = 0 lines = fd.readlines() for line in lines: if re.search(" FAIL ", line): fail_count += 1 elif re.search(" missing parameter: ", line): missing_count += 1 self.assertEqual(fail_count, 2) self.assertEqual(missing_count, 2)
def test_report_local_fail(self): if self.port is None: port = 8133 count = 8 server = test_server.TestServer(port, count) thread = threading.Thread(None, server.start_server) thread.start() else: port = self.port log_file = os.tempnam(None, "stasis-") case_lib = stasis.TestCaseLibrary(self.cv) url = stasis.buildUrl("localhost", "user", "pass", "/", "http", port) xml_file = "seq_report_fail.xml" params = {} sequence_lib = stasis.TestSequenceLibrary(case_lib) series = sequence_lib.load(xml_file) log_reporter = stasis.LogTestCaseReporter(3, logfile=log_file) series.addReporter(log_reporter) testopia_reporter = stasis.TestopiaCaseReporter(url) series.addReporter(testopia_reporter) dispatcher = stasis.RunDispatcher(series, self.rr) dispatcher.run() case_fail_count = 0 fail_count = 0 fd = open(log_file, 'r') for line in fd.readlines(): if re.search("CASE_FAIL_", line): case_fail_count += 1 if re.search(" FAIL ", line): fail_count += 1 fd.close() self.assertEqual(fail_count, 2) self.assertEqual(case_fail_count, 4)
def test_run_seq_fail_param(self): log_file = os.tempnam(None, "stasis_") print "LOG FILE: %s" % log_file case_lib = stasis.TestCaseLibrary(self.cv) sequence_lib = stasis.TestSequenceLibrary(case_lib) series = sequence_lib.load("seq_param_fail.xml") log_reporter = stasis.LogTestCaseReporter(debug=3, logfile=log_file) console_reporter = stasis.ConsoleTestCaseReporter() series.addReporter(log_reporter) series.addReporter(console_reporter) #register_roles() dispatcher = stasis.RunDispatcher(series, self.rr, {"string_2":"two",\ "int_2":"2"}) dispatcher.run() #dispatcher.run({"string_2":"two", # "int_2":"2"}) #runner = stasis.Runner(sequence, {"string_2":"two", # "int_2":"2"}) #runner.run() fd = open(log_file, 'r') fail_count = 0 lines = fd.readlines() for line in lines: if re.search(" FAIL ", line): fail_count += 1 continue self.assertEqual(fail_count, 1)
def test_run_sequence(self): log_file = os.tempnam(None, "stasis_") print "LOG FILE: %s" % log_file case_lib = stasis.TestCaseLibrary(self.cv) sequence_lib = stasis.TestSequenceLibrary(case_lib) series = sequence_lib.load("seq_all.xml") log_reporter = stasis.LogTestCaseReporter(debug=2, logfile=log_file) console_reporter = stasis.ConsoleTestCaseReporter() series.addReporter(log_reporter) series.addReporter(console_reporter) dispatcher = stasis.RunDispatcher(series, self.rr) dispatcher.run() fd = open(log_file, 'r') pass_count = 0 fail_count = 0 lines = fd.readlines() for line in lines: if re.search(" PASS ", line): pass_count += 1 continue if re.search(" FAIL ", line): fail_count += 1 self.assertEqual(pass_count, 2) self.assertEqual(fail_count, 2)
def test_add_conf(self): def sub_test_add_conf(sequence_lib): suites = sequence_lib.getSuiteNames() self.assertEqual(suites.count("unittest_add_path_sect"), 1) self.assertEqual(suites.count("unittest_default_1_sect"), 1) sequence = sequence_lib.load("seq_add_path_1.xml") paths = sequence_lib.getPaths() self.assertEqual( paths.count(os.path.expanduser("~/stasis/unittest/add_path")), 1) self.assertEqual( paths.count(os.path.expanduser("~/stasis/unittest")), 1) xml_files = sequence_lib.list() self.assert_(xml_files.count("case_add_path_1a.xml"), 1) self.assert_(xml_files.count("seq_add_path_1.xml"), 1) case_lib = stasis.TestCaseLibrary(self.cv) sequence_lib = stasis.TestSequenceLibrary(self.cv, self.sv, case_lib) sequence_lib.addConfFile( os.path.expanduser("~/stasis/unittest/add_path.conf")) sub_test_add_conf(sequence_lib) sequence_lib = stasis.TestSequenceLibrary( self.cv, self.sv, case_lib, os.path.expanduser("~/stasis/unittest/add_path.conf")) sub_test_add_conf(sequence_lib)
def test_report_local_fail(self): port = 8232 server = test_server.TestServer(port) server.count = 4 server.start() log_file = os.tempnam(None,"stasis-") case_lib = stasis.TestCaseLibrary(self.cv) url = stasis.buildUrl("localhost","user","pass","","http", port) xml_file = os.path.join("testopia_run_files","seq_report_fail.xml") params = {} sequence_lib = stasis.TestSequenceLibrary(self.cv, self.sv, case_lib) sequence = sequence_lib.load(xml_file) log_reporter = stasis.LogTestCaseReporter(2, logfile=log_file) sequence.addReporter(log_reporter) testopia_reporter = stasis.TestopiaCaseReporter(url) sequence.addReporter(testopia_reporter) runner = stasis.Runner(sequence, params) runner.run(wait_before_kill=3) begin_count = 0 pass_count = 0 total = 2 fd = open(log_file, 'r') for line in fd.readlines(): if re.search(" BEGIN ", line): begin_count += 1 if re.search(" ERROR ", line): pass_count += 1 fd.close() self.assertEqual(pass_count, total) self.assertEqual(begin_count, total)
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_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 setUp(self): self.old_path = sys.path self.cv = stasis.XMLValidator(os.path.join(xsd_dir, "test-case.xsd")) self.sv = stasis.XMLValidator( os.path.join(xsd_dir, "test-sequence.xsd")) setup_environment.setup_files() self.env_old_path = setup_environment.setup_path() self.case_lib = stasis.TestCaseLibrary(self.cv)
def test_print_ini_sequence(self): log_file = os.tempnam(None, "stasis_") print "LOG FILE: %s" % log_file case_lib = stasis.TestCaseLibrary(self.cv) sequence_lib = stasis.TestSequenceLibrary(case_lib) series = sequence_lib.load("seq_all.xml") series.printConf()
def test_report_live(self): log_file = os.tempnam(None, "stasis-") case_lib = stasis.TestCaseLibrary(self.cv) if self.case_run_id is None: case_run_id = raw_input("case_run_id: ") else: case_run_id = self.case_run_id if self.url is None: if self.user is None: user = raw_input("Enter testopia user name: ") else: user = self.user if self.password is None: passwd = raw_input("Password for %s: " % user) else: passwd = self.password if self.server is None: server = raw_input("Server: ") else: server = self.server url = stasis.buildUrl(server, user, passwd) else: url = self.url params = {} sequence_lib = stasis.TestSequenceLibrary(case_lib) series = sequence_lib.load(None, case_run_id) log_reporter = stasis.LogTestCaseReporter(3, logfile=log_file) series.addReporter(log_reporter) testopia_reporter = stasis.TestopiaCaseReporter(url) sequence.addReporter(testopia_reporter) dispatcher = stasis.RunDispatcher(series) dispatcher.run() begin_count = 0 pass_count = 0 total = 3 fd = open(log_file, 'r') for line in fd.readlines(): if re.search(" BEGIN ", line): begin_count += 1 if re.search(" PASS ", line): pass_count += 1 fd.close() self.assertEqual(pass_count, total) self.assertEqual(begin_count, total)
def test_xml_case_load_ini(self): def md5sum(file): import md5 fd = open(file) digest = md5.new() buffer = fd.read(4096) while buffer != "": digest.update(buffer) buffer = fd.read(4096) fd.close() return digest.hexdigest() ini_file = os.tempnam(None, "stasis_") print "INI FILE: %s" % ini_file file_name = "case_pass_2.xml" case_lib = stasis.TestCaseLibrary(self.cv) tc = case_lib.load(file_name) name = tc.getName() tc.values = {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'} tc.substitutions = { 'dest1': 'rule1', 'dest2': 'rule2', 'dest3': 'rule3' } fd = open(ini_file, 'w') parser = ConfigParser.SafeConfigParser() tc.addConfSection(parser) parser.write(fd) fd.close() del (parser) tc1 = stasis.TestCase(stasis.EmptySourceHandler(), "Empty") parser = ConfigParser.SafeConfigParser() fd = open(ini_file, 'r') parser.readfp(fd) fd.close() tc1.loadConf(parser) del (parser) parser = ConfigParser.SafeConfigParser() tc1.addConfSection(parser) resave = "%s.resave" % (ini_file) fd = open(resave, 'w') parser.write(fd) fd.close() original = md5sum(ini_file) resave = md5sum(resave) self.assertEqual(original, resave)
def test_run_seqence_local(self): port = 8222 server = test_server.TestServer(port) server.count = 4 server.start() log_file = os.tempnam(None,"stasis-") case_lib = stasis.TestCaseLibrary(self.cv) #url = stasis.buildUrl("localhost","user","pass","","http", port) url = "http://localhost:%s" % (port) status, out = commands.getstatusoutput("%s -u %s -U %s -P %s 32" % ( self.script_name, url, self.username, self.password)) self.assertEqual(status, 0)
def test_sequence_save_ini(self): if self.port is None: port = 8817 count = 12 server = test_server.TestServer(port, count) thread = threading.Thread(None, server.start_server) thread.start() else: port = self.port ini_file = os.tempnam(None, "stasis_") case_lib = stasis.TestCaseLibrary(self.cv) url = stasis.buildUrl("localhost", "user", "pass", "/", "http", port) params = {} sequence_lib = stasis.TestSequenceLibrary(case_lib) series = sequence_lib.load(32, url) print "INI FILE: %s" % ini_file fd = open(ini_file, 'w') parser = ConfigParser.SafeConfigParser() for tc in series: tc.addConfSection(parser) parser.write(fd) fd.close() fd = open(ini_file, 'r') found_file_2 = False found_file_22 = False found_function = False line_count = 0 section_count = 0 lines = fd.readlines() fd.close() for line in lines: line_count += 1 if re.search(' = case_pass_22', line): found_file_22 = True elif re.search(' = case_pass_2', line): found_file_2 = True elif re.search(' = test_case_pass_func', line): found_function = True elif re.search('\[.*/', line): section_count += 1 self.assertEqual(line_count, 108) self.assertEqual(section_count, 9) self.assert_(found_file_2) self.assert_(found_file_22) self.assert_(found_function)
def test_report_live(self): log_file = os.tempnam(None,"stasis-") case_lib = stasis.TestCaseLibrary(self.cv) #uri = os.path.join(os.getcwd(),"testopia") #hostname = "bugzillastage.provo.novell.com" #hostname = "localhost:%s" % self.port if self.case_run_id is None: case_run_id = raw_input("case_run_id: ") else: case_run_id = self.case_run_id if self.user is None: user = raw_input("Password for %s: " % user) else: user = self.passwd if self.password is None: passwd = raw_input("Password for %s: " % user) else: passwd = self.passwd #password = "******" url = stasis.buildUrl("bugzillastage.provo.novell.com", user, passwd) params = {} sequence_lib = stasis.TestopiaSequenceLibrary(self.cv, case_lib, url) sequence = sequence_lib.load(case_run_id) log_reporter = stasis.LogTestCaseReporter(2, logfile=log_file) sequence.addReporter(log_reporter) testopia_reporter = stasis.TestopiaCaseReporter(url) sequence.addReporter(testopia_reporter) runner = stasis.Runner(sequence, params) runner.run(wait_before_kill=3) begin_count = 0 pass_count = 0 total = 2 fd = open(log_file, 'r') for line in fd.readlines(): if re.search(" BEGIN ", line): begin_count += 1 if re.search(" PASS ", line): pass_count += 1 fd.close() self.assertEqual(pass_count, total) self.assertEqual(begin_count, total)
def test_xml_case_save_ini(self): ini_file = os.tempnam(None, "stasis_") print "INI FILE: %s" % ini_file file_name = "case_pass_2.xml" case_lib = stasis.TestCaseLibrary(self.cv) tc = case_lib.load(file_name) tc.values = {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'} tc.substitutions = { 'dest1': 'rule1', 'dest2': 'rule2', 'dest3': 'rule3' } fd = open(ini_file, 'w') parser = ConfigParser.SafeConfigParser() tc.addConfSection(parser) parser.write(fd) fd.close() fd = open(ini_file, 'r') line_count = 0 #found_file = False rule_count = 0 value_count = 0 section_count = 0 lines = fd.readlines() fd.close() for line in lines: line_count += 1 #if re.search("= %s" % (file_name), line): # found_file = True if re.search('value[1,2,3]{1}', line): value_count += 1 elif re.search('rule[1,2,3]{1}', line): rule_count += 1 elif re.search('\[.*/', line): section_count += 1 self.assertEqual(line_count, 42) self.assertEqual(rule_count, 3) self.assertEqual(value_count, 3) self.assertEqual(section_count, 4)
def test_conf_default(self): case_lib = stasis.TestCaseLibrary(self.cv) sequence_lib = stasis.TestSequenceLibrary(self.cv, self.sv, case_lib) #sequence_lib.load( "seq_1.xml" ) sequence_lib.load("seq_all.xml") suites = sequence_lib.getSuiteNames() self.assertEqual(suites.count("stasis_unittest"), 1) self.assertEqual(suites.count("live_integration"), 1) paths = sequence_lib.getPaths() self.assertEqual(paths.count("/tmp"), 1) self.assertEqual(paths.count("/var/tmp"), 1) self.assertEqual(paths.count("/usr/tmp"), 1) self.assertEqual(paths.count(os.getcwd()), 1) self.assertEqual( paths.count(os.path.expanduser("~/stasis/test_run_files")), 1) xml_files = sequence_lib.list() for file in [ "case_1_1a.xml", "case_1_1b.xml", "case_1_2a.xml", "case_1a.xml", "seq_1.xml", "seq_1_2.xml" ]: self.assertEqual(xml_files.count(file), 1)
def test_save_ini_sequence(self): ini_file = os.tempnam(None, "stasis_") print "INI FILE: %s" % ini_file case_lib = stasis.TestCaseLibrary(self.cv) sequence_lib = stasis.TestSequenceLibrary(case_lib) series = sequence_lib.load("seq_all.xml") console_reporter = stasis.ConsoleTestCaseReporter() series.addReporter(console_reporter) dispatcher = stasis.RunDispatcher(series, self.rr) dispatcher.run() fd = open(ini_file, 'w') parser = ConfigParser.SafeConfigParser() for tc in series: tc.addConfSection(parser) parser.write(fd) fd.close() sect_count = 0 #archive_count = 0 fail_count = 0 pass_count = 0 fd = open(ini_file, 'r') lines = fd.readlines() fd.close() for line in lines: if re.search("\+case_.*./default\]", line): sect_count += 1 continue if re.search("^status = FAIL", line): fail_count += 1 if re.search("^status = PASS", line): pass_count += 1 self.assertEqual(sect_count, 4) self.assertEqual(pass_count, 2) self.assertEqual(fail_count, 2)
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)
def test_run_seqence_live(self): log_file = os.tempnam(None,"stasis-") case_lib = stasis.TestCaseLibrary(self.cv) if self.case_run_id is None: case_run_id = raw_input("case_run_id: ") else: case_run_id = self.case_run_id user = "******" if self.password is None: passwd = raw_input("Password for %s: " % user) else: passwd = self.passwd url = stasis.buildUrl("bugzillastage.provo.novell.com", user, passwd) params = {} sequence_lib = stasis.TestopiaSequenceLibrary(self.cv, case_lib, url) sequence = sequence_lib.load(case_run_id) log_reporter = stasis.LogTestCaseReporter(2, logfile=log_file) sequence.addReporter(log_reporter) runner = stasis.Runner(sequence, params) runner.run(wait_before_kill=3) begin_count = 0 pass_count = 0 total = 2 fd = open(log_file, 'r') for line in fd.readlines(): if re.search(" BEGIN ", line): begin_count += 1 if re.search(" PASS ", line): pass_count += 1 fd.close() self.assertEqual(pass_count, total) self.assertEqual(begin_count, total)
def test_run_seqence_local(self): if self.port is None: port = 8113 count = 12 server = test_server.TestServer(port, count) thread = threading.Thread(None, server.start_server) thread.start() else: port = self.port log_file = os.tempnam(None, "stasis-") print "Log file: %s" % (log_file) case_lib = stasis.TestCaseLibrary(self.cv) url = stasis.buildUrl("localhost", "user", "pass", "/", "http", port) params = {} sequence_lib = stasis.TestSequenceLibrary(case_lib) series = sequence_lib.load(32, url) log_reporter = stasis.LogTestCaseReporter(debug=TestStasisTestopiaLocal.debug, \ logfile=log_file) series.addReporter(log_reporter) dispatcher = stasis.RunDispatcher(series, self.rr) dispatcher.run() case_pass_count = 0 pass_count = 0 total = 3 fd = open(log_file, 'r') for line in fd.readlines(): if re.search("CASE_PASS_", line): case_pass_count += 1 if re.search(" PASS ", line): pass_count += 1 fd.close() self.assertEqual(pass_count, total) self.assertEqual(case_pass_count, total)
def test_seq_run_arg(self): log_file = os.tempnam(None, "stasis_") print "LOG FILE: %s" % log_file case_lib = stasis.TestCaseLibrary(self.cv) sequence_lib = stasis.TestSequenceLibrary(case_lib) series = sequence_lib.load("seq_run_arg.xml") log_reporter = stasis.LogTestCaseReporter(debug=2, logfile=log_file) console_reporter = stasis.ConsoleTestCaseReporter() series.addReporter(log_reporter) series.addReporter(console_reporter) dispatcher = stasis.RunDispatcher(series, self.rr) dispatcher.run() #sequence_lib = stasis.TestSequenceLibrary(self.cv, # self.sv, # case_lib) #sequence = sequence_lib.load("seq_param_arg.xml") #log_reporter = stasis.LogTestCaseReporter(debug=3, logfile=log_file) #console_reporter = stasis.ConsoleTestCaseReporter() #sequence.addReporter(log_reporter) #sequence.addReporter(console_reporter) #register_roles() #runner = stasis.Runner(sequence, {}) #runner.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, 2)