|
| 1 | +import json |
| 2 | +from requests import Response |
| 3 | + |
| 4 | +import pytest |
| 5 | + |
| 6 | +import workos |
| 7 | +from workos.portal import Portal |
| 8 | + |
| 9 | + |
| 10 | +class TestPortal(object): |
| 11 | + @pytest.fixture(autouse=True) |
| 12 | + def setup(self, set_api_key): |
| 13 | + self.portal = Portal() |
| 14 | + |
| 15 | + @pytest.fixture |
| 16 | + def mock_organizations(self): |
| 17 | + return { |
| 18 | + "object": "list", |
| 19 | + "data": [ |
| 20 | + { |
| 21 | + "object": "organization", |
| 22 | + "id": "org_01EHQMYV6MBK39QC5PZXHY59C3", |
| 23 | + "name": "example.com", |
| 24 | + "domains": [ |
| 25 | + { |
| 26 | + "object": "organization_domain", |
| 27 | + "id": "org_domain_01EHQMYV71XT8H31WE5HF8YK4A", |
| 28 | + "domain": "example.com", |
| 29 | + } |
| 30 | + ], |
| 31 | + }, |
| 32 | + { |
| 33 | + "object": "organization", |
| 34 | + "id": "org_01EHQMVDTC2GRAHFCCRNTSKH46", |
| 35 | + "name": "example2.com", |
| 36 | + "domains": [ |
| 37 | + { |
| 38 | + "object": "organization_domain", |
| 39 | + "id": "org_domain_01EHQMVDTZVA27PK614ME4YK7V", |
| 40 | + "domain": "example2.com", |
| 41 | + } |
| 42 | + ], |
| 43 | + }, |
| 44 | + ], |
| 45 | + "listMetadata": {"before": "before-id", "after": None}, |
| 46 | + } |
| 47 | + |
| 48 | + def test_list_organizations(self, mock_organizations, mock_request_method): |
| 49 | + mock_response = Response() |
| 50 | + mock_response.status_code = 200 |
| 51 | + mock_response.response_dict = mock_organizations |
| 52 | + mock_request_method("get", mock_response, 200) |
| 53 | + response = self.portal.list_organizations() |
| 54 | + assert response.status_code == 200 |
| 55 | + assert len(response.response_dict["data"]) == 2 |
0 commit comments