Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
93 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import unittest | ||
import openmrsapi | ||
|
||
class TestUser(unittest.TestCase): | ||
def setUp(self): | ||
self.created_user_uuids = list() | ||
|
||
def tearDown(self): | ||
for uuid in self.created_user_uuids: | ||
openmrsapi.user.remove(uuid) | ||
|
||
def test_create(self): | ||
new_user = openmrsapi.user.add( | ||
'openmrsapi-createtest', | ||
'Openmrsapi123', | ||
first_name='Openmrsapi', | ||
last_name='CreateTest', | ||
role='Organizational: Doctor', | ||
gender='M' | ||
) | ||
|
||
assert 'uuid' in new_user | ||
self.created_user_uuids.append(new_user['uuid']) | ||
|
||
def test_delete(self): | ||
new_user = openmrsapi.user.add( | ||
'openmrsapi-deletetest', | ||
'Openmrsapi123', | ||
first_name='Openmrsapi', | ||
last_name='DeleteTest', | ||
role='Organizational: Doctor', | ||
gender='M' | ||
) | ||
|
||
res = openmrsapi.user.remove(new_user['uuid']) | ||
assert len(res) == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import requests | ||
import openmrsapi | ||
import json | ||
|
||
|
||
def add( | ||
username, | ||
password, | ||
first_name='', | ||
middle_name='', | ||
last_name='', | ||
force_pass_change=False, | ||
role='', | ||
gender='', | ||
provider_account=True, | ||
person_uuid=''): | ||
""" | ||
Adds a user, as well as a person for that user if 'person_uuid' not specified | ||
:param username: A username for the user | ||
:type username: str | ||
:param password: A password for the user | ||
:type password: str | ||
:param first_name: User's first name (not used if person_uuid specified) | ||
:type first_name: str | ||
:param middle_name: User's middle name (not used if person_uuid specified) | ||
:type middle_name: str | ||
:param last_name: User's last name (not used if person_uuid specified) | ||
:type last_name: str | ||
:param force_pass_change: Whether or not to force a password change on first login | ||
:type force_pass_change: bool | ||
:param role: The user's role (must be the name of a valid openmrs role) | ||
:type role: str | ||
:param gender: The user's gender (must be one of 'M' or 'F'; other genders not supported in openmrs) | ||
:type gender: str | ||
:param provider_account: Whether or not the new account is a provider account | ||
:type provider_account: bool | ||
:param person_uuid: UUID of an existing person in the openmrs database | ||
:type person_uuid: str | ||
:rtype: dict | ||
:return: The new user's data (guaranteed to contain uuid) | ||
""" | ||
pass | ||
|
||
|
||
def remove(uuid): | ||
""" | ||
Removes a user as well as the person backing that user | ||
:param uuid: UUID of user to be removed | ||
:type uuid: str | ||
:rtype: dict | ||
:return: Empty if successful, error information otherwise | ||
""" | ||
pass |