Skip to content

Commit

Permalink
ENG-486: fix. add possibility to remove a user default credits (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
parikls authored Nov 30, 2024
1 parent e26c09d commit 8efddb4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
11 changes: 7 additions & 4 deletions neuro_admin_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ async def update_org_balance_by_delta(
async def update_org_defaults(
self,
org_name: str,
user_default_credits: Decimal,
user_default_credits: Decimal | None,
) -> Org: ...

# org user
Expand Down Expand Up @@ -1818,9 +1818,12 @@ async def update_org_balance_by_delta(
async def update_org_defaults(
self,
org_name: str,
user_default_credits: Decimal,
user_default_credits: Decimal | None,
) -> Org:
payload: dict[str, str] = {"credits": str(user_default_credits)}
credits = (
str(user_default_credits) if user_default_credits is not None else None
)
payload: dict[str, str | None] = {"credits": credits}
async with self._request(
"PATCH",
f"orgs/{org_name}/defaults",
Expand Down Expand Up @@ -3031,7 +3034,7 @@ async def update_org_balance_by_delta(
async def update_org_defaults(
self,
org_name: str,
default_credits: Decimal,
default_credits: Decimal | None,
) -> Org:
return self.DUMMY_ORG

Expand Down
8 changes: 8 additions & 0 deletions tests/test_admin_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,14 @@ async def test_patch_org_defaults(self, mock_admin_server: AdminServer) -> None:
assert org.user_default_credits == Decimal(200)
assert org == mock_admin_server.orgs[0]

# set defaults to `None`
org = await client.update_org_defaults(
org_name="org",
user_default_credits=None,
)
assert org.user_default_credits is None
assert org == mock_admin_server.orgs[0]

async def test_list_orgs(self, mock_admin_server: AdminServer) -> None:
mock_admin_server.orgs = [
Org(
Expand Down

0 comments on commit 8efddb4

Please sign in to comment.