|
Revision 17, 0.9 kB
(checked in by cleverdevil, 6 years ago)
|
|
Finishing the name change from 'supermodel' to 'elixir'.
|
| Line | |
|---|
| 1 | """ |
|---|
| 2 | simple test case |
|---|
| 3 | """ |
|---|
| 4 | |
|---|
| 5 | import nose |
|---|
| 6 | |
|---|
| 7 | from sqlalchemy import create_engine |
|---|
| 8 | from elixir import * |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | class Person(Entity): |
|---|
| 12 | with_fields( |
|---|
| 13 | name = Field(Unicode(30)) |
|---|
| 14 | ) |
|---|
| 15 | |
|---|
| 16 | using_options(shortnames=True, order_by="name") |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | class Animal(Entity): |
|---|
| 20 | with_fields( |
|---|
| 21 | name = Field(Unicode(30)), |
|---|
| 22 | nose_color = Field(Unicode(15)) |
|---|
| 23 | ) |
|---|
| 24 | |
|---|
| 25 | belongs_to('owner', of_kind='Person') |
|---|
| 26 | |
|---|
| 27 | using_options(shortnames=True, order_by="name") |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | class TestOneWay(object): |
|---|
| 31 | def setup(self): |
|---|
| 32 | engine = create_engine('sqlite:///') |
|---|
| 33 | metadata.connect(engine) |
|---|
| 34 | create_all() |
|---|
| 35 | |
|---|
| 36 | def teardown(self): |
|---|
| 37 | drop_all() |
|---|
| 38 | |
|---|
| 39 | def test_oneway(self): |
|---|
| 40 | santa = Person(name="Santa Claus") |
|---|
| 41 | rudolph = Animal(name="Rudolph", nose_color="red") |
|---|
| 42 | rudolph.owner = santa |
|---|
| 43 | |
|---|
| 44 | objectstore.flush() |
|---|
| 45 | objectstore.clear() |
|---|
| 46 | |
|---|
| 47 | assert "Claus" in Animal.get_by(name="Rudolph").owner.name |
|---|