root / elixir / trunk / tests / test_o2o.py @ 490

Revision 490, 0.5 kB (checked in by ged, 4 years ago)

Dropped support for python 2.3, SQLAlchemy 0.4 and deprecated stuff from Elixir
0.7

Line 
1from elixir import *
2
3def setup():
4    metadata.bind = "sqlite://"
5
6class TestOneToOne(object):
7    def teardown(self):
8        cleanup_all(True)
9
10    def test_simple(self):
11        class A(Entity):
12            name = Field(String(60))
13            b = OneToOne('B')
14
15        class B(Entity):
16            name = Field(String(60))
17            a = ManyToOne('A')
18
19        setup_all(True)
20
21        b1 = B(name='b1', a=A(name='a1'))
22
23        session.commit()
24        session.expunge_all()
25
26        b = B.query.one()
27        a = b.a
28
29        assert b == a.b
30
Note: See TracBrowser for help on using the browser.