|
Revision 471, 0.7 kB
(checked in by ged, 4 years ago)
|
|
cosmetic improvements
|
| Line | |
|---|
| 1 | from elixir import * |
|---|
| 2 | |
|---|
| 3 | def setup(): |
|---|
| 4 | metadata.bind = 'sqlite://' |
|---|
| 5 | |
|---|
| 6 | def teardown(): |
|---|
| 7 | cleanup_all(True) |
|---|
| 8 | |
|---|
| 9 | class TestAutoloadMixed(object): |
|---|
| 10 | def setup(self): |
|---|
| 11 | conn = metadata.bind.connect() |
|---|
| 12 | conn.execute("CREATE TABLE user (" |
|---|
| 13 | "user_id INTEGER PRIMARY KEY AUTOINCREMENT)") |
|---|
| 14 | conn.close() |
|---|
| 15 | |
|---|
| 16 | def test_belongs_to(self): |
|---|
| 17 | class User(Entity): |
|---|
| 18 | using_options(tablename='user', autoload=True) |
|---|
| 19 | |
|---|
| 20 | class Item(Entity): |
|---|
| 21 | owner = ManyToOne('User') |
|---|
| 22 | |
|---|
| 23 | setup_all(True) |
|---|
| 24 | |
|---|
| 25 | colname = Item.table.c['owner_user_id'].foreign_keys[0].column.name |
|---|
| 26 | assert colname == 'user_id' |
|---|