@@ -12,6 +12,21 @@ class TestPortal(object):
1212 def setup (self , set_api_key ):
1313 self .portal = Portal ()
1414
15+ @pytest .fixture
16+ def mock_organization (self ):
17+ return {
18+ "name" : "Test Organization" ,
19+ "object" : "organization" ,
20+ "id" : "org_01EHT88Z8J8795GZNQ4ZP1J81T" ,
21+ "domains" : [
22+ {
23+ "domain" : "example.com" ,
24+ "object" : "organization_domain" ,
25+ "id" : "org_domain_01EHT88Z8WZEFWYPM6EC9BX2R8" ,
26+ }
27+ ],
28+ }
29+
1530 @pytest .fixture
1631 def mock_organizations (self ):
1732 return {
@@ -45,6 +60,19 @@ def mock_organizations(self):
4560 "listMetadata" : {"before" : "before-id" , "after" : None },
4661 }
4762
63+ def test_create_organization (self , mock_organization , mock_request_method ):
64+ organization = {"domains" : ["example.com" ], "name" : "Test Organization" }
65+ mock_response = Response ()
66+ mock_response .status_code = 201
67+ mock_response .response_dict = mock_organization
68+ mock_request_method ("post" , mock_response , 201 )
69+
70+ result = self .portal .create_organization (organization )
71+ subject = result .response_dict
72+
73+ assert subject ["id" ] == "org_01EHT88Z8J8795GZNQ4ZP1J81T"
74+ assert subject ["name" ] == "Test Organization"
75+
4876 def test_list_organizations (self , mock_organizations , mock_request_method ):
4977 mock_response = Response ()
5078 mock_response .status_code = 200
0 commit comments