root / elixir / trunk / tests / test_autoload_nopk.py @ 271

Revision 271, 0.8 kB (checked in by ged, 6 years ago)

- changed all Unicode fields to String since we don't send unicode data to

those fields and now SQLAlchemy complains when that happens

- added test for multi-pk case to M2M

Line 
1"""
2    simple test case
3"""
4
5from sqlalchemy import Table, Column, MetaData
6from elixir import *
7
8def setup():
9    metadata.bind = 'sqlite:///'
10
11def teardown():
12    cleanup_all()
13
14#-----------
15
16class TestAutoload(object):
17    def test_pk(self):
18        local_meta = MetaData(metadata.bind)
19
20        person_table = Table('person', local_meta,
21            Column('id', Integer),
22            Column('name', String(32)))
23       
24        local_meta.create_all()
25
26        class Person(Entity):
27            using_options(tablename='person', autoload=True)
28            using_mapper_options(primary_key=['id'])
29
30        setup_all()
31
32        barney = Person(id=1, name="Barney")
33
34        session.flush()
35        session.clear()
36
37        persons = Person.query.all()
38
39        assert len(persons) == 1
40        assert persons[0].name == "Barney"
Note: See TracBrowser for help on using the browser.