root / elixir / trunk / tests / test_autoload_mixed.py @ 471

Revision 471, 0.7 kB (checked in by ged, 4 years ago)

cosmetic improvements

Line 
1from elixir import *
2
3def setup():
4    metadata.bind = 'sqlite://'
5
6def teardown():
7    cleanup_all(True)
8
9class 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'
Note: See TracBrowser for help on using the browser.