Пример #1
0
def test_create_EAnnotation():
    c = Class()
    assert c.eAnnotations == []

    annotation = c.create_EAnnotation(source='testsrc')
    assert annotation in c.eAnnotations
    assert annotation.source == 'testsrc'
Пример #2
0
def test_all_owned_elements():
    p = Package()
    c = Class()
    sub = Package()
    p.packagedElement.append(sub)
    sub.packagedElement.append(c)

    assert len(list(p.all_owned_elements())) == 2
    assert c in p.all_owned_elements()
    assert sub in p.all_owned_elements()
    assert c in sub.all_owned_elements()
    assert c.not_own_self() is True
Пример #3
0
def test_owner():
    c = Class()
    p = Property()
    c.ownedAttribute.append(p)

    assert c.owner is None
    assert p.owner is c
Пример #4
0
def test_ownedElement():
    c = Class()
    p = Property()
    assert len(c.ownedElement) == 0

    c.ownedAttribute.append(p)
    assert p in c.ownedElement
Пример #5
0
def test_qualified_name():
    p = Package(name='p')
    c = Class(name='c')
    sub = Package(name='sub')
    p.packagedElement.append(sub)
    sub.packagedElement.append(c)

    assert c.qualifiedName == 'p::sub::c'
Пример #6
0
def test_class_superclass_derived():
    c1 = Class()
    c2 = Class()
    assert len(c1.superClass) == 0

    c1.superClass.append(c2)
    assert len(c1.superClass) == 1
    assert c2 in c1.superClass

    c1.superClass.remove(c2)
    assert len(c1.superClass) == 0

    c1.superClass.insert(0, c2)
    assert len(c1.superClass) == 1
    assert c2 in c1.superClass

    del c1.superClass[0]
    assert len(c1.superClass) == 0

    assert repr(c1.superClass)
Пример #7
0
def test_package_nestingPackage():
    p1, p2 = Package(), Package()
    assert p1.nestingPackage is None

    p2.nestingPackage = p1
    assert p2.nestingPackage is p1
    assert p2 in p1.packagedElement
    assert p2 in p1.nestedPackage

    p2.nestingPackage = None
    assert p2.nestingPackage is None
    assert p2 not in p1.packagedElement
    assert p2 not in p1.nestedPackage

    with pytest.raises(BadValueError):
        p1.nestingPackage = Class()
Пример #8
0
def test_has_owner():
    c = Class()
    p = Property()
    c.ownedAttribute.append(p)
    assert c.has_owner() is False
    assert p.has_owner() is True