forked from jamesscottbrown/pyyed
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for varous entity types, with or without attributes
- Loading branch information
Showing
4 changed files
with
128 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from __future__ import print_function | ||
|
||
import sys, os | ||
sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | ||
|
||
import pyyed | ||
|
||
g = pyyed.Graph() | ||
g.add_node('Person', shape_fill="#EEEEEE", | ||
node_type="GenericNode", | ||
ER={"attributes": ["name", "surname"]}) | ||
|
||
#This is an entity without any attribut, for which only name will be set | ||
g.add_node('Role', shape_fill="#EEEEEE", | ||
node_type="GenericNode", | ||
ER={}) | ||
|
||
g.add_node('Kind', shape_fill="#EEEEEE", | ||
node_type="GenericNode", | ||
ER={'weak':'true'}) | ||
|
||
# g.add_node('ICar', shape_fill="#EEEEEE", | ||
# node_type="UMLClassNode", | ||
# UML={"stereotype": "interface", | ||
# "attributes": "", | ||
# "methods": "getModel()\ngetManufacturer()\ngetPrice()\nsetPrice()"}) | ||
|
||
#g.add_node('Vehicle', shape_fill="#EEEEEE", node_type="UMLClassNode") | ||
#g.add_edge('Car', 'Vehicle', arrowhead="white_delta") | ||
#g.add_edge('Car', 'ICar', arrowhead="white_delta", line_type="dashed") | ||
#g.add_node('This is a note', shape_fill="#EEEEEE", node_type="UMLNoteNode") | ||
|
||
# print(g.get_graph()) | ||
|
||
g.write_graph('demo-entity-relation.graphml') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import pyyed | ||
import xml.etree.ElementTree as xml | ||
|
||
import pytest | ||
|
||
|
||
def test_er_node_properties_are_set(): | ||
expected_attributes = 'attribute 1\nattribute 2' | ||
|
||
g = pyyed.Graph() | ||
|
||
g.add_node('BigEntity', node_type="GenericNode", | ||
ER={'attributes': expected_attributes}) | ||
|
||
assert g.nodes["BigEntity"].library['ER']["attributes"] == expected_attributes | ||
|
||
graphml = g.get_graph() | ||
# assertERNode(graphml, | ||
# expected_attributes) | ||
|
||
|
||
# def assertERNode(graphml, expected_stereotype, expected_attributes, expected_methods): | ||
# doc = xml.fromstring(graphml) | ||
# nsmap = {'g': 'http://graphml.graphdrawing.org/xmlns', | ||
# 'y': 'http://www.yworks.com/xml/graphml' | ||
# } | ||
# ernode = doc.find( | ||
# 'g:graph/g:node/g:data/y:UMLClassNode/y:UML', namespaces=nsmap) | ||
# attributes = ernode.find('y:AttributeLabel', namespaces=nsmap) | ||
# methods = ernode.find('y:MethodLabel', namespaces=nsmap) | ||
# | ||
# assert ernode.attrib['stereotype'] == expected_stereotype | ||
# assert attributes.text == expected_attributes | ||
# assert methods.text == expected_methods |