Beispiel #1
0
 def test_remove_bundle_from_two_bundles(self):
     b1 = CBundle("B1")
     b2 = CBundle("B2")
     s1 = CStereotype("s1", bundles=[b1, b2])
     b1.remove(s1)
     eq_(set(b1.get_elements(type=CStereotype)), set())
     eq_(set(b2.get_elements(type=CStereotype)), {s1})
     eq_(set(s1.bundles), {b2})
 def test_remove_bundle_from_two_bundles(self):
     b1 = CBundle("B1")
     b2 = CBundle("B2")
     c1 = CClass(self.mcl, "c1", bundles=[b1, b2])
     b1.remove(c1)
     eq_(set(b1.get_elements(type=CClass)), set())
     eq_(set(b2.get_elements(type=CClass)), {c1})
     eq_(set(c1.bundles), {b2})
 def test_remove_bundle_from_two_bundles(self):
     b1 = CBundle("B1")
     b2 = CBundle("B2")
     m1 = CMetaclass("m1", bundles=[b1, b2])
     b1.remove(m1)
     eq_(set(b1.get_elements(type=CMetaclass)), set())
     eq_(set(b2.get_elements(type=CMetaclass)), {m1})
     eq_(set(m1.bundles), {b2})
Beispiel #4
0
 def test_remove_bundle_from_two_bundles(self):
     b1 = CBundle("B1")
     b2 = CBundle("B2")
     e1 = CEnum("e1", bundles=[b1, b2])
     b1.remove(e1)
     eq_(set(b1.get_elements(type=CEnum)), set())
     eq_(set(b2.get_elements(type=CEnum)), {e1})
     eq_(set(e1.bundles), {b2})
 def test_remove_bundle_from_two_bundles(self):
     b1 = CBundle("B1")
     b2 = CBundle("B2")
     ba = CBundle("ba", bundles=[b1, b2])
     b1.remove(ba)
     eq_(set(b1.get_elements(type=CBundle)), set())
     eq_(set(b2.get_elements(type=CBundle)), {ba})
     eq_(set(ba.bundles), {b2})
Beispiel #6
0
    def test_remove_stereotype_from_bundle(self):
        b1 = CBundle("B1")
        b2 = CBundle("B2")
        s1 = CStereotype("s1", bundles=b1)
        try:
            # noinspection PyTypeChecker
            b1.remove(None)
            exception_expected_()
        except CException as e:
            eq_("'None' is not an element of the bundle", e.value)
        try:
            b1.remove(CEnum("A"))
            exception_expected_()
        except CException as e:
            eq_("'A' is not an element of the bundle", e.value)
        try:
            b2.remove(s1)
            exception_expected_()
        except CException as e:
            eq_("'s1' is not an element of the bundle", e.value)
        b1.remove(s1)
        eq_(set(b1.get_elements(type=CStereotype)), set())

        s1 = CStereotype("s1", bundles=b1)
        s2 = CStereotype("s1", bundles=b1)
        s3 = CStereotype("s1",
                         superclasses=s2,
                         attributes={"i": 1},
                         bundles=b1,
                         extended=self.mcl)
        s4 = CStereotype("s1",
                         superclasses=s2,
                         attributes={"i": 1},
                         bundles=b1,
                         extended=self.a)

        b1.remove(s1)
        try:
            b1.remove(CStereotype("s2", bundles=b2))
            exception_expected_()
        except CException as e:
            eq_("'s2' is not an element of the bundle", e.value)
        try:
            b1.remove(s1)
            exception_expected_()
        except CException as e:
            eq_("'s1' is not an element of the bundle", e.value)

        eq_(set(b1.get_elements(type=CStereotype)), {s2, s3, s4})
        b1.remove(s3)
        b1.remove(s4)
        eq_(set(b1.get_elements(type=CStereotype)), {s2})

        eq_(s3.superclasses, [s2])
        eq_(s2.subclasses, [s3, s4])
        eq_(s3.attribute_names, ["i"])
        eq_(s3.extended, [self.mcl])
        eq_(s3.name, "s1")
        eq_(s3.bundles, [])
        eq_(s4.superclasses, [s2])
        eq_(s4.attribute_names, ["i"])
        eq_(s4.extended, [self.a])
        eq_(s4.name, "s1")
        eq_(s4.bundles, [])
    def test_remove_class_from_bundle(self):
        b1 = CBundle("B1")
        b2 = CBundle("B2")
        cl1 = CClass(self.mcl, "CL1", bundles=b1)
        try:
            # noinspection PyTypeChecker
            b1.remove(None)
            exception_expected_()
        except CException as e:
            eq_("'None' is not an element of the bundle", e.value)
        try:
            b1.remove(CEnum("A"))
            exception_expected_()
        except CException as e:
            eq_("'A' is not an element of the bundle", e.value)
        try:
            b2.remove(cl1)
            exception_expected_()
        except CException as e:
            eq_("'CL1' is not an element of the bundle", e.value)
        b1.remove(cl1)
        eq_(set(b1.get_elements(type=CClass)), set())

        cl1 = CClass(self.mcl, "CL1", bundles=b1)
        cl2 = CClass(self.mcl, "CL2", bundles=b1)
        cl3 = CClass(self.mcl,
                     "CL3",
                     superclasses=cl2,
                     attributes={"i": 1},
                     bundles=b1)
        cl3.set_value("i", 7)
        o = CObject(cl3, bundles=b1)

        b1.remove(cl1)
        try:
            b1.remove(CClass(CMetaclass("MCL", bundles=b2), "CL2", bundles=b2))
            exception_expected_()
        except CException as e:
            eq_("'CL2' is not an element of the bundle", e.value)
        try:
            b1.remove(cl1)
            exception_expected_()
        except CException as e:
            eq_("'CL1' is not an element of the bundle", e.value)

        eq_(set(b1.get_elements(type=CClass)), {cl2, cl3})
        b1.remove(cl3)
        eq_(set(b1.get_elements(type=CClass)), {cl2})

        eq_(cl3.superclasses, [cl2])
        eq_(cl2.subclasses, [cl3])
        eq_(cl3.attribute_names, ["i"])
        eq_(cl3.metaclass, self.mcl)
        eq_(cl3.objects, [o])
        eq_(cl3.name, "CL3")
        eq_(cl3.bundles, [])
        eq_(b1.get_elements(type=CObject), [o])
        eq_(cl3.get_value("i"), 7)
    def test_remove_metaclass_from_bundle(self):
        b1 = CBundle("B1")
        b2 = CBundle("B2")
        m1 = CMetaclass("M1", bundles=b1)
        try:
            # noinspection PyTypeChecker
            b1.remove(None)
            exception_expected_()
        except CException as e:
            eq_("'None' is not an element of the bundle", e.value)
        try:
            b1.remove(CEnum("A"))
            exception_expected_()
        except CException as e:
            eq_("'A' is not an element of the bundle", e.value)
        try:
            b2.remove(m1)
            exception_expected_()
        except CException as e:
            eq_("'M1' is not an element of the bundle", e.value)
        b1.remove(m1)
        eq_(set(b1.get_elements(type=CMetaclass)), set())

        m1 = CMetaclass("M1", bundles=b1)
        m2 = CMetaclass("M1", bundles=b1)
        m3 = CMetaclass("M1", superclasses=m2, attributes={"i": 1}, bundles=b1)
        c = CClass(m3, bundles=b1)

        b1.remove(m1)
        try:
            b1.remove(CMetaclass("M2", bundles=b2))
            exception_expected_()
        except CException as e:
            eq_("'M2' is not an element of the bundle", e.value)
        try:
            b1.remove(m1)
            exception_expected_()
        except CException as e:
            eq_("'M1' is not an element of the bundle", e.value)

        eq_(set(b1.get_elements(type=CMetaclass)), {m2, m3})
        b1.remove(m3)
        eq_(set(b1.get_elements(type=CMetaclass)), {m2})

        eq_(m3.superclasses, [m2])
        eq_(m2.subclasses, [m3])
        eq_(m3.attribute_names, ["i"])
        eq_(m3.classes, [c])
        eq_(m3.name, "M1")
        eq_(m3.bundles, [])
        eq_(b1.get_elements(type=CClass), [c])
