def test_positive_08(self): "MemLogStore: Check error msg - file and line" mls = MemLogStore() mls.error(77, "ErrMsg", "EFile", "ELine") assert(mls == MemLogStore.create_mls( [ [77, LogLevel.error(), "ErrMsg", "EFile", "ELine"] ]))
def test_positive_07(self): "MemLogStore: Check error msg - line - easy cmp" mls = MemLogStore() mls.error(77, "ErrMsg", None, "ELine") assert(mls == MemLogStore.create_mls( [ [77, LogLevel.error(), "ErrMsg", None, "ELine"] ]))
def test_positive_09(self): "MemLogStore: Check debug msg" mls = MemLogStore() mls.debug(77, "DebugMsg", "EFile", "ELine") assert(mls == MemLogStore.create_mls( [ [77, LogLevel.debug(), "DebugMsg", "EFile", "ELine"] ]))
def test_positive_14(self): "MemLogStore: Check to_list - with file and line" mls = MemLogStore() mls.info(77, "InfoMsg", "EFile", "ELine") l = mls.to_list() assert(mls == MemLogStore.create_mls(l))
def test_positive_10(self): "MemLogStore: Check info msg" mls = MemLogStore() mls.info(77, "InfoMsg", "EFile", "ELine") assert(mls == MemLogStore.create_mls( [ [77, LogLevel.info(), "InfoMsg", "EFile", "ELine"] ]))
def test_positive_01(self): "MemLogStore: Check error msg - only message" mls = MemLogStore() mls.error(77, "ErrMsg") sio = StringIO.StringIO() mls.write_log(sio) assert(sio.getvalue() == "+++ Error: 77:ErrMsg\n")
def test_positive_04(self): "MemLogStore: Check error msg - file and line" mls = MemLogStore() mls.error(77, "ErrMsg", "EFile", "ELine") sio = StringIO.StringIO() mls.write_log(sio) assert(sio.getvalue() == "+++ Error: 77:EFile:ELine:ErrMsg\n")
def main(args, mstdout, mstderr): '''Converts the configuration. Reads in the given and (pretty) prints the configuration to mstdout.''' log_store = MemLogStore() config = MainHelper.main_setup_config(args, log_store) log_store.write_log(mstderr) mstdout.write(json.dumps(config.config, sort_keys=True, indent=4)) mstdout.write("\n")
def main_setup(args, mstdout, mstderr): log_store = MemLogStore() config = MainHelper.main_setup_config(args, log_store) moddirs = config.get_value("global.modules.directories") if len(moddirs) != 1: # TODO Handle multiple module directories. assert(False) mods = InputModules(moddirs[0], config) log_store.write_log(mstderr) return config, mods
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, 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, 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 __init__(self, config, input_handler, commit, object_cache, input_mods): '''Constructs a RequirementSet. This does not read everything in: please use the appropriate method to do so.''' tracer.info("called") Digraph.__init__(self) MemLogStore.__init__(self) self.__config = config self.__object_cache = object_cache self.__input_mods = input_mods # TODO: is this the structure that is needed? self.__requirements = {} self.__read_requirements(input_handler, commit)
def test_json_init_add_new_cmd_line_params(self): '''Init Cfg with JSON and adds parameters with command line options''' log_store = MemLogStore() # Create two JSON files. tmpdir = create_tmp_dir() jsonfile1 = os.path.join(tmpdir, "config1.json") jsonfd1 = file(jsonfile1, "w") jsonfd1.write(json.dumps({'k': 2 , 'm': {'n': 5}, 'o': 7})) jsonfd1.close() jsonfile2 = os.path.join(tmpdir, "config2.json") jsonfd2 = file(jsonfile2, "w") jsonfd2.write(json.dumps({'k': 3 , 'm': {'w': 11}, 'p': 9})) jsonfd2.close() config = Cfg.new_by_json_str('{"k": 1, "l": [2, 3], "m": {"n": 4}}'); config.merge_cmd_line_params(['-j', '{"m": {"p": 99}}', '-j', 'file://' + jsonfile1, '-j', '{"m": {"q": 100}}', '-j', 'file://' + jsonfile2]) self.failUnlessEqual(1, config.get_value("k"), "k is not 1") config.evaluate(log_store) self.failUnlessEqual(3, config.get_value("k"), "k is not 3") self.failUnlessEqual(11, config.get_value("m.w")) self.failUnlessEqual(MemLogStore.create_mls([]), log_store)
def DEPRECATED___init__(self, config, name, config_prefix_str, req_input_dir): tracer.info("name [%s] config_prefix [%s] req_input_dir [%s]" % (name, config_prefix_str, req_input_dir)) Digraph.__init__(self) MemLogStore.__init__(self) # The name of the TopicSet. self.name = name # The directory where all topics are stored. self.topic_dir = config.get_value(config_prefix_str + '.directory') # The master (i.e. the initial) topic. self.master_topic = config.get_value(config_prefix_str + '.name') self.config = config self.internal_init_requirements() # TODO: is this needed???? # if all_reqs != None: # self.mReqset = self.reqs_limit(all_reqs) self.output_handlers = [] self.init_output_handler()
def __init__(self, input_mods, config): '''Sets up a TopicContinuum for use.''' tracer.info("called") MemLogStore.__init__(self) self.__input_mods = input_mods self.__config = config # This dictionary holds all the TopicSetCollections # available in the configured time period. self.__continuum = {} # The VCS repository. # If this is None - there is no repository available. self.__deprecated_repo = None # Because the construction / evaluation should continue even in # error cases, a flag is available to check if the (possible only # partially) constructed element is usable. self.__is_usable = True # Store objects with IDs also in the cache - so that they can be reused. self.__object_cache = ObjectCache() self.__init_continuum_set() self.__object_cache.log_stats()
def test_json_init_add_old_cmd_line_params(self): '''Init Cfg with old config and adds parameters with command line options''' log_store = MemLogStore() config = Cfg.new_by_json_str('{"k": 1, "l": [2, 3], "m": {"n": 4}}'); config.merge_cmd_line_params(['-f', 'tests/unit-test/core-tests/' 'testdata/Config3.py']) self.failUnlessEqual(1, config.get_value("k"), "k is not 1") config.evaluate(log_store) self.failUnlessEqual(['development', 'management', 'users', 'customers'], config.get_value("requirements.stakeholders")) print("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU") log_store.write_log(sys.stdout) ## TODO:+ + +Warning:100:Old Configuration: Not converted attributes: [['output_specs2']] print("VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV") self.failUnlessEqual(MemLogStore.create_mls([[ 100, LogLevel.warning(), "Old Configuration: Not converted attributes: [['output_specs2']]"]]), log_store)
def test_positive_05(self): "MemLogStore: Check error msg - only message - easy cmp" mls = MemLogStore() mls.error(77, "ErrMsg") print("1111 [%s]" % mls.to_list()) print("2222 [%s]" % MemLogStore.create_mls( [ [77, LogLevel.error(), "ErrMsg"] ]).to_list()) assert(mls == MemLogStore.create_mls( [ [77, LogLevel.error(), "ErrMsg"] ]))
def test_negative_05(self): "Set without any master requirement" config, reqset = create_parameters() reqset.reqs = { "A": TestReq("A", {"Type": Requirement.rt_requirement}, {"Solved by": RecordEntry("Solved by", "B")}), "B": TestReq("B", {"Type": Requirement.rt_requirement}, {"Solved by": RecordEntry("Solved by", "A")})} config.set_solved_by() rdep = RDepSolvedBy(config) status = rdep.rewrite(reqset) assert(status == False) assert(reqset.mls() == MemLogStore.create_mls( [[78, LogLevel.error(), "no master requirement found"], ]))
def test_negative_01(self): "Two nodes as master requirement" config, reqset = create_parameters() reqset.reqs = { "A": TestReq("A", {"Type": Requirement.rt_master_requirement}, {}), "B": TestReq("B", {"Type": Requirement.rt_master_requirement}, {})} config.set_solved_by() rdep = RDepSolvedBy(config) status = rdep.rewrite(reqset) assert(status == False) assert(reqset.mls() == MemLogStore.create_mls( [ [76, LogLevel.error(), "Another master is already there. " "There can only be one.", "B"] ]))
def test_negative_02(self): "Normal requirement has empty 'Solved by'" config, reqset = create_parameters() reqset.reqs = { "A": TestReq("A", {"Type": Requirement.rt_master_requirement}, {}), "B": TestReq("B", {"Type": Requirement.rt_requirement}, {"Solved by": RecordEntry("Solved by", "")})} config.set_solved_by() rdep = RDepSolvedBy(config) status = rdep.rewrite(reqset) assert(status == False) assert(reqset.mls() == MemLogStore.create_mls( [ [77, LogLevel.error(), "'Solved by' field has len 0", "B"] ]))
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, TestConfig()) reqs = RequirementSet(mods, None) reqs.add_req(req) reqs.handle_modules() assert(reqs.mls() == MemLogStore.create_mls( [[57, LogLevel.error(), "No tag handler found for tag(s) " "'['Hubbel']' - Hint: typo in tag(s)?", 'hubbel'], [56, LogLevel.error(), "There were errors encountered during " "parsing and checking - can't continue"] ]))
def test_negative_04(self): "'Solved by' points to same requirement" config, reqset = create_parameters() reqset.reqs = { "A": TestReq("A", {"Type": Requirement.rt_master_requirement}, {}), "B": TestReq("B", {"Type": Requirement.rt_requirement}, {"Solved by": RecordEntry("Solved by", "B")})} config.set_solved_by() rdep = RDepSolvedBy(config) status = rdep.rewrite(reqset) assert(status == False) assert(reqset.mls() == MemLogStore.create_mls( [[75, LogLevel.error(), "'Solved by' points to the requirement " "itself", "B" ], ]))
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, TestConfig()) reqs = RequirementSet(mods, 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, LogLevel.error(), "No tag handler found for tag(s) " "'['Siebel', 'Hubbel']' - Hint: typo in tag(s)?", 'InvalidTagReq'], [56, LogLevel.error(), "There were errors encountered during " "parsing and checking - can't continue"]]))
def __init__(self): MemLogStore.__init__(self) list.__init__(self) self.ldict = None self.lis_usable = True
def __init__(self, d=None): Digraph.__init__(self, d, lambda nname: Requirement(None, nname, None, None, None)) MemLogStore.__init__(self)