Skip to content

Commit

Permalink
invite_to_organization: fix InvitationOrganizationJoinEmail ctor …
Browse files Browse the repository at this point in the history
…call (#637)

* `invite_to_organization`: fix `InvitationOrganizationJoinEmail` ctor call

[sc-54346]

* Add a test for the fix in gh-637

---------

Co-authored-by: Sean Gillies <[email protected]>
  • Loading branch information
ryan-williams and sgillies authored Sep 10, 2024
1 parent 7965f86 commit 77b3d6d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/tiledb/cloud/invites.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Sequence
from typing import Optional, Sequence

from tiledb.cloud import client
from tiledb.cloud import rest_api
Expand Down Expand Up @@ -54,7 +54,11 @@ def fetch_invitations(**filters):


def invite_to_organization(
organization: str, *, recipients: Sequence[str], role: str
organization: str,
*,
recipients: Sequence[str],
role: str,
actions: Optional[Sequence[str]] = None,
) -> None:
"""
Sends email to multiple recipients with joining information
Expand All @@ -63,10 +67,13 @@ def invite_to_organization(
:param organization: name or UUID of organization.
:param recipients: list of recipient emails/usernames.
:param role: role assigned to the recipient.
:param actions: an optional sequence of actions.
:return: None
"""
invitation_api = client.build(rest_api.InvitationApi)
email_invite = InvitationOrganizationJoinEmail(role, recipients)
email_invite = InvitationOrganizationJoinEmail(
actions=actions, organization_role=role, invitee_email=recipients
)
try:
return invitation_api.join_organization(organization, email_invite)
except rest_api.ApiException as exc:
Expand Down
14 changes: 14 additions & 0 deletions tests/test_invites.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""Test of invites."""

import unittest.mock

from tiledb.cloud import invites


@unittest.mock.patch("tiledb.cloud.invites.client")
def test_invite_to_organization(client):
"""Function is properly wired to low-level generated API."""
# This call used to raise a ValueError.
invites.invite_to_organization(
"test_org", recipients=["[email protected]"], role="read_only"
)

0 comments on commit 77b3d6d

Please sign in to comment.