Skip to content

Commit

Permalink
Add test for 0.8 compatibility patch.
Browse files Browse the repository at this point in the history
  • Loading branch information
fschulze committed Mar 2, 2014
1 parent e7cc9dd commit f9305bb
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_uml_graph.py
Expand Up @@ -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'

0 comments on commit f9305bb

Please sign in to comment.