File: test_autoload_mixed.py

package info (click to toggle)
elixir 0.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 640 kB
  • ctags: 1,079
  • sloc: python: 4,936; makefile: 10
file content (26 lines) | stat: -rw-r--r-- 645 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from elixir import *

def setup():
    metadata.bind = 'sqlite:///'

def teardown():
    cleanup_all(True)

class TestAutoloadMixed(object):
    def setup(self):
        conn = metadata.bind.connect()
        conn.execute("""CREATE TABLE user
        (user_id INTEGER PRIMARY KEY AUTOINCREMENT)""")
        conn.close()

    def test_belongs_to(self):
        class User(Entity):
            using_options(tablename='user', autoload=True)

        class Item(Entity):
            owner = ManyToOne('User')

        setup_all(True)

        assert Item.table.c['owner_user_id'].foreign_keys[0].column.name == 'user_id'