root / elixir / trunk / tests / test_o2o.py @ 490
| Revision 490, 0.5 kB (checked in by ged, 4 years ago) |
|---|
| Rev | Line | |
|---|---|---|
| [199] | 1 | from elixir import * |
| 2 | ||
| 3 | def setup(): | |
| [467] | 4 | metadata.bind = "sqlite://" |
| [199] | 5 | |
| [235] | 6 | class TestOneToOne(object): |
| [199] | 7 | def teardown(self): |
| 8 | cleanup_all(True) | |
| 9 | ||
| [235] | 10 | def test_simple(self): |
| [199] | 11 | class A(Entity): |
| [271] | 12 | name = Field(String(60)) |
| [199] | 13 | b = OneToOne('B') |
| 14 | ||
| 15 | class B(Entity): | |
| [271] | 16 | name = Field(String(60)) |
| [199] | 17 | a = ManyToOne('A') |
| 18 | ||
| 19 | setup_all(True) | |
| 20 | ||
| 21 | b1 = B(name='b1', a=A(name='a1')) | |
| 22 | ||
| [349] | 23 | session.commit() |
| [490] | 24 | session.expunge_all() |
| [199] | 25 | |
| [210] | 26 | b = B.query.one() |
| [199] | 27 | a = b.a |
| 28 | ||
| 29 | assert b == a.b | |
| 30 |
Note: See TracBrowser
for help on using the browser.
