def test_allow_reconnect_on_same_class_for_multiple_presentations( connected_association, clone, create): asc, c1, c2 = connected_association new = clone(asc) assert allow(new, new.head, c1) assert allow(new, new.tail, c2)
def test_glue_to_class(connected_association): asc, c1, c2 = connected_association glued = allow(asc, asc.head, c1) assert glued connect(asc, asc.head, c1) glued = allow(asc, asc.tail, c2) assert glued
def test_allow_both_ends_connected_to_the_same_class(create, clone): asc = create(AssociationItem) c1 = create(ClassItem, UML.Class) connect(asc, asc.head, c1) connect(asc, asc.tail, c1) new = clone(asc) c2 = create(ClassItem, UML.Class) assert allow(new, new.head, c1) assert allow(new, new.tail, c1) assert not allow(new, new.head, c2) assert not allow(new, new.tail, c2)
def test_dependency_glue(create): """Test dependency glue to two actor items.""" actor1 = create(ActorItem, UML.Actor) actor2 = create(ActorItem, UML.Actor) dep = create(DependencyItem) glued = allow(dep, dep.head, actor1) assert glued connect(dep, dep.head, actor1) glued = allow(dep, dep.tail, actor2) assert glued
def test_generalization_glue(create): """Test generalization item gluing using two classes.""" gen = create(GeneralizationItem) c1 = create(ClassItem, UML.Class) c2 = create(ClassItem, UML.Class) glued = allow(gen, gen.tail, c1) assert glued connect(gen, gen.tail, c1) assert get_connected(gen, gen.tail) is c1 assert gen.subject is None glued = allow(gen, gen.head, c2) assert glued
def test_glue(element_factory, diagram): """Test extension item glue.""" ext = diagram.create(ExtensionItem) st = diagram.create(ClassItem, subject=element_factory.create(UML.Stereotype)) cls = diagram.create(ClassItem, subject=element_factory.create(UML.Class)) glued = allow(ext, ext.tail, st) assert glued connect(ext, ext.tail, st) glued = allow(ext, ext.head, cls) assert glued
def test_commentline_glie_to_item_with_no_subject(create, diagram): """Test comment line connecting to comment and actor items. """ line = create(CommentLineItem) gi = create(GeneralizationItem) assert allow(line, line.tail, gi)
def test_allow_reconnect_if_only_one_connected_presentations( connected_association, clone, create): asc, c1, c2 = connected_association clone(asc) c3 = create(ClassItem, UML.Class) assert allow(asc, asc.head, c3)
def test_allow_execution_specification_to_lifeline(diagram): lifeline = diagram.create(LifelineItem) lifeline.lifetime.visible = True exec_spec = diagram.create(ExecutionSpecificationItem) glued = allow(exec_spec, exec_spec.handles()[0], lifeline, lifeline.lifetime.port) assert glued
def test_disallow_connect_if_already_connected_with_presentations( connected_association, clone, create): asc, c1, c2 = connected_association new = clone(asc) c3 = create(ClassItem, UML.Class) assert not allow(new, new.head, c3)
def test_commentline_same_comment_glue(create): """Test comment line item gluing to already connected comment item.""" comment = create(CommentItem, Comment) line = create(CommentLineItem) connect(line, line.head, comment) glued = allow(line, line.tail, comment) assert not glued
def test_class_glue(element_factory, diagram): """Test extension item gluing to a class.""" ext = diagram.create(ExtensionItem) cls = diagram.create(ClassItem, subject=element_factory.create(UML.Class)) glued = allow(ext, ext.tail, cls) assert not glued
def test_disallow_reconnect_if_multiple_connected_presentations( connected_association, clone, create): asc, c1, c2 = connected_association new = clone(asc) connect(new, new.head, c1) c3 = create(ClassItem, UML.Class) assert not allow(asc, asc.head, c3)
def test_glue(element_factory, diagram): """Test gluing package import item.""" pkg_import = diagram.create(PackageImportItem) package1 = diagram.create(PackageItem, subject=element_factory.create(UML.Package)) package2 = diagram.create(PackageItem, subject=element_factory.create(UML.Package)) glued = allow(pkg_import, pkg_import.tail, package1) assert glued connect(pkg_import, pkg_import.tail, package1) glued = allow(pkg_import, pkg_import.head, package2) assert glued
def test_visible_lifetime_glue(diagram): """Test message to visible lifetime glue.""" ll = diagram.create(LifelineItem) msg = diagram.create(MessageItem) ll.lifetime.visible = True glued = allow(msg, msg.head, ll, ll.lifetime.port) assert glued
def test_head_glue(diagram): """Test message head glue.""" ll = diagram.create(LifelineItem) msg = diagram.create(MessageItem) # get head port port = ll.ports()[0] glued = allow(msg, msg.head, ll, port) assert glued
def test_package_glue(element_factory, diagram): """Test package import item can't glue to a class.""" pkg_import = diagram.create(PackageImportItem) import_class = diagram.create(ClassItem, subject=element_factory.create(UML.Class)) glued = allow(pkg_import, pkg_import.head, import_class) assert not glued
def test_invisible_lifetime_glue(diagram): """Test message to invisible lifetime glue """ ll = diagram.create(LifelineItem) msg = diagram.create(MessageItem) glued = allow(msg, msg.head, ll, ll.lifetime.port) assert not ll.lifetime.visible assert not glued
def test_allow_execution_specification_to_execution_specification(diagram): parent_exec_spec = diagram.create(ExecutionSpecificationItem) child_exec_spec = diagram.create(ExecutionSpecificationItem) glued = allow( parent_exec_spec, parent_exec_spec.handles()[0], child_exec_spec, child_exec_spec.ports()[0], ) assert glued
def test_relation_allow_connect_disconnect_cycle(diagram, element_factory, item_class): req1 = element_factory.create(sysml.Requirement) req2 = element_factory.create(sysml.Requirement) req_item1 = diagram.create(RequirementItem, subject=req1) req_item2 = diagram.create(RequirementItem, subject=req2) relation = diagram.create(item_class) assert allow(relation, relation.handles()[0], req_item1) assert allow(relation, relation.handles()[1], req_item2) connect(relation, relation.handles()[0], req_item1) connect(relation, relation.handles()[1], req_item2) assert relation.subject assert relation.subject.sourceContext is req_item1.subject assert relation.subject.targetContext is req_item2.subject disconnect(relation, relation.handles()[0]) assert not relation.subject
def test_stereotype_glue(element_factory, diagram): """Test extension item gluing to a stereotype. Connecting a Stereotype should work because it is derived from the UML Class. """ ext = diagram.create(ExtensionItem) st = diagram.create(ClassItem, subject=element_factory.create(UML.Stereotype)) assert isinstance(st.subject, UML.Stereotype) glued = allow(ext, ext.head, st) assert glued
def test_message_glue_cd(diagram): """Test gluing message on communication diagram.""" lifeline1 = diagram.create(LifelineItem) lifeline2 = diagram.create(LifelineItem) message = diagram.create(MessageItem) # make second lifeline to be in sequence diagram mode lifeline2.lifetime.visible = True # connect head of message to lifeline's head connect(message, message.head, lifeline1) glued = allow(message, message.tail, lifeline2, lifeline2.lifetime.port) # no connection possible as 2nd lifeline is in sequence diagram # mode assert not glued
def test_message_glue_sd(diagram): """Test gluing message on sequence diagram.""" msg = diagram.create(MessageItem) ll1 = diagram.create(LifelineItem) ll2 = diagram.create(LifelineItem) # 1st lifeline - communication diagram # 2nd lifeline - sequence diagram ll2.lifetime.visible = True # connect lifetime of message to lifeline's lifetime connect(msg, msg.head, ll1, ll1.lifetime.port) glued = allow(msg, msg.tail, ll2) # no connection possible as 2nd lifeline is in communication # diagram mode assert not glued
def test_commentline_linked_to_same_element_twice(create): """It is not allowed to create two commentlines between the same elements.""" clazz = create(ClassItem, UML.Class) # now, connect comment to a generalization (relationship) comment = create(CommentItem, Comment) line1 = create(CommentLineItem) connect(line1, line1.head, comment) connect(line1, line1.tail, clazz) assert clazz.subject in comment.subject.annotatedElement assert comment.subject in clazz.subject.comment # Now add another line line2 = create(CommentLineItem) connect(line2, line2.head, comment) assert not allow(line2, line2.tail, clazz)
def test_allow_connector_to_proxy_port(diagram, connector_item: ConnectorItem, head_proxy_port_item: ProxyPortItem): assert allow(connector_item, connector_item.handles()[0], head_proxy_port_item)
def test_allow_reconnect_for_single_presentation(connected_association, create): asc, c1, c2 = connected_association c3 = create(ClassItem, UML.Class) assert allow(asc, asc.head, c3)