Skip to content

Commit daf0756

Browse files
author
Matt Sokoloff
committed
recommended changes
1 parent 1b76fc1 commit daf0756

File tree

3 files changed

+21
-26
lines changed

3 files changed

+21
-26
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ test-local: build
1212
test-staging: build
1313
docker run -it -v ${PWD}:/usr/src -w /usr/src \
1414
-e LABELBOX_TEST_ENVIRON="staging" \
15-
-e LABELBOX_TEST_API_KEY_STAGING=${LLT} \
15+
-e LABELBOX_TEST_API_KEY_STAGING=${LABELBOX_TEST_API_KEY_STAGING} \
1616
local/labelbox-python:test pytest $(PATH_TO_TEST) -svvx
1717

1818
test-prod: build

labelbox/schema/iam_integration.py

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,20 @@
1-
from labelbox.utils import camel_case
2-
from pydantic import BaseModel
1+
from dataclasses import dataclass
32

3+
from labelbox.utils import snake_case
44
from labelbox.orm.db_object import DbObject
55
from labelbox.orm.model import Field
66

77

8-
9-
10-
11-
class AwsIamIntegrationSettings(BaseModel):
8+
@dataclass
9+
class AwsIamIntegrationSettings:
1210
role_arn: str
1311

14-
class Config:
15-
allow_population_by_field_name = True
16-
alias_generator = camel_case
17-
1812

19-
class GcpIamIntegrationSettings(BaseModel):
13+
@dataclass
14+
class GcpIamIntegrationSettings:
2015
service_account_email_id: str
2116
read_bucket: str
2217

23-
class Config:
24-
allow_population_by_field_name = True
25-
alias_generator = camel_case
26-
27-
2818

2919
class IAMIntegration(DbObject):
3020
""" Represents an IAM integration for delegated access
@@ -41,13 +31,18 @@ class IAMIntegration(DbObject):
4131
"""
4232

4333
def __init__(self, client, data):
44-
settings = data.pop('settings', {})
45-
type_name = settings.pop('__typename')
46-
if type_name == "GcpIamIntegrationSettings":
47-
self.settings = GcpIamIntegrationSettings(**settings)
48-
elif type_name == "AwsIamIntegrationSettings":
49-
self.settings = AwsIamIntegrationSettings(**settings)
50-
34+
settings = data.pop('settings', None)
35+
if settings is not None:
36+
type_name = settings.pop('__typename')
37+
settings = {snake_case(k): v for k, v in settings.items()}
38+
if type_name == "GcpIamIntegrationSettings":
39+
self.settings = GcpIamIntegrationSettings(**settings)
40+
elif type_name == "AwsIamIntegrationSettings":
41+
self.settings = AwsIamIntegrationSettings(**settings)
42+
else:
43+
self.settings = None
44+
else:
45+
self.settings = None
5146
super().__init__(client, data)
5247

5348
_DEFAULT = "DEFAULT"

tests/integration/test_delegated_access.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pytest
33

44

5-
#@pytest.mark.skip("Can only be tested in specific organizations.")
5+
@pytest.mark.skip("Can only be tested in specific organizations.")
66
def test_default_integration(client):
77
# This tests assumes the following:
88
# 1. gcp delegated access is configured to work with utkarsh-da-test-bucket
@@ -17,7 +17,7 @@ def test_default_integration(client):
1717
ds.delete()
1818

1919

20-
#@pytest.mark.skip("Can only be tested in specific organizations.")
20+
@pytest.mark.skip("Can only be tested in specific organizations.")
2121
def test_non_default_integration(client):
2222
# This tests assumes the following:
2323
# 1. aws delegated access is configured to work with lbox-test-bucket

0 commit comments

Comments
 (0)