Skip to content

Commit

Permalink
Merge branch 'develop' into PTDT-2863
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim-Kerr committed Dec 17, 2024
2 parents ac91b9a + 97bd850 commit acf4f18
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
project = 'Python SDK reference'
copyright = '2024, Labelbox'
author = 'Labelbox'
release = '6.2.0'
release = '6.3.0'

# -- General configuration ---------------------------------------------------

Expand Down
8 changes: 8 additions & 0 deletions libs/labelbox/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Changelog
# Version 6.3.0 (2024-12-12)
## Added
* Group member upload([#1924](https://github.com/Labelbox/labelbox-python/pull/1924))
* Group member export([#1925](https://github.com/Labelbox/labelbox-python/pull/1925))

## Note
* The `Invite` class no longer returns the invite ID (uid).

# Version 6.2.0 (2024-11-26)
## Added
* Prompt Issue ontology support([#1917](https://github.com/Labelbox/labelbox-python/pull/1917)), ([#1891](https://github.com/Labelbox/labelbox-python/pull/1891))
Expand Down
2 changes: 1 addition & 1 deletion libs/labelbox/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "labelbox"
version = "6.2.0"
version = "6.3.0"
description = "Labelbox Python API"
authors = [{ name = "Labelbox", email = "[email protected]" }]
dependencies = [
Expand Down
2 changes: 1 addition & 1 deletion libs/labelbox/src/labelbox/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "labelbox"

__version__ = "6.2.0"
__version__ = "6.3.0"

from labelbox.client import Client
from labelbox.schema.annotation_import import (
Expand Down
51 changes: 38 additions & 13 deletions libs/labelbox/tests/integration/test_user_management.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
from typing import Optional

import pytest
from faker import Faker

from labelbox import ProjectRole
from faker import Faker
from labelbox.schema.invite import Invite

faker = Faker()


def find_invite_and_id_by_email(
queries, client, invite_email
) -> Optional[Invite]:
"""For security reasons, invite uid is not returned for a query for a single invite.
This function is a workaround to find the invite uid by email using another query that returns all invites.
"""
outstanding_invites = queries.get_invites(client)

for outstanding_invite in outstanding_invites:
if outstanding_invite.email == invite_email:
return outstanding_invite
return None


@pytest.fixture
def org_invite(client, organization, environ, queries):
role = client.get_roles()["LABELER"]
Expand All @@ -27,7 +44,9 @@ def org_invite(client, organization, environ, queries):

yield invite, invite_limit

queries.cancel_invite(client, invite.uid)
found_invite = find_invite_and_id_by_email(queries, client, invite.email)
assert found_invite is not None, "Invite not found"
queries.cancel_invite(client, found_invite.uid)


@pytest.fixture
Expand Down Expand Up @@ -60,30 +79,32 @@ def create_project_invite(

yield invite

queries.cancel_invite(client, invite.uid)
found_invite = find_invite_and_id_by_email(queries, client, invite.email)
assert found_invite is not None, "Invite not found"
queries.cancel_invite(client, found_invite.uid)


def test_org_invite(client, organization, environ, queries, org_invite):
invite, invite_limit = org_invite
role = client.get_roles()["LABELER"]

assert (
invite.uid == "invited"
) # for security reasons we don't return the invite uid

if environ.value == "prod":
invite_limit_after = organization.invite_limit()
# One user added
assert invite_limit.remaining - invite_limit_after.remaining == 1
# An invite shouldn't effect the user count until after it is accepted

outstanding_invites = queries.get_invites(client)
in_list = False
found_invite = find_invite_and_id_by_email(queries, client, invite.email)

for outstanding_invite in outstanding_invites:
if outstanding_invite.uid == invite.uid:
in_list = True
org_role = outstanding_invite.organization_role_name.lower()
assert (
org_role == role.name.lower()
), "Role should be labeler. Found {org_role} "
assert in_list, "Invite not found"
assert found_invite is not None, "Invite not found"
org_role = found_invite.organization_role_name.lower()
assert (
org_role == role.name.lower()
), "Role should be labeler. Found {org_role} "


def test_cancel_invite(
Expand All @@ -96,6 +117,10 @@ def test_cancel_invite(
"".join(faker.random_letters(26))
)
invite = organization.invite_user(dummy_email, role)
found_invite = find_invite_and_id_by_email(queries, client, invite.email)
assert found_invite is not None, "Invite not found"
invite.uid = found_invite.uid # for security reasons we don't return the invite uid directly but need it in order to cancel the invite

queries.cancel_invite(client, invite.uid)
outstanding_invites = [i.uid for i in queries.get_invites(client)]
assert invite.uid not in outstanding_invites
Expand Down

0 comments on commit acf4f18

Please sign in to comment.