Skip to content

Commit

Permalink
Fix get_user, list_users, and delete_user methods (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
blairworkos authored Nov 15, 2023
1 parent 9c5b744 commit b53af30
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions tests/test_user_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def mock_users(self):
"list_metadata": {"before": None, "after": None},
"metadata": {
"params": {
"organization": None,
"organization_id": None,
"email": None,
"limit": None,
"before": None,
Expand All @@ -45,7 +45,7 @@ def mock_users_with_limit(self):
"metadata": {
"params": {
"type": None,
"organization": None,
"organization_id": None,
"email": None,
"limit": 4,
"before": None,
Expand All @@ -67,7 +67,7 @@ def mock_users_with_default_limit(self):
"metadata": {
"params": {
"type": None,
"organization": None,
"organization_id": None,
"email": None,
"limit": None,
"before": None,
Expand Down Expand Up @@ -143,7 +143,7 @@ def test_get_user(self, mock_user, capture_and_mock_request):

user = self.user_management.get_user("user_01H7ZGXFP5C6BBQY6Z7277ZCT0")

assert url[0].endswith("users/user_01H7ZGXFP5C6BBQY6Z7277ZCT0")
assert url[0].endswith("user_management/users/user_01H7ZGXFP5C6BBQY6Z7277ZCT0")
assert user["id"] == "user_01H7ZGXFP5C6BBQY6Z7277ZCT0"

def test_list_users_auto_pagination(
Expand Down Expand Up @@ -179,19 +179,19 @@ def test_list_users_returns_metadata(

users = self.user_management.list_users(
email="marcelina@foo-corp.com",
organization="foo-corp.com",
organization_id="org_12345",
)

dict_users = users.to_dict()
assert dict_users["metadata"]["params"]["email"] == "marcelina@foo-corp.com"
assert dict_users["metadata"]["params"]["organization"] == "foo-corp.com"
assert dict_users["metadata"]["params"]["organization_id"] == "org_12345"

def test_delete_user(self, capture_and_mock_request):
url, request_kwargs = capture_and_mock_request("delete", None, 200)

user = self.user_management.delete_user("user_01H7ZGXFP5C6BBQY6Z7277ZCT0")

assert url[0].endswith("users/user_01H7ZGXFP5C6BBQY6Z7277ZCT0")
assert url[0].endswith("user_management/users/user_01H7ZGXFP5C6BBQY6Z7277ZCT0")
assert user is None

def test_update_user(self, mock_user, capture_and_mock_request):
Expand Down
10 changes: 5 additions & 5 deletions workos/user_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
)
from workos.utils.validation import validate_settings, USER_MANAGEMENT_MODULE

USER_PATH = "users"
USER_DETAIL_PATH = "users/{0}"
USER_PATH = "user_management/users"
USER_DETAIL_PATH = "user_management/users/{0}"
USER_ORGANIZATION_PATH = "users/{0}/organization/{1}"
USER_PASSWORD_PATH = "users/{0}/password"
USER_AUTHENTICATE_PATH = "users/authenticate"
Expand Down Expand Up @@ -90,7 +90,7 @@ def get_user(self, user):
def list_users(
self,
email=None,
organization=None,
organization_id=None,
limit=None,
before=None,
after=None,
Expand All @@ -100,7 +100,7 @@ def list_users(
Kwargs:
email (str): Filter Users by their email. (Optional)
organization (list): Filter Users by the organization they are members of. (Optional)
organization_id (str): Filter Users by the organization they are members of. (Optional)
limit (int): Maximum number of records to return. (Optional)
before (str): Pagination cursor to receive records before a provided User ID. (Optional)
after (str): Pagination cursor to receive records after a provided User ID. (Optional)
Expand All @@ -118,7 +118,7 @@ def list_users(

params = {
"email": email,
"organization": organization,
"organization_id": organization_id,
"limit": limit,
"before": before,
"after": after,
Expand Down

0 comments on commit b53af30

Please sign in to comment.