Beispiel #9
0
    def test_remove_enum_from_bundle(self):
        b1 = CBundle("B1")
        b2 = CBundle("B2")
        e1 = CEnum("E1", bundles=b1)
        try:
            # noinspection PyTypeChecker
            b1.remove(None)
            exception_expected_()
        except CException as e:
            eq_("'None' is not an element of the bundle", e.value)
        try:
            b1.remove(CEnum("A"))
            exception_expected_()
        except CException as e:
            eq_("'A' is not an element of the bundle", e.value)
        try:
            b2.remove(e1)
            exception_expected_()
        except CException as e:
            eq_("'E1' is not an element of the bundle", e.value)
        b1.remove(e1)
        eq_(set(b1.get_elements(type=CEnum)), set())

        e1 = CEnum("E1", bundles=b1)
        e2 = CEnum("E2", bundles=b1)
        e3 = CEnum("E3", values=["1", "2"], bundles=b1)

        b1.remove(e1)
        try:
            b1.remove(CEnum("E2", bundles=b2))
            exception_expected_()
        except CException as e:
            eq_("'E2' is not an element of the bundle", e.value)
        try:
            b1.remove(e1)
            exception_expected_()
        except CException as e:
            eq_("'E1' is not an element of the bundle", e.value)

        eq_(set(b1.get_elements(type=CEnum)), {e2, e3})
        b1.remove(e3)
        eq_(set(b1.get_elements(type=CEnum)), {e2})

        eq_(e3.name, "E3")
        eq_(e3.bundles, [])
        eq_(e3.values, ["1", "2"])
    def test_remove_bundle_from_bundle(self):
        b1 = CBundle("B1")
        b2 = CBundle("B2")
        ba = CBundle("A", bundles=b1)
        try:
            # noinspection PyTypeChecker
            b1.remove(None)
            exception_expected_()
        except CException as e:
            eq_("'None' is not an element of the bundle", e.value)
        try:
            b1.remove(CEnum("A"))
            exception_expected_()
        except CException as e:
            eq_("'A' is not an element of the bundle", e.value)
        try:
            b2.remove(ba)
            exception_expected_()
        except CException as e:
            eq_("'A' is not an element of the bundle", e.value)
        b1.remove(ba)
        eq_(set(b1.get_elements(type=CBundle)), set())

        mcl1 = CMetaclass("MCL")
        cl1 = CClass(mcl1, "CL")

        ba = CBundle("PA", bundles=b1)
        bb = CBundle("PB", bundles=b1)
        bc = CBundle("PC", bundles=b1, elements=[mcl1, cl1])

        b1.remove(ba)
        try:
            b1.remove(CBundle("PB", bundles=b2))
            exception_expected_()
        except CException as e:
            eq_("'PB' is not an element of the bundle", e.value)
        try:
            b1.remove(ba)
            exception_expected_()
        except CException as e:
            eq_("'PA' is not an element of the bundle", e.value)

        eq_(set(b1.get_elements(type=CBundle)), {bb, bc})
        b1.remove(bc)
        eq_(set(b1.get_elements(type=CBundle)), {bb})

        eq_(bc.get_elements(type=CBundle), [])
        eq_(bc.get_elements(type=CBundle), [])
        eq_(bc.elements, [mcl1, cl1])