File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88 Integer ,
99 DateTime ,
1010 ForeignKey ,
11- Enum ,
1211 )
12+ from sqlalchemy .types import Enum
1313from sqlalchemy .ext .declarative import declared_attr
1414
1515
@@ -29,9 +29,7 @@ class AddressMixin(object):
2929 """ This is a mixin for Address Many2Many bindings """
3030
3131 priority = Column (Integer )
32- addr_type_cn = Column (
33- Enum (EnumAddressType ),
34- )
32+ addr_type_cn = Column (Integer )
3533 app_flags = Column (Integer )
3634 timestmp = Column (DateTime )
3735
@@ -42,3 +40,7 @@ def addr_id(cls):
4240 ForeignKey ('csaddr.addr_id' ),
4341 primary_key = True ,
4442 )
43+
44+ @property
45+ def addr_type (self ):
46+ return EnumAddressType (self .addr_type_cn )
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ class Order(Carepoint.BASE):
2828 acct_id = Column (Integer )
2929 invoice_nbr = Column (Integer )
3030 order_state_cn = Column (
31- Enum ( EnumOrderState ) ,
31+ Integer ,
3232 ForeignKey ('CsOmStatus.state_cn' )
3333 )
3434 order_status_cn = Column (
@@ -88,3 +88,7 @@ class Order(Carepoint.BASE):
8888 ForeignKey ('csuser.user_id' ),
8989 )
9090 chg_date = Column (DateTime )
91+
92+ @property
93+ def order_state (self ):
94+ return EnumOrderState (self .order_state_cn )
Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ class OrderStatus(Carepoint.BASE):
2222 autoincrement = False ,
2323 )
2424 state_cn = Column (
25- Enum ( EnumOrderState )
25+ Integer ,
2626 )
2727 descr = Column (String )
28+
29+ @property
30+ def state (self ):
31+ return EnumOrderState (self .state_cn )
Original file line number Diff line number Diff line change 88 Integer ,
99 DateTime ,
1010 ForeignKey ,
11- Enum ,
1211 )
12+ from sqlalchemy .types import Enum
1313from sqlalchemy .ext .declarative import declared_attr
1414
1515
@@ -33,9 +33,7 @@ class PhoneMixin(object):
3333 """ This is a mixin for Phone Many2Many bindings """
3434
3535 priority = Column (Integer )
36- phone_type_cn = Column (
37- Enum (EnumPhoneType ),
38- )
36+ phone_type_cn = Column (Integer )
3937 app_flags = Column (Integer )
4038 timestmp = Column (DateTime )
4139
@@ -46,3 +44,7 @@ def phone_id(cls):
4644 ForeignKey ('csphone.phone_id' ),
4745 primary_key = True ,
4846 )
47+
48+ @property
49+ def phone_type (self ):
50+ return EnumPhoneType (self .phone_type_cn )
Original file line number Diff line number Diff line change @@ -18,5 +18,6 @@ def test_addr_mixin_col(self):
1818 hasattr (DoctorAddress , 'addr_id' )
1919 )
2020
21+
2122if __name__ == '__main__' :
2223 unittest .main ()
Original file line number Diff line number Diff line change 55import unittest
66from sqlalchemy .schema import Table
77from carepoint .tests .db .db import DatabaseTest
8- from carepoint .models .cph .order import Order
8+ from carepoint .models .cph .order import Order , EnumOrderState
99
1010
1111class TestModelsCphOrder (DatabaseTest ):
1212
1313 def test_table_initialization (self , ):
1414 self .assertIsInstance (Order .__table__ , Table )
1515
16+ def new_record (self ):
17+ self .type_cn = 20
18+ obj = Order ()
19+ obj .order_state_cn = self .type_cn
20+ return obj
21+
22+ def test_order_state (self ):
23+ """ It should return proper Enum for state cn """
24+ obj = self .new_record ()
25+ self .assertEqual (
26+ EnumOrderState (self .type_cn ),
27+ obj .order_state ,
28+ )
29+
1630
1731if __name__ == '__main__' :
1832 unittest .main ()
Original file line number Diff line number Diff line change 55import unittest
66from sqlalchemy .schema import Table
77from carepoint .tests .db .db import DatabaseTest
8- from carepoint .models .cph .order_status import OrderStatus
8+ from carepoint .models .cph .order_status import OrderStatus , EnumOrderState
99
1010
1111class TestModelsCphOrderStatus (DatabaseTest ):
1212
1313 def test_table_initialization (self , ):
1414 self .assertIsInstance (OrderStatus .__table__ , Table )
1515
16+ def new_record (self ):
17+ self .type_cn = 20
18+ obj = OrderStatus ()
19+ obj .state_cn = self .type_cn
20+ return obj
21+
22+ def test_state (self ):
23+ """ It should return proper Enum for state cn """
24+ obj = self .new_record ()
25+ self .assertEqual (
26+ EnumOrderState (self .type_cn ),
27+ obj .state ,
28+ )
29+
1630
1731if __name__ == '__main__' :
1832 unittest .main ()
Original file line number Diff line number Diff line change 1+ # -*- coding: utf-8 -*-
2+ # Copyright 2015-TODAY LasLabs Inc.
3+ # License MIT (https://opensource.org/licenses/MIT).
4+
5+ import unittest
6+ from sqlalchemy .schema import Table
7+ from carepoint .tests .db .db import DatabaseTest
8+ from carepoint .models .address_mixin import AddressMixin , EnumAddressType
9+
10+
11+ class TestAddressMixin (DatabaseTest ):
12+
13+ def setUp (self ):
14+ super (TestAddressMixin , self ).setUp ()
15+ self .type_cn = 2
16+ self .obj = AddressMixin ()
17+ self .obj .addr_type_cn = self .type_cn
18+
19+ def test_addr_type (self ):
20+ """ It should return proper Enum for type cn """
21+ self .assertEqual (
22+ EnumAddressType (self .type_cn ),
23+ self .obj .addr_type ,
24+ )
25+
26+
27+ if __name__ == '__main__' :
28+ unittest .main ()
Original file line number Diff line number Diff line change 1+ # -*- coding: utf-8 -*-
2+ # Copyright 2015-TODAY LasLabs Inc.
3+ # License MIT (https://opensource.org/licenses/MIT).
4+
5+ import unittest
6+ from sqlalchemy .schema import Table
7+ from carepoint .tests .db .db import DatabaseTest
8+ from carepoint .models .phone_mixin import PhoneMixin , EnumPhoneType
9+
10+
11+ class TestPhoneMixin (DatabaseTest ):
12+
13+ def setUp (self ):
14+ super (TestPhoneMixin , self ).setUp ()
15+ self .type_cn = 2
16+ self .obj = PhoneMixin ()
17+ self .obj .phone_type_cn = self .type_cn
18+
19+ def test_addr_type (self ):
20+ """ It should return proper Enum for type cn """
21+ self .assertEqual (
22+ EnumPhoneType (self .type_cn ),
23+ self .obj .phone_type ,
24+ )
25+
26+
27+ if __name__ == '__main__' :
28+ unittest .main ()
Original file line number Diff line number Diff line change 99
1010setup_vals = {
1111 'name' : 'carepoint' ,
12- 'version' : '0.1.4 ' ,
12+ 'version' : '0.1.5 ' ,
1313 'author' : 'LasLabs Inc.' ,
1414 'author_email' : 'support@laslabs.com' ,
1515 'description' : 'This library will allow you to interact with CarePoint '
You can’t perform that action at this time.
0 commit comments