예제 #1
0
    def test_positive_01(self):
        "Two node one edge digraph B -> A"
        config = TestConfig()

        imod = InputModules("..", config)

        reqset = RequirementSet(config)
        req1 = Requirement('''Name: A
Type: master requirement''', 'A', None, imod, config)
        reqset.add_node(RequirementDNode(req1))
        req2 = Requirement('''Name: B
Type: requirement
Depends on: A''', 'B', None, imod, config)
        reqset.add_node(RequirementDNode(req2))
        config.set_depends_on()

        rdep = RDepDependsOn(config)
        rdep.rewrite(reqset)

        assert (reqset.get_requirement("A").get_incoming_as_named_list() == [])
        assert (reqset.get_requirement("A").get_outgoing_as_named_list() == [
            "B"
        ])
        assert (reqset.get_requirement("B").get_incoming_as_named_list() == [
            "A"
        ])
        assert (reqset.get_requirement("B").get_outgoing_as_named_list() == [])
    def rmttest_positive_02(self):
        "Three node one edge digraph B -> A, C -> A and C -> B"
        config = TestConfig()

        imod = InputModules(config)

        reqset = RequirementSet(config)
        req1 = Requirement('''Name: A
Type: master requirement''', 'A', None, imod, config)
        reqset.add_requirement(req1)
        req2 = Requirement('''Name: B
Type: requirement
Depends on: A''', 'B', None, imod, config)
        reqset.add_requirement(req2)
        config.set_depends_on()
        req3 = Requirement('''Name: C
Type: requirement
Depends on: A B''', 'C', None, imod, config)
        reqset.add_requirement(req3)
        config.set_depends_on()

        rdep = RDepDependsOn(config)
        rdep.rewrite(reqset)

        assert [] == reqset.get_requirement("A").incoming_as_named_list()
        # There are two possible valid results
        assert reqset.get_requirement("A").outgoing_as_named_list() \
            in [["C", "B"], ["B", "C"]]
        assert ["A"] == reqset.get_requirement("B").incoming_as_named_list()
        assert ["C"] == reqset.get_requirement("B").outgoing_as_named_list()
        assert ["A",
                "B"] == reqset.get_requirement("C").incoming_as_named_list()
        assert [] == reqset.get_requirement("C").outgoing_as_named_list()
예제 #3
0
    def rmttest_positive_02(self):
        "Three node one edge digraph B -> A, C -> A and C -> B"
        config = TestConfig()

        imod = InputModules(config)

        reqset = RequirementSet(config)
        req1 = Requirement('''Name: A
Type: master requirement''', 'A', None, imod, config)
        reqset.add_requirement(req1)
        req2 = Requirement('''Name: B
Type: requirement
Depends on: A''', 'B', None, imod, config)
        reqset.add_requirement(req2)
        config.set_depends_on()
        req3 = Requirement('''Name: C
Type: requirement
Depends on: A B''', 'C', None, imod, config)
        reqset.add_requirement(req3)
        config.set_depends_on()

        rdep = RDepDependsOn(config)
        rdep.rewrite(reqset)

        assert [] == reqset.get_requirement("A").incoming_as_named_list()
        # There are two possible valid results
        assert reqset.get_requirement("A").outgoing_as_named_list() \
            in [["C", "B"], ["B", "C"]]
        assert ["A"] == reqset.get_requirement("B").incoming_as_named_list()
        assert ["C"] == reqset.get_requirement("B").outgoing_as_named_list()
        assert ["A", "B"] == reqset.get_requirement(
            "C").incoming_as_named_list()
        assert [] == reqset.get_requirement("C").outgoing_as_named_list()
예제 #4
0
    def test_positive_02(self):
        "Three node one edge digraph B -> A, C -> A and C -> B"
        config = TestConfig()

        imod = InputModules("..", config)

        reqset = RequirementSet(config)
        req1 = Requirement('''Name: A
Type: master requirement''', 'A', None, imod, config)
        reqset.add_node(RequirementDNode(req1))
        req2 = Requirement('''Name: B
Type: requirement
Depends on: A''', 'B', None, imod, config)
        reqset.add_node(RequirementDNode(req2))
        config.set_depends_on()
        req3 = Requirement('''Name: C
Type: requirement
Depends on: A B''', 'C', None, imod, config)
        reqset.add_node(RequirementDNode(req3))
        config.set_depends_on()

        rdep = RDepDependsOn(config)
        rdep.rewrite(reqset)

        assert(reqset.get_requirement("A").get_incoming_as_named_list() == [])
        assert(reqset.get_requirement("A").get_outgoing_as_named_list() == ["C", "B"])
        assert(reqset.get_requirement("B").get_incoming_as_named_list() == ["A"])
        assert(reqset.get_requirement("B").get_outgoing_as_named_list() == ["C"])
        assert(reqset.get_requirement("C").get_incoming_as_named_list() == ["A", "B"])
        assert(reqset.get_requirement("C").get_outgoing_as_named_list() == [])
