diff --git a/tests/test_uml_graph.py b/tests/test_uml_graph.py index d5e1062..d85b172 100644 --- a/tests/test_uml_graph.py +++ b/tests/test_uml_graph.py @@ -54,3 +54,23 @@ class Bar(Base): assert 'edges' in graph.obj_dict assert ('"Foo"', '"Bar"') in graph.obj_dict['edges'] assert graph.obj_dict['edges'][('"Foo"', '"Bar"')][0]['attributes']['headlabel'] == '+bars *' + + +def test_backref(Base): + class Foo(Base): + __tablename__ = 'foo' + id = Column(types.Integer, primary_key=True) + class Bar(Base): + __tablename__ = 'bar' + id = Column(types.Integer, primary_key=True) + foo_id = Column(types.Integer, ForeignKey(Foo.id)) + Foo.bars = relationship(Bar, backref='foo') + graph = sasd.create_uml_graph(mappers(Foo, Bar)) + assert sorted(graph.obj_dict['nodes'].keys()) == ['"Bar"', '"Foo"'] + assert '+id : Integer' in graph.obj_dict['nodes']['"Foo"'][0]['attributes']['label'] + assert '+foo_id : Integer' in graph.obj_dict['nodes']['"Bar"'][0]['attributes']['label'] + assert 'edges' in graph.obj_dict + assert ('"Foo"', '"Bar"') in graph.obj_dict['edges'] + assert ('"Bar"', '"Foo"') in graph.obj_dict['edges'] + assert graph.obj_dict['edges'][('"Foo"', '"Bar"')][0]['attributes']['headlabel'] == '+bars *' + assert graph.obj_dict['edges'][('"Bar"', '"Foo"')][0]['attributes']['headlabel'] == '+foo 0..1'