Skip to content

Commit fcbc49d

Browse files
author
Ted S
authored
Merge pull request #24 from laslabs/feature/0.1/user-type-enum
[ADD] Support for user types
2 parents 6e16122 + a498bb2 commit fcbc49d

3 files changed

Lines changed: 30 additions & 2 deletions

File tree

carepoint/models/cph/user.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Copyright 2015-TODAY LasLabs Inc.
33
# License MIT (https://opensource.org/licenses/MIT).
44

5+
import enum
6+
57
from carepoint import Carepoint
68
from sqlalchemy import (Column,
79
Integer,
@@ -12,6 +14,14 @@
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+
1525
class 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)

carepoint/tests/models/cph/test_user.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,28 @@
55
import unittest
66
from sqlalchemy.schema import Table
77
from 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

1111
class 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

1731
if __name__ == '__main__':
1832
unittest.main()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
setup_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 '

0 commit comments

Comments
 (0)