Ticket #86: test_concrete.py

File test_concrete.py, 0.8 kB (added by ged, 5 years ago)
Line 
1from elixir import *
2from datetime import datetime
3
4class Event(Entity):
5    using_options(inheritance='concrete', tablename='__event')
6    _start = Field(DateTime, required=True, colname='start')
7    _finish = Field(DateTime, required=True, colname='finish')
8
9    def set_start(self, value):
10        self._start = value
11    start = property(lambda e: e._start, set_start)
12
13    def set_finish(self, value):
14        self._finish = value
15    finish = property(lambda e: e._finish, set_finish)
16
17class Shift(Event):
18    using_options(inheritance='concrete', shortnames=True)
19
20metadata.bind = 'sqlite://'
21metadata.bind.echo = True
22
23setup_all(True)
24
25shift = Shift(start=datetime.now(), finish=datetime.now())
26
27session.commit()
28session.expunge_all()
29
30shifts = Shift.query.all()
31for shift in shifts:
32    print "Shift(start=%s, finish=%s)" % (shift.start, shift.finish)