Пример #1
0
def test_enumerations():
    class A(Element):
        a: enumeration

    A.a = enumeration("a", ("one", "two", "three"), "one")
    a = A()
    assert a.a == "one"
    a.a = "two"
    assert a.a == "two"
    a.a = "three"
    assert a.a == "three"
    try:
        a.a = "four"
    except AttributeError:
        assert a.a == "three"
    else:
        assert 0, "a.a could not be four"
    del a.a
    assert a.a == "one"
Пример #2
0
class _Refine:
    pass


AbstractRequirement.externalId = attribute("externalId", str)
AbstractRequirement.text = attribute("text", str)
AdjuntProperty.principal = association("principal", Element, upper=1)
Block.isEncapsulated = attribute("isEncapsulated", int)
BoundReference.boundend = association("boundend", ConnectorEnd, upper=1)
ChangeSructuralFeatureEvent.structuralFeature = association(
    "structuralFeature", StructuralFeature, upper=1
)
ConnectorProperty.connector = association("connector", Connector, upper=1)
DirectedFeature.featureDirection = enumeration(
    "kind", ("required", "providedRequired", "provided"), "required"
)
DirectedRelationshipPropertyPath.sourceContext = association(
    "sourceContext", Classifier, upper=1
)
DirectedRelationshipPropertyPath.sourcePropertyPath = association(
    "sourcePropertyPath", Property
)
DirectedRelationshipPropertyPath.targetContext = association(
    "targetContext", Classifier, upper=1
)
DirectedRelationshipPropertyPath.targetPropertyPath = association(
    "targetPropertyPath", Property
)
ElementGroup.name = attribute("name", str)
ElementGroup.orderedMember = association("orderedMember", Element)
Пример #3
0
class View(Class):
    pass


class Viewpoint(Class):
    concernList: relation_many[Comment]
    language: attribute[str]
    presentation: attribute[str]
    purpose: attribute[str]
    stakeholder: relation_many[Stakeholder]


Heritage.isSubstitutable = attribute("isSubstitutable", int)
ObjectNode.ordering = enumeration("ordering",
                                  ("unordered", "ordered", "LIFO", "FIFO"),
                                  "FIFO")
Heritage.general = association("general", Classifier, lower=1, upper=1)
Classifier.heritage = association("heritage",
                                  Heritage,
                                  composite=True,
                                  opposite="specific")
Heritage.specific = association("specific",
                                Classifier,
                                lower=1,
                                upper=1,
                                opposite="heritage")
Classifier.general = derived("general", Classifier, 0, "*",
                             lambda self: [g.general for g in self.heritage])
DirectedRelationship.target = derivedunion(
    "target",