Skip to content

Commit

Permalink
Merge pull request #258 from Crown-Commercial-Service/list-active
Browse files Browse the repository at this point in the history
Add support for listing active users
  • Loading branch information
bjgill authored Dec 17, 2021
2 parents 605affa + d3bc0c7 commit ee1ff5f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dmapiclient/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '23.0.0'
__version__ = '23.1.0'

from .errors import APIError, HTTPError, InvalidResponse # noqa
from .errors import REQUEST_ERROR_STATUS_CODE, REQUEST_ERROR_MESSAGE # noqa
Expand Down
3 changes: 3 additions & 0 deletions dmapiclient/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ def find_users(
personal_data_removed=None,
*,
user_research_opted_in=None,
active=None,
):
warnings.warn(
"The output of 'find_users' is paginated. Use 'find_users_iter' instead.",
Expand All @@ -410,6 +411,8 @@ def find_users(
params['personal_data_removed'] = personal_data_removed
if user_research_opted_in is not None:
params['user_research_opted_in'] = user_research_opted_in
if active is not None:
params['active'] = active
return self._get("/users", params=params)

find_users_iter = make_iter_method('find_users', 'users')
Expand Down
24 changes: 23 additions & 1 deletion tests/test_data_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def user():
'email_address': 'email_address',
'name': 'name',
'role': 'supplier',
'active': 'active',
'active': True,
'locked': False,
'created_at': "2015-05-05T05:05:05",
'updated_at': "2015-05-05T05:05:05",
Expand Down Expand Up @@ -297,6 +297,28 @@ def test_find_users_by_user_research_opted_in_true(self, data_client, rmock):

assert user == expected_data

def test_find_users_by_active_false(self, data_client, rmock):
rmock.get(
"http://baseurl/users?active=false",
json=self.user(),
status_code=200)
user = data_client.find_users(active=False)

assert user == self.user()

def test_find_users_by_active_true(self, data_client, rmock):
user = self.user()
user['users'].update({'active': True})
expected_data = user.copy()

rmock.get(
"http://baseurl/users?active=true",
json=user,
status_code=200)
user = data_client.find_users(active=True)

assert user == expected_data

def test_get_user_by_id(self, data_client, rmock):
rmock.get(
"http://baseurl/users/1234",
Expand Down

0 comments on commit ee1ff5f

Please sign in to comment.