File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22# Copyright 2015-TODAY LasLabs Inc.
33# License MIT (https://opensource.org/licenses/MIT).
44
5+ import enum
6+
57from carepoint import Carepoint
68from sqlalchemy import (Column ,
79 Integer ,
1214 )
1315
1416
17+ class EnumUserType (enum .Enum ):
18+ """ It provides PEP-0435 compliant Carepoint User Type Enumerable """
19+
20+ user = 'U'
21+ group = 'G'
22+ machine = 'M'
23+
24+
1525class User (Carepoint .BASE ):
1626 __tablename__ = 'csuser'
1727 __dbname__ = 'cph'
@@ -57,3 +67,7 @@ class User(Carepoint.BASE):
5767 ForeignKey ('csuser.user_id' ),
5868 )
5969 chg_date = Column (DateTime )
70+
71+ @property
72+ def user_type (self ):
73+ return EnumUserType (self .user_type_cd )
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 .user import User
8+ from carepoint .models .cph .user import EnumUserType , User
99
1010
1111class TestModelsCphUser (DatabaseTest ):
1212
13+ def new_record (self , type_cd = 'U' ):
14+ self .type_cd = type_cd
15+ obj = User ()
16+ obj .user_type_cd = type_cd
17+ return obj
18+
1319 def test_table_initialization (self , ):
1420 self .assertIsInstance (User .__table__ , Table )
1521
22+ def test_user_type (self ):
23+ """ It should return proper Enum for user type cd """
24+ obj = self .new_record ()
25+ self .assertEqual (
26+ obj .user_type ,
27+ EnumUserType (self .type_cd ),
28+ )
29+
1630
1731if __name__ == '__main__' :
1832 unittest .main ()
Original file line number Diff line number Diff line change 99
1010setup_vals = {
1111 'name' : 'carepoint' ,
12- 'version' : '0.1.7 ' ,
12+ 'version' : '0.1.8 ' ,
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