|
3 | 3 | import pytest |
4 | 4 | from tests.types.test_auto_pagination_function import TestAutoPaginationFunction |
5 | 5 | from tests.utils.fixtures.mock_organization import MockOrganization |
| 6 | +from tests.utils.fixtures.mock_role import MockRole |
6 | 7 | from tests.utils.list_resource import list_response_of |
7 | 8 | from tests.utils.syncify import syncify |
8 | 9 | from workos.organizations import AsyncOrganizations, Organizations |
@@ -67,6 +68,13 @@ def mock_organizations_multiple_data_pages(self): |
67 | 68 | ] |
68 | 69 | return list_response_of(data=organizations_list) |
69 | 70 |
|
| 71 | + @pytest.fixture |
| 72 | + def mock_organization_roles(self): |
| 73 | + return { |
| 74 | + "data": [MockRole(id=str(i)).dict() for i in range(10)], |
| 75 | + "object": "list", |
| 76 | + } |
| 77 | + |
70 | 78 | def test_list_organizations( |
71 | 79 | self, mock_organizations, capture_and_mock_http_client_request |
72 | 80 | ): |
@@ -227,3 +235,28 @@ def test_list_organizations_auto_pagination_for_multiple_pages( |
227 | 235 | list_function=self.organizations.list_organizations, |
228 | 236 | expected_all_page_data=mock_organizations_multiple_data_pages["data"], |
229 | 237 | ) |
| 238 | + |
| 239 | + def test_list_organization_roles( |
| 240 | + self, mock_organization_roles, capture_and_mock_http_client_request |
| 241 | + ): |
| 242 | + request_kwargs = capture_and_mock_http_client_request( |
| 243 | + self.http_client, mock_organization_roles, 200 |
| 244 | + ) |
| 245 | + |
| 246 | + organization_roles_response = syncify( |
| 247 | + self.organizations.list_organization_roles( |
| 248 | + organization_id="org_01EHT88Z8J8795GZNQ4ZP1J81T" |
| 249 | + ) |
| 250 | + ) |
| 251 | + |
| 252 | + def to_dict(x): |
| 253 | + return x.dict() |
| 254 | + |
| 255 | + assert request_kwargs["method"] == "get" |
| 256 | + assert request_kwargs["url"].endswith( |
| 257 | + "/organizations/org_01EHT88Z8J8795GZNQ4ZP1J81T/roles" |
| 258 | + ) |
| 259 | + assert ( |
| 260 | + list(map(to_dict, organization_roles_response.data)) |
| 261 | + == mock_organization_roles["data"] |
| 262 | + ) |
0 commit comments