def test_positive_02(self): "Requirement contains a tag where no handler exists - multiple tags" mstderr = StringIO.StringIO() init_logger(mstderr) mods = InputModules(os.path.join(mod_base_dir, "modules08"), {}, [], mods_list("modules08", mod_base_dir)) reqs = RequirementSet(None) req = Requirement("Hubbel: bubbel\nSiebel: do", "InvalidTagReq", reqs, mods, TestConfig()) reqs.add_node(RequirementDNode(req)) reqs._handle_modules(mods) lstderr = hide_timestamp(mstderr.getvalue()) lstderr = hide_lineno(lstderr) tear_down_log_handler() result_expected = "===DATETIMESTAMP===;rmtoo;ERROR;RequirementSet;" \ "__all_tags_handled;===SOURCELINENO===; 57:InvalidTagReq:No tag " \ "handler found " \ "for tag(s) '['Siebel', 'Hubbel']' - Hint: typo in tag(s)?\n" \ "===DATETIMESTAMP===;rmtoo;ERROR;RequirementSet;_handle_modules;" \ "===SOURCELINENO===; 56:There were errors encountered during parsing " \ "and checking " \ "- can't continue.\n" self.assertEquals(result_expected, lstderr)
def test_simple_04(self): "Module test with cyclic dependency " try: mods = Modules(os.path.join(mod_base_dir, "modules04"), {}, {}, [], mods_list("modules04", mod_base_dir)) assert(False) except RMTException, rmte: assert(rmte.id()==26)
def test_simple_03(self): "Module test with invalid dependency " try: mods = InputModules(os.path.join(mod_base_dir, "modules03"), {}, [], mods_list("modules03", mod_base_dir)) assert(False) except RMTException, rmte: assert(rmte.id() == 27)
def test_simple_07(self): "RequirementSet: Module which renders set as errornous" mods = Modules(os.path.join(mod_base_dir, "modules07"), {}, {}, [], mods_list("modules07", mod_base_dir)) reqs = RequirementSet(mods, None, None) reqs.handle_modules() assert(reqs.state==RequirementSet.er_error) sout = StringIO.StringIO() reqs.write_log(sout) assert(sout.getvalue()=="+++ Error: 43:there was a problem handling the requirement set modules\n")
def test_simple_05(self): "Module test with dependend modules" mods = Modules(os.path.join(mod_base_dir, "modules05"), {}, {}, [], mods_list("modules05", mod_base_dir)) sio = StringIO.StringIO("Name: t\n") mls = MemLogStore() req = Requirement(sio, 77, mls, mods, None, TestConfig()) sout = StringIO.StringIO() mls.write_log(sout) assert(req.state==Requirement.er_error) assert(sout.getvalue()== "+++ Error: 54:77:tag 'SameTag' already defined\n")
def test_simple_06(self): "Requirement: Module test with exception thrown" mods = Modules(os.path.join(mod_base_dir, "modules06"), {}, {}, [], mods_list("modules06", mod_base_dir)) sio = StringIO.StringIO("Name: t\n") mls = MemLogStore() req = Requirement(sio, 77, mls, mods, None, TestConfig()) sout = StringIO.StringIO() mls.write_log(sout) assert(req.state==Requirement.er_error) assert(sout.getvalue()== "+++ Error: 55:TCExcept\n" "+++ Error: 41:77:semantic error occured in module 'Module01'\n")
def test_simple_05(self): "Module test with dependent modules" mstderr = StringIO.StringIO() init_logger(mstderr) mods = InputModules(os.path.join(mod_base_dir, "modules05"), {}, [], mods_list("modules05", mod_base_dir)) req = Requirement("Name: t\n", 77, None, mods, TestConfig()) lstderr = hide_lineno(hide_timestamp(mstderr.getvalue())) tear_down_log_handler() self.assertEqual(req.is_usable(), False) expected_result = "===DATETIMESTAMP===;rmtoo;ERROR;BaseRMObject;" \ "handle_modules_tag;===SOURCELINENO===; 54:77:" \ "tag [SameTag] already defined\n" self.assertEqual(lstderr, expected_result)
def test_positive_01(self): "Requirement contains a tag where no handler exists" mods = Modules(os.path.join(mod_base_dir, "modules08"), {}, {}, [], mods_list("modules08", mod_base_dir)) sio = StringIO.StringIO("Hubbel: bubbel") req = Requirement(sio, "hubbel", None, mods, None, TestConfig()) reqs = RequirementSet(mods, None, None) reqs.add_req(req) reqs.handle_modules() assert(reqs.mls()==MemLogStore.create_mls( [[57, MemLog.error, "No tag handler found for tag(s) " "'['Hubbel']' - Hint: typo in tag(s)?", 'hubbel'], [56, MemLog.error, "There were errors encountered during " "parsing and checking - can't continue"] ] ))
def test_simple_06(self): "Requirement: Module test with exception thrown" mstderr = StringIO.StringIO() init_logger(mstderr) mods = InputModules(os.path.join(mod_base_dir, "modules06"), {}, [], mods_list("modules06", mod_base_dir)) req = Requirement("Name: t\n", 77, None, mods, TestConfig()) lstderr = hide_lineno(hide_timestamp(mstderr.getvalue())) tear_down_log_handler() self.assertEqual(req.is_usable(), False) expected_result = "===DATETIMESTAMP===;rmtoo;ERROR;BaseRMObject;" \ "handle_modules_tag;===SOURCELINENO===; 55:TCExcept\n" \ "===DATETIMESTAMP===;rmtoo;ERROR;BaseRMObject;handle_modules_tag;" \ "===SOURCELINENO===; 41:77:" \ "semantic error occurred in module [Module01]\n" self.assertEqual(lstderr, expected_result)
def test_simple_07(self): "RequirementSet: Module which renders set as errornous" mstderr = StringIO.StringIO() init_logger(mstderr) mods = InputModules(os.path.join(mod_base_dir, "modules07"), {}, [], mods_list("modules07", mod_base_dir)) reqs = RequirementSet(None) reqs._handle_modules(mods) self.assertEqual(reqs.is_usable(), False) lstderr = hide_lineno(hide_timestamp(mstderr.getvalue())) tear_down_log_handler() expected_result = "===DATETIMESTAMP===;rmtoo;ERROR;RequirementSet;" \ "_handle_modules;===SOURCELINENO===; 43:there was a problem handling the " \ "requirement set modules\n" self.assertEqual(lstderr, expected_result)
def test_positive_02(self): "Requirement contains a tag where no handler exists - multiple tags" mods = Modules(os.path.join(mod_base_dir, "modules08"), {}, {}, [], mods_list("modules08", mod_base_dir)) sio = StringIO.StringIO("Hubbel: bubbel\nSiebel: do") req = Requirement(sio, "InvalidTagReq", None, mods, None, TestConfig()) reqs = RequirementSet(mods, None, None) reqs.add_req(req) reqs.handle_modules() #o = StringIO.StringIO() #reqs.write_log(o) #print("HHHHHHHHHHH %s" % o.getvalue()) assert(reqs.mls()==MemLogStore.create_mls( [[57, MemLog.error, "No tag handler found for tag(s) " "'['Siebel', 'Hubbel']' - Hint: typo in tag(s)?", 'InvalidTagReq'], [56, MemLog.error, "There were errors encountered during " "parsing and checking - can't continue"]] ))
def test_simple_02(self): "Module test with dependend modules" mods = Modules(os.path.join(mod_base_dir, "modules02"), {}, {}, [], mods_list("modules02", mod_base_dir)) mods_name = node_list_to_node_name_list(mods.reqdeps_sorted) assert(mods_name==['Module01', 'Module02'])
def test_simple_01(self): "Simple module test" mods = Modules(os.path.join(mod_base_dir, "modules01"), {}, {}, [], mods_list("modules01", mod_base_dir))
def test_simple_02(self): "Module test with dependent modules" mods = InputModules(os.path.join(mod_base_dir, "modules02"), {}, [], mods_list("modules02", mod_base_dir)) mods_name = node_list_to_node_name_list(mods.get_reqdeps_sorted()) assert (mods_name == ['Module01', 'Module02'])
def test_simple_01(self): "Simple module test" mods = InputModules(os.path.join(mod_base_dir, "modules01"), {}, [], mods_list("modules01", mod_base_dir))