예제 #5
0
    def rmttest_positive_01(self):
        "Two node one edge digraph B -> A"
        config = TestConfig()

        imod = InputModules(config)

        reqset = RequirementSet(config)
        req1 = Requirement('''Name: A
Type: master requirement''', 'A', None, imod, config)
        reqset.add_requirement(req1)
        req2 = Requirement('''Name: B
Type: requirement
Depends on: A''', 'B', None, imod, config)
        reqset.add_requirement(req2)
        config.set_depends_on()

        rdep = RDepDependsOn(config)
        rdep.rewrite(reqset)

        self.assertEqual([],
                         reqset.get_requirement("A").incoming_as_named_list())
        self.assertEqual(["B"],
                         reqset.get_requirement("A").outgoing_as_named_list())
        self.assertEqual(["A"],
                         reqset.get_requirement("B").incoming_as_named_list())
        self.assertEqual([],
                         reqset.get_requirement("B").outgoing_as_named_list())
예제 #6
0
    def rmttest_negative_01(self):
        "Master requirement with Depends on field"
        config = TestConfig()

        imod = InputModules(config)

        reqset = RequirementSet(config)
        req1 = Requirement('''Name: A
Type: master requirement
Depends on: A''', 'A', None, imod, config)
        reqset.add_requirement(req1)
        config.set_depends_on()

        rdep = RDepDependsOn(config)
        status = rdep.rewrite(reqset)

        assert not status
예제 #7
0
    def test_negative_01(self):
        "Master requirement with Depends on field"
        config = TestConfig()

        imod = InputModules("..", config)

        reqset = RequirementSet(config)
        req1 = Requirement(
            '''Name: A
Type: master requirement
Depends on: A''', 'A', None, imod, config)
        reqset.add_node(RequirementDNode(req1))
        config.set_depends_on()

        rdep = RDepDependsOn(config)
        status = rdep.rewrite(reqset)

        assert (status == False)
예제 #8
0
    def test_negative_03(self):
        "Normal requirement has no 'Depends on'"
        config = TestConfig()

        imod = InputModules("..", config)

        reqset = RequirementSet(config)
        req1 = Requirement('''Name: A
Type: master requirement''', 'A', None, imod, config)
        reqset.add_node(RequirementDNode(req1))
        req2 = Requirement('''Name: B
Type: requirement''', 'B', None, imod, config)
        reqset.add_node(RequirementDNode(req2))
        config.set_depends_on()

        rdep = RDepDependsOn(config)
        status = rdep.rewrite(reqset)

        assert (status == False)
예제 #9
0
    def rmttest_negative_03(self):
        "Normal requirement has no 'Depends on'"
        config = TestConfig()

        imod = InputModules(config)

        reqset = RequirementSet(config)
        req1 = Requirement('''Name: A
Type: master requirement''', 'A', None, imod, config)
        reqset.add_requirement(req1)
        req2 = Requirement('''Name: B
Type: requirement''', 'B', None, imod, config)
        reqset.add_requirement(req2)
        config.set_depends_on()

        rdep = RDepDependsOn(config)
        status = rdep.rewrite(reqset)

        assert not status
    def rmttest_negative_07(self):
        "'Depends on' points to same requirement"
        config = TestConfig()

        imod = InputModules(config)

        reqset = RequirementSet(config)
        req1 = Requirement('''Name: A
Type: master requirement''', 'A', None, imod, config)
        reqset.add_requirement(req1)
        req2 = Requirement('''Name: B
Type: requirement
Depends on: B''', 'B', None, imod, config)
        reqset.add_requirement(req2)
        config.set_depends_on()

        rdep = RDepDependsOn(config)
        status = rdep.rewrite(reqset)

        assert not status
예제 #11
0
    def test_negative_07(self):
        "'Depends on' points to same requirement"
        config = TestConfig()

        imod = InputModules("..", config)

        reqset = RequirementSet(config)
        req1 = Requirement('''Name: A
Type: master requirement''', 'A', None, imod, config)
        reqset.add_node(RequirementDNode(req1))
        req2 = Requirement('''Name: B
Type: requirement
Depends on: B''', 'B', None, imod, config)
        reqset.add_node(RequirementDNode(req2))
        config.set_depends_on()

        rdep = RDepDependsOn(config)
        status = rdep.rewrite(reqset)

        assert(status == False)
예제 #12
0
    def rmttest_negative_04(self):
        "Normal requirement has empty 'Depends on'"
        config = TestConfig()

        imod = InputModules(config)

        reqset = RequirementSet(config)
        req1 = Requirement('''Name: A
Type: master requirement''', 'A', None, imod, config)
        reqset.add_requirement(req1)
        req2 = Requirement('''Name: B
Type: requirement
Depends on:''', 'B', None, imod, config)
        reqset.add_requirement(req2)
        config.set_depends_on()

        rdep = RDepDependsOn(config)
        status = rdep.rewrite(reqset)

        self.assertFalse(status)
예제 #13
0
    def rmttest_positive_01(self):
        "Two node one edge digraph B -> A"
        config = TestConfig()

        imod = InputModules(config)

        reqset = RequirementSet(config)
        req1 = Requirement('''Name: A
Type: master requirement''', 'A', None, imod, config)
        reqset.add_requirement(req1)
        req2 = Requirement('''Name: B
Type: requirement
Depends on: A''', 'B', None, imod, config)
        reqset.add_requirement(req2)
        config.set_depends_on()

        rdep = RDepDependsOn(config)
        rdep.rewrite(reqset)

        assert [] == reqset.get_requirement("A").incoming_as_named_list()
        assert ["B"] == reqset.get_requirement("A").outgoing_as_named_list()
        assert ["A"] == reqset.get_requirement("B").incoming_as_named_list()
        assert [] == reqset.get_requirement("B").outgoing_as_named_list()