예제 #1
0
    def test_neg_point_to_self(self):
        "'Solved by' points to same requirement"
        mstderr = StringIO.StringIO()
        init_logger(mstderr)

        config = TestConfig()
        reqset = RequirementSet(config)
        req1 = Requirement('''Name: A
Type: master requirement''', 'A', None, None, None)
        reqset.add_node(RequirementDNode(req1))
        req2 = Requirement('''Name: B
Type: requirement
Solved by: B''', 'B', None, None, None)
        reqset.add_node(RequirementDNode(req2))
        config.set_solved_by()
        rdep = RDepSolvedBy(config)
        status = rdep.rewrite(reqset)

        self.assertFalse(status)
        lstderr = hide_lineno(hide_timestamp(mstderr.getvalue()))
        tear_down_log_handler()
        result_expected = "===DATETIMESTAMP===;rmtoo;ERROR;RequirementSet;" \
        "__resolve_solved_by_one_req;===SOURCELINENO===; 75:B:'Solved by' " \
        "points to the requirement itself\n"
        self.assertEquals(result_expected, lstderr)
예제 #2
0
    def rmttest_positive_01(self):
        """Requirement contains a tag where no handler exists"""
        mstderr = StringIO()
        init_logger(mstderr)

        test_config = TestConfig()
        test_config.set_solved_by()
        mods = InputModules(test_config)

        reqs = RequirementSet(None)
        req = Requirement("Hubbel: bubbel", "hubbel", reqs, mods, test_config)
        reqs.add_requirement(req)
        reqs._handle_modules(mods)

        lstderr = hide_volatile(mstderr.getvalue())
        tear_down_log_handler()
        result_expected \
            = ["===DATETIMESTAMP===;rmtoo;ERROR;RequirementSet;"
               "__all_tags_handled;===LINENO===; 57:hubbel:No tag handler "
               "found for "
               "tag(s) '[\"Hubbel\"]' - Hint: typo in tag(s)?",
               "===DATETIMESTAMP===;rmtoo;ERROR;"
               "RequirementSet;_handle_modules;"
               "===LINENO===; 56:There were errors encountered during parsing "
               "and checking - can't continue."]

        lstderr_last_two_lines = lstderr.split("\n")[-3:-1]

        assert result_expected == lstderr_last_two_lines
예제 #3
0
    def rmttest_neg_solved_by_to_nonex_req(self):
        "'Solved by' points to a non existing requirement"
        mstderr = StringIO()
        init_logger(mstderr)

        config = TestConfig()
        reqset = RequirementSet(config)
        req1 = Requirement('''Name: A
Type: master requirement''', 'A', None, None, None)
        reqset.add_requirement(req1)
        req2 = Requirement('''Name: B
Type: requirement
Solved by: C''', 'B', None, None, None)
        reqset.add_requirement(req2)

        config.set_solved_by()
        rdep = RDepSolvedBy(config)
        status = rdep.rewrite(reqset)

        self.assertFalse(status)
        lstderr = hide_volatile(mstderr.getvalue())
        tear_down_log_handler()
        result_expected \
            = "===DATETIMESTAMP===;rmtoo;ERROR;RequirementSet;" \
            "__resolve_solved_by_one_req_deps;===LINENO===; " \
            "74:B:'Solved by' points to a non-existing requirement 'C'\n"
        self.assertEquals(result_expected, lstderr)
    def rmttest_neg_point_to_self(self):
        "'Solved by' points to same requirement"
        mstderr = StringIO()
        init_logger(mstderr)

        config = TestConfig()
        reqset = RequirementSet(config)
        req1 = Requirement('''Name: A
Type: master requirement''', 'A', None, None, None)
        reqset.add_requirement(req1)
        req2 = Requirement('''Name: B
Type: requirement
Solved by: B''', 'B', None, None, None)
        reqset.add_requirement(req2)
        config.set_solved_by()
        rdep = RDepSolvedBy(config)
        status = rdep.rewrite(reqset)

        assert not status
        lstderr = hide_volatile(mstderr.getvalue())
        tear_down_log_handler()
        result_expected \
            = "===DATETIMESTAMP===;rmtoo;ERROR;RequirementSet;" \
            "__resolve_solved_by_one_req_deps;===LINENO===; " \
            "75:B:'Solved by' points to the requirement itself\n"
        assert result_expected == lstderr
