From 153cd7fd4b0a5142f5c45eb4023b169605b7a94b Mon Sep 17 00:00:00 2001 From: Val Brodsky Date: Thu, 12 Dec 2024 13:29:05 -0800 Subject: [PATCH 1/2] Update invite tests (#1926) --- .../tests/integration/test_user_management.py | 51 ++++++++++++++----- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/libs/labelbox/tests/integration/test_user_management.py b/libs/labelbox/tests/integration/test_user_management.py index cfdf3c566..769ed5fa8 100644 --- a/libs/labelbox/tests/integration/test_user_management.py +++ b/libs/labelbox/tests/integration/test_user_management.py @@ -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"] @@ -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 @@ -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( @@ -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 From 97bd850aa5b61ed0f81cf4ea672c3bb21b1f054e Mon Sep 17 00:00:00 2001 From: Val Brodsky Date: Thu, 12 Dec 2024 16:58:40 -0800 Subject: [PATCH 2/2] Vb/prep 6.3.0 (#1928) --- docs/conf.py | 2 +- libs/labelbox/CHANGELOG.md | 8 ++++++++ libs/labelbox/pyproject.toml | 2 +- libs/labelbox/src/labelbox/__init__.py | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 1a28e549f..e1e65e074 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -16,7 +16,7 @@ project = 'Python SDK reference' copyright = '2024, Labelbox' author = 'Labelbox' -release = '6.2.0' +release = '6.3.0' # -- General configuration --------------------------------------------------- diff --git a/libs/labelbox/CHANGELOG.md b/libs/labelbox/CHANGELOG.md index abe477a8f..2aaac81b6 100644 --- a/libs/labelbox/CHANGELOG.md +++ b/libs/labelbox/CHANGELOG.md @@ -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)) diff --git a/libs/labelbox/pyproject.toml b/libs/labelbox/pyproject.toml index a4280fac0..110a422f6 100644 --- a/libs/labelbox/pyproject.toml +++ b/libs/labelbox/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "labelbox" -version = "6.2.0" +version = "6.3.0" description = "Labelbox Python API" authors = [{ name = "Labelbox", email = "engineering@labelbox.com" }] dependencies = [ diff --git a/libs/labelbox/src/labelbox/__init__.py b/libs/labelbox/src/labelbox/__init__.py index db5641432..8611a1456 100644 --- a/libs/labelbox/src/labelbox/__init__.py +++ b/libs/labelbox/src/labelbox/__init__.py @@ -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 (