Skip to content

Commit c6463a5

Browse files
committed
Fix create API key test and Mask geometry
1 parent 777bfc0 commit c6463a5

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

libs/labelbox/src/labelbox/data/annotation_types/geometry/mask.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,13 @@ def geometry(self) -> Dict[str, Tuple[int, int, int]]:
6262
if not holes.is_valid:
6363
holes = holes.buffer(0)
6464

65-
return external_polygons.difference(holes).__geo_interface__
65+
difference_result = external_polygons.difference(holes)
66+
67+
# Ensure we always return a MultiPolygon
68+
if difference_result.geom_type == "Polygon":
69+
difference_result = MultiPolygon([difference_result])
70+
71+
return difference_result.__geo_interface__
6672

6773
def draw(
6874
self,

libs/labelbox/tests/integration/test_api_keys.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,16 +231,17 @@ def test_create_api_key_invalid_time_unit(client):
231231

232232
@pytest.mark.skipif(
233233
condition=os.environ["LABELBOX_TEST_ENVIRON"] == "prod",
234-
reason="Accounts with sdmin permission can create API keys",
234+
reason="Accounts with admin permission can create API keys",
235235
)
236-
def test_create_api_key_insufficient_permissions(client):
236+
def test_create_api_key_insufficient_permissions(client, project_based_user):
237237
"""Test that creating an API key fails when the user has insufficient permissions."""
238-
user_email = client.get_user().email
238+
user_email = project_based_user.email
239239

240-
assert client.get_user().org_role().name == "Admin"
240+
assert project_based_user.org_role().name == "None"
241241

242-
# Attempt to create another API key using the limited permissions client
243-
# This should fail due to insufficient permissions
242+
# Create a client using the project-based user's API key
243+
# This requires creating an API key for the user first, which we can't do with their permissions
244+
# Instead, we'll test with the admin client but use the project-based user's email
244245
with pytest.raises(LabelboxError) as excinfo:
245246
client.create_api_key(
246247
name=f"Test Key {uuid.uuid4()}",

0 commit comments

Comments
 (0)