Skip to content

Commit 9853e88

Browse files
authored
Expose organizations on Client (#73)
* Expose `organizations` on `Client` * Add trailing comma * Fix test
1 parent 53c1136 commit 9853e88

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

tests/test_client.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class TestClient(object):
99
def setup(self):
1010
client._audit_trail = None
1111
client._directory_sync = None
12+
client._organizations = None
1213
client._passwordless = None
1314
client._portal = None
1415
client._sso = None
@@ -22,6 +23,9 @@ def test_initialize_audit_log(self, set_api_key):
2223
def test_initialize_directory_sync(self, set_api_key):
2324
assert bool(client.directory_sync)
2425

26+
def test_initialize_organizations(self, set_api_key):
27+
assert bool(client.organizations)
28+
2529
def test_initialize_passwordless(self, set_api_key):
2630
assert bool(client.passwordless)
2731

@@ -70,6 +74,14 @@ def test_initialize_directory_sync_missing_api_key(self):
7074

7175
assert "api_key" in message
7276

77+
def test_initialize_organizations_missing_api_key(self):
78+
with pytest.raises(ConfigurationException) as ex:
79+
client.organizations
80+
81+
message = str(ex)
82+
83+
assert "api_key" in message
84+
7385
def test_initialize_passwordless_missing_api_key(self):
7486
with pytest.raises(ConfigurationException) as ex:
7587
client.passwordless

workos/client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from workos.audit_trail import AuditTrail
22
from workos.directory_sync import DirectorySync
3+
from workos.organizations import Organizations
34
from workos.passwordless import Passwordless
45
from workos.portal import Portal
56
from workos.sso import SSO
@@ -26,6 +27,12 @@ def directory_sync(self):
2627
self._directory_sync = DirectorySync()
2728
return self._directory_sync
2829

30+
@property
31+
def organizations(self):
32+
if not getattr(self, "_organizations", None):
33+
self._organizations = Organizations()
34+
return self._organizations
35+
2936
@property
3037
def passwordless(self):
3138
if not getattr(self, "_passwordless", None):

workos/utils/validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
REQUIRED_SETTINGS_FOR_MODULE = {
1414
AUDIT_TRAIL_MODULE: ["api_key",],
1515
DIRECTORY_SYNC_MODULE: ["api_key",],
16-
ORGANIZATIONS_MODULE: ["api_key"],
16+
ORGANIZATIONS_MODULE: ["api_key",],
1717
PASSWORDLESS_MODULE: ["api_key",],
1818
PORTAL_MODULE: ["api_key",],
1919
SSO_MODULE: ["api_key", "client_id",],

0 commit comments

Comments
 (0)