File tree 10 files changed +110
-13
lines changed
10 files changed +110
-13
lines changed Original file line number Diff line number Diff line change 8
8
Integer ,
9
9
DateTime ,
10
10
ForeignKey ,
11
- Enum ,
12
11
)
12
+ from sqlalchemy .types import Enum
13
13
from sqlalchemy .ext .declarative import declared_attr
14
14
15
15
@@ -29,9 +29,7 @@ class AddressMixin(object):
29
29
""" This is a mixin for Address Many2Many bindings """
30
30
31
31
priority = Column (Integer )
32
- addr_type_cn = Column (
33
- Enum (EnumAddressType ),
34
- )
32
+ addr_type_cn = Column (Integer )
35
33
app_flags = Column (Integer )
36
34
timestmp = Column (DateTime )
37
35
@@ -42,3 +40,7 @@ def addr_id(cls):
42
40
ForeignKey ('csaddr.addr_id' ),
43
41
primary_key = True ,
44
42
)
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):
28
28
acct_id = Column (Integer )
29
29
invoice_nbr = Column (Integer )
30
30
order_state_cn = Column (
31
- Enum ( EnumOrderState ) ,
31
+ Integer ,
32
32
ForeignKey ('CsOmStatus.state_cn' )
33
33
)
34
34
order_status_cn = Column (
@@ -88,3 +88,7 @@ class Order(Carepoint.BASE):
88
88
ForeignKey ('csuser.user_id' ),
89
89
)
90
90
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):
22
22
autoincrement = False ,
23
23
)
24
24
state_cn = Column (
25
- Enum ( EnumOrderState )
25
+ Integer ,
26
26
)
27
27
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 8
8
Integer ,
9
9
DateTime ,
10
10
ForeignKey ,
11
- Enum ,
12
11
)
12
+ from sqlalchemy .types import Enum
13
13
from sqlalchemy .ext .declarative import declared_attr
14
14
15
15
@@ -33,9 +33,7 @@ class PhoneMixin(object):
33
33
""" This is a mixin for Phone Many2Many bindings """
34
34
35
35
priority = Column (Integer )
36
- phone_type_cn = Column (
37
- Enum (EnumPhoneType ),
38
- )
36
+ phone_type_cn = Column (Integer )
39
37
app_flags = Column (Integer )
40
38
timestmp = Column (DateTime )
41
39
@@ -46,3 +44,7 @@ def phone_id(cls):
46
44
ForeignKey ('csphone.phone_id' ),
47
45
primary_key = True ,
48
46
)
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):
18
18
hasattr (DoctorAddress , 'addr_id' )
19
19
)
20
20
21
+
21
22
if __name__ == '__main__' :
22
23
unittest .main ()
Original file line number Diff line number Diff line change 5
5
import unittest
6
6
from sqlalchemy .schema import Table
7
7
from carepoint .tests .db .db import DatabaseTest
8
- from carepoint .models .cph .order import Order
8
+ from carepoint .models .cph .order import Order , EnumOrderState
9
9
10
10
11
11
class TestModelsCphOrder (DatabaseTest ):
12
12
13
13
def test_table_initialization (self , ):
14
14
self .assertIsInstance (Order .__table__ , Table )
15
15
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
+
16
30
17
31
if __name__ == '__main__' :
18
32
unittest .main ()
Original file line number Diff line number Diff line change 5
5
import unittest
6
6
from sqlalchemy .schema import Table
7
7
from 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
9
9
10
10
11
11
class TestModelsCphOrderStatus (DatabaseTest ):
12
12
13
13
def test_table_initialization (self , ):
14
14
self .assertIsInstance (OrderStatus .__table__ , Table )
15
15
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
+
16
30
17
31
if __name__ == '__main__' :
18
32
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 9
9
10
10
setup_vals = {
11
11
'name' : 'carepoint' ,
12
- 'version' : '0.1.4 ' ,
12
+ 'version' : '0.1.5 ' ,
13
13
'author' : 'LasLabs Inc.' ,
14
14
'author_email' :
'[email protected] ' ,
15
15
'description' : 'This library will allow you to interact with CarePoint '
You can’t perform that action at this time.
0 commit comments