예제 #5
0
    def test_neg_point_to_self(self):
        "'Solved by' points to same requirement"
        mstderr = StringIO.StringIO()
        init_logger(mstderr)

        config = TestConfig()
        reqset = RequirementSet(config)
        req1 = Requirement('''Name: A
Type: master requirement''', 'A', None, None, None)
        reqset.add_node(RequirementDNode(req1))
        req2 = Requirement('''Name: B
Type: requirement
Solved by: B''', 'B', None, None, None)
        reqset.add_node(RequirementDNode(req2))
        config.set_solved_by()
        rdep = RDepSolvedBy(config)
        status = rdep.rewrite(reqset)

        self.assertFalse(status)
        lstderr = hide_lineno(hide_timestamp(mstderr.getvalue()))
        tear_down_log_handler()
        result_expected = "===DATETIMESTAMP===;rmtoo;ERROR;RequirementSet;" \
        "__resolve_solved_by_one_req;===SOURCELINENO===; 75:B:'Solved by' " \
        "points to the requirement itself\n"
        self.assertEquals(result_expected, lstderr)
예제 #6
0
    def rmttest_positive_01(self):
        """Requirement contains a tag where no handler exists"""
        mstderr = StringIO()
        init_logger(mstderr)

        test_config = TestConfig()
        test_config.set_solved_by()
        mods = InputModules(test_config)

        reqs = RequirementSet(None)
        req = Requirement("Hubbel: bubbel", "hubbel",
                          reqs, mods, test_config)
        reqs.add_requirement(req)
        reqs._handle_modules(mods)

        lstderr = hide_volatile(mstderr.getvalue())
        tear_down_log_handler()
        result_expected \
            = ["===DATETIMESTAMP===;rmtoo;ERROR;RequirementSet;"
               "__all_tags_handled;===LINENO===; 57:hubbel:No tag handler "
               "found for "
               "tag(s) '[\"Hubbel\"]' - Hint: typo in tag(s)?",
               "===DATETIMESTAMP===;rmtoo;ERROR;"
               "RequirementSet;_handle_modules;"
               "===LINENO===; 56:There were errors encountered during parsing "
               "and checking - can't continue."]

        lstderr_last_two_lines = lstderr.split("\n")[-3:-1]

        assert result_expected == lstderr_last_two_lines
예제 #7
0
    def rmttest_positive_02(self):
        "Requirement contains a tag where no handler exists - multiple tags"
        mstderr = StringIO()
        init_logger(mstderr)

        tc = TestConfig()
        tc.set_solved_by()
        mods = InputModules(tc)

        reqs = RequirementSet(None)
        req = Requirement("Hubbel: bubbel\nSiebel: do", "InvalidTagReq", reqs,
                          mods, tc)
        reqs.add_requirement(req)
        reqs._handle_modules(mods)

        lstderr = hide_volatile(mstderr.getvalue())
        tear_down_log_handler()

        lstderr_last_two_lines = lstderr.split("\n")[-3:-1]

        result0 \
            = re.match(
                "^===DATETIMESTAMP===;rmtoo;ERROR;RequirementSet;"
                "__all_tags_handled;===LINENO===; 57:InvalidTagReq:"
                "No tag handler found "
                "for tag\(s\) '\[.*\]' - Hint: typo in tag\(s\)\?$",
                lstderr_last_two_lines[0])
        result1 \
            = re.match(
                "^===DATETIMESTAMP===;rmtoo;ERROR;RequirementSet;"
                "_handle_modules;"
                "===LINENO===; 56:There were errors encountered "
                "during parsing "
                "and checking - can't continue.$",
                lstderr_last_two_lines[1])

        assert result0
        assert result1
예제 #8
0
    def rmttest_positive_02(self):
        "Requirement contains a tag where no handler exists - multiple tags"
        mstderr = StringIO()
        init_logger(mstderr)

        tc = TestConfig()
        tc.set_solved_by()
        mods = InputModules(tc)

        reqs = RequirementSet(None)
        req = Requirement("Hubbel: bubbel\nSiebel: do", "InvalidTagReq",
                          reqs, mods, tc)
        reqs.add_requirement(req)
        reqs._handle_modules(mods)

        lstderr = hide_volatile(mstderr.getvalue())
        tear_down_log_handler()

        lstderr_last_two_lines = lstderr.split("\n")[-3:-1]

        result0 \
            = re.match(
                r"^===DATETIMESTAMP===;rmtoo;ERROR;RequirementSet;"
                r"__all_tags_handled;===LINENO===; 57:InvalidTagReq:"
                r"No tag handler found "
                r"for tag\(s\) '\[.*\]' - Hint: typo in tag\(s\)\?$",
                lstderr_last_two_lines[0])
        result1 \
            = re.match(
                r"^===DATETIMESTAMP===;rmtoo;ERROR;RequirementSet;"
                "_handle_modules;"
                "===LINENO===; 56:There were errors encountered "
                "during parsing "
                "and checking - can't continue.$",
                lstderr_last_two_lines[1])

        assert result0
        assert result1