Skip to content

Commit

Permalink
Remove domains and allowProfilesOutsideOrganization from Organization…
Browse files Browse the repository at this point in the history
… entity
  • Loading branch information
robframpton committed Nov 10, 2023
1 parent 2667837 commit 05a77e1
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 37 deletions.
22 changes: 2 additions & 20 deletions tests/test_organizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ def mock_organization_updated(self):
"name": "Example Organization",
"object": "organization",
"id": "org_01EHT88Z8J8795GZNQ4ZP1J81T",
"allow_profiles_outside_organization": True,
"domains": [
{
"domain": "example.io",
"object": "organization_domain",
"id": "org_domain_01EHT88Z8WZEFWYPM6EC9BX2R8",
}
],
}

@pytest.fixture
Expand Down Expand Up @@ -188,15 +180,15 @@ def test_get_organization(self, mock_organization, mock_request_method):
def test_create_organization(self, mock_organization, mock_request_method):
mock_request_method("post", mock_organization, 201)

payload = {"domains": ["example.com"], "name": "Test Organization"}
payload = {"name": "Test Organization"}
organization = self.organizations.create_organization(payload)

assert organization["id"] == "org_01EHT88Z8J8795GZNQ4ZP1J81T"
assert organization["name"] == "Foo Corporation"

def test_sends_idempotency_key(self, capture_and_mock_request):
idempotency_key = "test_123456789"
payload = {"domains": ["example.com"], "name": "Foo Corporation"}
payload = {"name": "Foo Corporation"}

_, request_kwargs = capture_and_mock_request("post", payload, 200)

Expand All @@ -213,20 +205,10 @@ def test_update_organization(self, mock_organization_updated, mock_request_metho
updated_organization = self.organizations.update_organization(
organization="org_01EHT88Z8J8795GZNQ4ZP1J81T",
name="Example Organization",
domains=["example.io"],
allow_profiles_outside_organization=True,
)

assert updated_organization["id"] == "org_01EHT88Z8J8795GZNQ4ZP1J81T"
assert updated_organization["name"] == "Example Organization"
assert updated_organization["domains"] == [
{
"domain": "example.io",
"object": "organization_domain",
"id": "org_domain_01EHT88Z8WZEFWYPM6EC9BX2R8",
}
]
assert updated_organization["allow_profiles_outside_organization"]

def test_delete_organization(self, setup, mock_raw_request_method):
mock_raw_request_method(
Expand Down
4 changes: 0 additions & 4 deletions tests/utils/fixtures/mock_organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,13 @@ def __init__(self, id):
self.id = id
self.object = "organization"
self.name = "Foo Corporation"
self.allow_profiles_outside_organization = False
self.created_at = datetime.datetime.now()
self.updated_at = datetime.datetime.now()
self.domains = ["domain1.com"]

OBJECT_FIELDS = [
"id",
"object",
"name",
"allow_profiles_outside_organization",
"created_at",
"updated_at",
"domains",
]
12 changes: 1 addition & 11 deletions workos/organizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,6 @@ def create_organization(self, organization, idempotency_key=None):
Args:
organization (dict) - An organization object
organization[name] (str) - A unique, descriptive name for the organization
organization[allow_profiles_outside_organization] (boolean) - Whether Connections
within the Organization allow profiles that are outside of the Organization's
configured User Email Domains. (Optional)
organization[domains] (list) - List of domains that belong to the organization
idempotency_key (str) - Idempotency key for creating an organization. (Optional)
Returns:
Expand All @@ -199,25 +195,19 @@ def create_organization(self, organization, idempotency_key=None):
return WorkOSOrganization.construct_from_response(response).to_dict()

def update_organization(
self, organization, name, allow_profiles_outside_organization=None, domains=None
self, organization, name
):
"""Update an organization
Args:
organization(str) - Organization's unique identifier.
name (str) - A unique, descriptive name for the organization.
allow_profiles_outside_organization (boolean) - Whether Connections
within the Organization allow profiles that are outside of the Organization's
configured User Email Domains. (Optional)
domains (list) - List of domains that belong to the organization. (Optional)
Returns:
dict: Updated Organization response from WorkOS.
"""
params = {
"name": name,
"domains": domains,
"allow_profiles_outside_organization": allow_profiles_outside_organization,
}
response = self.request_helper.request(
"organizations/{organization}".format(organization=organization),
Expand Down
2 changes: 0 additions & 2 deletions workos/resources/organizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ class WorkOSOrganization(WorkOSBaseResource):
"id",
"object",
"name",
"allow_profiles_outside_organization",
"created_at",
"updated_at",
"domains",
]

@classmethod
Expand Down

0 comments on commit 05a77e1

Please sign in to comment.