Example #1
0
    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"] ]))
Example #2
0
    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"] ]))
Example #3
0
    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"] ]))
Example #4
0
    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))
Example #5
0
    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"] ]))
Example #6
0
    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")
Example #7
0
    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")
Example #8
0
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")
Example #9
0
    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
Example #10
0
    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")
Example #11
0
    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")
Example #12
0
    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)
Example #13
0
    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)
Example #14
0
    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()
Example #15
0
    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()
Example #16
0
    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)
Example #17
0
    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"] ]))
Example #18
0
    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"], ]))
Example #19
0
    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"] ]))
Example #20
0
    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"] ]))
Example #21
0
    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"] ]))
Example #22
0
    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" ], ]))
Example #23
0
    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"]]))
Example #24
0
 def __init__(self):
     MemLogStore.__init__(self)
     list.__init__(self)
     self.ldict = None
     self.lis_usable = True
Example #25
0
 def __init__(self, d=None):
     Digraph.__init__(self, d,
                      lambda nname: Requirement(None, nname, None,
                                                None, None))
     MemLogStore.__init__(self)