Skip to content

Commit

Permalink
Merge 232e496 into 3133693
Browse files Browse the repository at this point in the history
  • Loading branch information
fanglinfang committed Jun 18, 2019
2 parents 3133693 + 232e496 commit 57ccf71
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# REST client for the UW HRP Web Service
# UW-RestClients-HRP

[![Build Status](https://api.travis-ci.org/uw-it-aca/uw-restclients-hrp.svg?branch=master)](https://travis-ci.org/uw-it-aca/uw-restclients-hrp)
[![Coverage Status](https://coveralls.io/repos/uw-it-aca/uw-restclients-hrp/badge.png?branch=master)](https://coveralls.io/r/uw-it-aca/uw-restclients-hrp?branch=master)

# uw-restclients-hrp
REST client for the UW HR/Payroll Web Service
Installation:

pip install UW-RestClients-HRP

To use this client, you'll need these settings in your application or script:

RESTCLIENTS_HRPWS_HOST='https://...'

Optional settings:

# Customizable parameters for urllib3
RESTCLIENTS_HRPWS_TIMEOUT=60
RESTCLIENTS_HRPWS_POOL_SIZE=10
4 changes: 4 additions & 0 deletions uw_hrp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ class WorkerPosition(models.Model):
is_future_date = models.BooleanField(default=False)
is_primary = models.BooleanField(default=False)
location = models.CharField(max_length=96, null=True, default=None)
payroll_unit_code = models.CharField(max_length=8,
null=True, default=None)
pos_type = models.CharField(max_length=64, null=True, default=None)
pos_time_type_id = models.CharField(max_length=64,
null=True, default=None)
Expand All @@ -134,6 +136,7 @@ def to_json(self):
'is_future_date': self.is_future_date,
'is_primary': self.is_primary,
'location': self.location,
'payroll_unit_code': self.payroll_unit_code,
'pos_type': self.pos_type,
'pos_time_type_id': self.pos_time_type_id,
'title': self.title,
Expand Down Expand Up @@ -164,6 +167,7 @@ def __init__(self, *args, **kwargs):

self.ecs_job_cla_code_desc = \
data.get("EcsJobClassificationCodeDescription")
self.payroll_unit_code = data.get("PayrollUnitCode")
self.is_future_date = data.get("IsFutureDate")
self.is_primary = data.get("IsPrimaryPosition")
if data.get("Location") is not None:
Expand Down
3 changes: 3 additions & 0 deletions uw_hrp/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def test_supervisory_organization(self):
self.assertIsNotNone(str(super_org))

def test_worker_position(self):
# self.maxDiff = None
pos = WorkerPosition()
self.assertIsNotNone(str(pos))
data = {
Expand Down Expand Up @@ -128,6 +129,7 @@ def test_worker_position(self):
'is_future_date': False,
"is_primary": True,
"location": "Seattle Campus",
"payroll_unit_code": "00702",
"pos_type": "Regular",
"pos_time_type_id": "Full_time",
"title": "Program Operations Specialist (E S 8)",
Expand Down Expand Up @@ -299,6 +301,7 @@ def test_worker(self):
'is_primary': True,
'job_profile': {'description': None, 'job_code': None},
'location': 'Bothell Campus',
'payroll_unit_code': '00356',
'pos_time_type_id': 'Full_time',
'pos_type': 'Regular',
'start_date': '2015-12-21 00:00:00+00:00',
Expand Down
3 changes: 3 additions & 0 deletions uw_hrp/tests/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def test_get_worker_by_netid(self):
get_worker_by_netid,
"")
worker = get_worker_by_netid("faculty")
# self.maxDiff = None
self.assertEqual(
worker.to_json(),
{"netid": "faculty",
Expand All @@ -41,6 +42,7 @@ def test_get_worker_by_netid(self):
'is_future_date': False,
"is_primary": True,
"location": "Seattle Campus",
"payroll_unit_code": "00753",
"pos_type": "Unpaid_Academic",
"pos_time_type_id": "Part_time",
"title": "Clinical Associate Professor",
Expand All @@ -62,6 +64,7 @@ def test_get_worker_by_netid(self):
'is_future_date': False,
"is_primary": True,
"location": "Seattle Campus",
'payroll_unit_code': '00753',
"pos_type": "Unpaid_Academic",
"pos_time_type_id": "Part_time",
"title": "Clinical Associate Professor",
Expand Down
8 changes: 4 additions & 4 deletions uw_hrp/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@
def get_worker_by_employee_id(employee_id, current_future=True):
if not PWS().valid_employee_id(employee_id):
raise InvalidEmployeeID(employee_id)
return _get_worker(employee_id, current_future=True)
return _get_worker(employee_id, current_future)


def get_worker_by_netid(netid, current_future=True):
if not PWS().valid_uwnetid(netid):
raise InvalidNetID(netid)
return _get_worker(netid, current_future=True)
return _get_worker(netid, current_future)


def get_worker_by_regid(regid, current_future=True):
if not PWS().valid_uwregid(regid):
raise InvalidRegID(regid)
return _get_worker(regid, current_future=True)
return _get_worker(regid, current_future)


def _get_worker(id, current_future=True):
def _get_worker(id, current_future):
"""
Return a restclients.models.hrp.WorkerPerson object
"""
Expand Down

0 comments on commit 57ccf71

Please sign in to comment.