diff --git a/.oagen-manifest.json b/.oagen-manifest.json index 518993d7..1b3ee0e7 100644 --- a/.oagen-manifest.json +++ b/.oagen-manifest.json @@ -1,7 +1,7 @@ { - "version": 1, + "version": 2, "language": "python", - "generatedAt": "2026-04-22T22:10:13.399Z", + "generatedAt": "2026-04-23T15:27:42.321Z", "files": [ "src/workos/_client.py", "src/workos/admin_portal/__init__.py", @@ -814,6 +814,7 @@ "tests/fixtures/event_context_actor.json", "tests/fixtures/event_context_google_analytics_session.json", "tests/fixtures/event_list_list_metadata.json", + "tests/fixtures/event_schema.json", "tests/fixtures/external_auth_complete_response.json", "tests/fixtures/feature_flag.json", "tests/fixtures/feature_flag_owner.json", @@ -884,6 +885,7 @@ "tests/fixtures/list_directory.json", "tests/fixtures/list_directory_group.json", "tests/fixtures/list_directory_user_with_groups.json", + "tests/fixtures/list_event_schema.json", "tests/fixtures/list_flag.json", "tests/fixtures/list_organization.json", "tests/fixtures/list_role_assignment.json", diff --git a/src/workos/authorization/__init__.py b/src/workos/authorization/__init__.py index 467944e3..25484043 100644 --- a/src/workos/authorization/__init__.py +++ b/src/workos/authorization/__init__.py @@ -1,4 +1,13 @@ # This file is auto-generated by oagen. Do not edit. -from ._resource import Authorization, AsyncAuthorization +from ._resource import ( + Authorization, + AsyncAuthorization, + ResourceTargetById, + ResourceTargetByExternalId, + ParentResourceById, + ParentResourceByExternalId, + ParentById, + ParentByExternalId, +) from .models import * diff --git a/src/workos/user_management/__init__.py b/src/workos/user_management/__init__.py index d5269ca2..b77c4389 100644 --- a/src/workos/user_management/__init__.py +++ b/src/workos/user_management/__init__.py @@ -1,4 +1,11 @@ # This file is auto-generated by oagen. Do not edit. -from ._resource import UserManagement, AsyncUserManagement +from ._resource import ( + UserManagement, + AsyncUserManagement, + PasswordPlaintext, + PasswordHashed, + RoleSingle, + RoleMultiple, +) from .models import * diff --git a/tests/test_api_keys.py b/tests/test_api_keys.py index 17ef6e0c..e2a13dde 100644 --- a/tests/test_api_keys.py +++ b/tests/test_api_keys.py @@ -7,6 +7,7 @@ from tests.generated_helpers import load_fixture from workos.api_keys.models import ( + ApiKey, ApiKeyValidationResponse, ApiKeyWithValue, OrganizationsApiKeysOrder, @@ -49,7 +50,8 @@ def test_list_organization_api_keys(self, workos, httpx_mock): ) page = workos.api_keys.list_organization_api_keys("test_organizationId") assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], ApiKey) def test_list_organization_api_keys_empty_page(self, workos, httpx_mock): httpx_mock.add_response(json={"data": [], "list_metadata": {}}) @@ -190,7 +192,8 @@ async def test_list_organization_api_keys(self, async_workos, httpx_mock): "test_organizationId" ) assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], ApiKey) @pytest.mark.asyncio async def test_list_organization_api_keys_empty_page( diff --git a/tests/test_audit_logs.py b/tests/test_audit_logs.py index 9e328c1f..5bd6d3bc 100644 --- a/tests/test_audit_logs.py +++ b/tests/test_audit_logs.py @@ -7,6 +7,7 @@ from tests.generated_helpers import load_fixture from workos.audit_logs.models import ( + AuditLogActionJson, AuditLogEvent, AuditLogEventCreateResponse, AuditLogExportJson, @@ -58,7 +59,8 @@ def test_list_actions(self, workos, httpx_mock): ) page = workos.audit_logs.list_actions() assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], AuditLogActionJson) def test_list_actions_empty_page(self, workos, httpx_mock): httpx_mock.add_response(json={"data": [], "list_metadata": {}}) @@ -86,7 +88,8 @@ def test_list_action_schemas(self, workos, httpx_mock): ) page = workos.audit_logs.list_action_schemas("test_actionName") assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], AuditLogSchemaJson) def test_list_action_schemas_empty_page(self, workos, httpx_mock): httpx_mock.add_response(json={"data": [], "list_metadata": {}}) @@ -286,7 +289,8 @@ async def test_list_actions(self, async_workos, httpx_mock): httpx_mock.add_response(json=load_fixture("list_audit_log_action_json.json")) page = await async_workos.audit_logs.list_actions() assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], AuditLogActionJson) @pytest.mark.asyncio async def test_list_actions_empty_page(self, async_workos, httpx_mock): @@ -315,7 +319,8 @@ async def test_list_action_schemas(self, async_workos, httpx_mock): httpx_mock.add_response(json=load_fixture("list_audit_log_schema_json.json")) page = await async_workos.audit_logs.list_action_schemas("test_actionName") assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], AuditLogSchemaJson) @pytest.mark.asyncio async def test_list_action_schemas_empty_page(self, async_workos, httpx_mock): diff --git a/tests/test_authorization.py b/tests/test_authorization.py index 6049b2ff..2df6450f 100644 --- a/tests/test_authorization.py +++ b/tests/test_authorization.py @@ -14,6 +14,7 @@ Role, RoleAssignment, RoleList, + UserOrganizationMembershipBaseListData, AuthorizationAssignment, AuthorizationOrder, PermissionsOrder, @@ -64,7 +65,8 @@ def test_list_organization_membership_resources(self, workos, httpx_mock): permission_slug="test_permission_slug", ) assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], AuthorizationResource) def test_list_organization_membership_resources_empty_page( self, workos, httpx_mock @@ -111,7 +113,8 @@ def test_list_resource_permissions(self, workos, httpx_mock): "test_organization_membership_id", "test_resource_id" ) assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], AuthorizationPermission) def test_list_resource_permissions_empty_page(self, workos, httpx_mock): httpx_mock.add_response(json={"data": [], "list_metadata": {}}) @@ -147,7 +150,8 @@ def test_list_effective_permissions_by_external_id(self, workos, httpx_mock): "test_external_id", ) assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], AuthorizationPermission) def test_list_effective_permissions_by_external_id_empty_page( self, workos, httpx_mock @@ -188,7 +192,8 @@ def test_list_organization_membership_role_assignments(self, workos, httpx_mock) "test_organization_membership_id" ) assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], RoleAssignment) def test_list_organization_membership_role_assignments_empty_page( self, workos, httpx_mock @@ -457,7 +462,8 @@ def test_list_resource_organization_memberships(self, workos, httpx_mock): permission_slug="test_permission_slug", ) assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], UserOrganizationMembershipBaseListData) def test_list_resource_organization_memberships_empty_page( self, workos, httpx_mock @@ -503,7 +509,8 @@ def test_list_resources(self, workos, httpx_mock): parent=ParentById(parent_resource_id="test_value") ) assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], AuthorizationResource) def test_list_resources_empty_page(self, workos, httpx_mock): httpx_mock.add_response(json={"data": [], "list_metadata": {}}) @@ -611,7 +618,8 @@ def test_list_memberships_for_resource(self, workos, httpx_mock): "test_resource_id", permission_slug="test_permission_slug" ) assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], UserOrganizationMembershipBaseListData) def test_list_memberships_for_resource_empty_page(self, workos, httpx_mock): httpx_mock.add_response(json={"data": [], "list_metadata": {}}) @@ -732,7 +740,8 @@ def test_list_permissions(self, workos, httpx_mock): ) page = workos.authorization.list_permissions() assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], AuthorizationPermission) def test_list_permissions_empty_page(self, workos, httpx_mock): httpx_mock.add_response(json={"data": [], "list_metadata": {}}) @@ -934,7 +943,8 @@ async def test_list_organization_membership_resources( permission_slug="test_permission_slug", ) assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], AuthorizationResource) @pytest.mark.asyncio async def test_list_organization_membership_resources_empty_page( @@ -982,7 +992,8 @@ async def test_list_resource_permissions(self, async_workos, httpx_mock): "test_organization_membership_id", "test_resource_id" ) assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], AuthorizationPermission) @pytest.mark.asyncio async def test_list_resource_permissions_empty_page(self, async_workos, httpx_mock): @@ -1025,7 +1036,8 @@ async def test_list_effective_permissions_by_external_id( ) ) assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], AuthorizationPermission) @pytest.mark.asyncio async def test_list_effective_permissions_by_external_id_empty_page( @@ -1071,7 +1083,8 @@ async def test_list_organization_membership_role_assignments( "test_organization_membership_id" ) assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], RoleAssignment) @pytest.mark.asyncio async def test_list_organization_membership_role_assignments_empty_page( @@ -1338,7 +1351,8 @@ async def test_list_resource_organization_memberships( permission_slug="test_permission_slug", ) assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], UserOrganizationMembershipBaseListData) @pytest.mark.asyncio async def test_list_resource_organization_memberships_empty_page( @@ -1385,7 +1399,8 @@ async def test_list_resources(self, async_workos, httpx_mock): parent=ParentById(parent_resource_id="test_value") ) assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], AuthorizationResource) @pytest.mark.asyncio async def test_list_resources_empty_page(self, async_workos, httpx_mock): @@ -1492,7 +1507,8 @@ async def test_list_memberships_for_resource(self, async_workos, httpx_mock): "test_resource_id", permission_slug="test_permission_slug" ) assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], UserOrganizationMembershipBaseListData) @pytest.mark.asyncio async def test_list_memberships_for_resource_empty_page( @@ -1603,7 +1619,8 @@ async def test_list_permissions(self, async_workos, httpx_mock): httpx_mock.add_response(json=load_fixture("list_authorization_permission.json")) page = await async_workos.authorization.list_permissions() assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], AuthorizationPermission) @pytest.mark.asyncio async def test_list_permissions_empty_page(self, async_workos, httpx_mock): diff --git a/tests/test_connect.py b/tests/test_connect.py index 412253c7..64dbebd9 100644 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -52,7 +52,8 @@ def test_list_applications(self, workos, httpx_mock): ) page = workos.connect.list_applications() assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], ConnectApplication) def test_list_applications_empty_page(self, workos, httpx_mock): httpx_mock.add_response(json={"data": [], "list_metadata": {}}) @@ -295,7 +296,8 @@ async def test_list_applications(self, async_workos, httpx_mock): httpx_mock.add_response(json=load_fixture("list_connect_application.json")) page = await async_workos.connect.list_applications() assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], ConnectApplication) @pytest.mark.asyncio async def test_list_applications_empty_page(self, async_workos, httpx_mock): diff --git a/tests/test_directory_sync.py b/tests/test_directory_sync.py index 2c4ddde2..7dae6f98 100644 --- a/tests/test_directory_sync.py +++ b/tests/test_directory_sync.py @@ -31,7 +31,8 @@ def test_list_directories(self, workos, httpx_mock): ) page = workos.directory_sync.list_directories() assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], Directory) def test_list_directories_empty_page(self, workos, httpx_mock): httpx_mock.add_response(json={"data": [], "list_metadata": {}}) @@ -85,7 +86,8 @@ def test_list_groups(self, workos, httpx_mock): ) page = workos.directory_sync.list_groups() assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], DirectoryGroup) def test_list_groups_empty_page(self, workos, httpx_mock): httpx_mock.add_response(json={"data": [], "list_metadata": {}}) @@ -129,7 +131,8 @@ def test_list_users(self, workos, httpx_mock): ) page = workos.directory_sync.list_users() assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], DirectoryUserWithGroups) def test_list_users_empty_page(self, workos, httpx_mock): httpx_mock.add_response(json={"data": [], "list_metadata": {}}) @@ -249,7 +252,8 @@ async def test_list_directories(self, async_workos, httpx_mock): httpx_mock.add_response(json=load_fixture("list_directory.json")) page = await async_workos.directory_sync.list_directories() assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], Directory) @pytest.mark.asyncio async def test_list_directories_empty_page(self, async_workos, httpx_mock): @@ -306,7 +310,8 @@ async def test_list_groups(self, async_workos, httpx_mock): httpx_mock.add_response(json=load_fixture("list_directory_group.json")) page = await async_workos.directory_sync.list_groups() assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], DirectoryGroup) @pytest.mark.asyncio async def test_list_groups_empty_page(self, async_workos, httpx_mock): @@ -352,7 +357,8 @@ async def test_list_users(self, async_workos, httpx_mock): ) page = await async_workos.directory_sync.list_users() assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], DirectoryUserWithGroups) @pytest.mark.asyncio async def test_list_users_empty_page(self, async_workos, httpx_mock): diff --git a/tests/test_events.py b/tests/test_events.py index 387146f2..34b5be84 100644 --- a/tests/test_events.py +++ b/tests/test_events.py @@ -5,7 +5,7 @@ from workos import WorkOSClient, AsyncWorkOSClient from tests.generated_helpers import load_fixture -from workos.common.models import ActionAuthenticationDenied +from workos.common.models import DsyncUserCreated from workos.events.models import EventsOrder from workos._pagination import AsyncPage, SyncPage from workos._errors import ( @@ -21,15 +21,18 @@ class TestEvents: def test_list_events(self, workos, httpx_mock): httpx_mock.add_response( - json={ - "data": [load_fixture("action_authentication_denied.json")], - "list_metadata": {}, - }, + json=load_fixture("list_event_schema.json"), ) page = workos.events.list_events() assert isinstance(page, SyncPage) assert len(page.data) == 1 - assert isinstance(page.data[0], ActionAuthenticationDenied) + assert isinstance(page.data[0], DsyncUserCreated) + + def test_list_events_empty_page(self, workos, httpx_mock): + httpx_mock.add_response(json={"data": [], "list_metadata": {}}) + page = workos.events.list_events() + assert isinstance(page, SyncPage) + assert page.data == [] def test_list_events_encodes_query_params(self, workos, httpx_mock): httpx_mock.add_response(json={"data": [], "list_metadata": {}}) @@ -132,16 +135,18 @@ def test_list_events_unprocessable(self, httpx_mock): class TestAsyncEvents: @pytest.mark.asyncio async def test_list_events(self, async_workos, httpx_mock): - httpx_mock.add_response( - json={ - "data": [load_fixture("action_authentication_denied.json")], - "list_metadata": {}, - }, - ) + httpx_mock.add_response(json=load_fixture("list_event_schema.json")) page = await async_workos.events.list_events() assert isinstance(page, AsyncPage) assert len(page.data) == 1 - assert isinstance(page.data[0], ActionAuthenticationDenied) + assert isinstance(page.data[0], DsyncUserCreated) + + @pytest.mark.asyncio + async def test_list_events_empty_page(self, async_workos, httpx_mock): + httpx_mock.add_response(json={"data": [], "list_metadata": {}}) + page = await async_workos.events.list_events() + assert isinstance(page, AsyncPage) + assert page.data == [] @pytest.mark.asyncio async def test_list_events_encodes_query_params(self, async_workos, httpx_mock): diff --git a/tests/test_feature_flags.py b/tests/test_feature_flags.py index 525daacf..6f8ef66b 100644 --- a/tests/test_feature_flags.py +++ b/tests/test_feature_flags.py @@ -30,7 +30,8 @@ def test_list_feature_flags(self, workos, httpx_mock): ) page = workos.feature_flags.list_feature_flags() assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], Flag) def test_list_feature_flags_empty_page(self, workos, httpx_mock): httpx_mock.add_response(json={"data": [], "list_metadata": {}}) @@ -115,7 +116,8 @@ def test_list_organization_feature_flags(self, workos, httpx_mock): "test_organizationId" ) assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], Flag) def test_list_organization_feature_flags_empty_page(self, workos, httpx_mock): httpx_mock.add_response(json={"data": [], "list_metadata": {}}) @@ -148,7 +150,8 @@ def test_list_user_feature_flags(self, workos, httpx_mock): ) page = workos.feature_flags.list_user_feature_flags("test_userId") assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], Flag) def test_list_user_feature_flags_empty_page(self, workos, httpx_mock): httpx_mock.add_response(json={"data": [], "list_metadata": {}}) @@ -253,7 +256,8 @@ async def test_list_feature_flags(self, async_workos, httpx_mock): httpx_mock.add_response(json=load_fixture("list_flag.json")) page = await async_workos.feature_flags.list_feature_flags() assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], Flag) @pytest.mark.asyncio async def test_list_feature_flags_empty_page(self, async_workos, httpx_mock): @@ -342,7 +346,8 @@ async def test_list_organization_feature_flags(self, async_workos, httpx_mock): "test_organizationId" ) assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], Flag) @pytest.mark.asyncio async def test_list_organization_feature_flags_empty_page( @@ -378,7 +383,8 @@ async def test_list_user_feature_flags(self, async_workos, httpx_mock): httpx_mock.add_response(json=load_fixture("list_flag.json")) page = await async_workos.feature_flags.list_user_feature_flags("test_userId") assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], Flag) @pytest.mark.asyncio async def test_list_user_feature_flags_empty_page(self, async_workos, httpx_mock): diff --git a/tests/test_multi_factor_auth.py b/tests/test_multi_factor_auth.py index b8a2efd9..146bfb41 100644 --- a/tests/test_multi_factor_auth.py +++ b/tests/test_multi_factor_auth.py @@ -94,7 +94,8 @@ def test_list_user_auth_factors(self, workos, httpx_mock): ) page = workos.multi_factor_auth.list_user_auth_factors("test_userlandUserId") assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], AuthenticationFactor) def test_list_user_auth_factors_empty_page(self, workos, httpx_mock): httpx_mock.add_response(json={"data": [], "list_metadata": {}}) @@ -281,7 +282,8 @@ async def test_list_user_auth_factors(self, async_workos, httpx_mock): "test_userlandUserId" ) assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], AuthenticationFactor) @pytest.mark.asyncio async def test_list_user_auth_factors_empty_page(self, async_workos, httpx_mock): diff --git a/tests/test_organizations.py b/tests/test_organizations.py index bb41b71a..9e300cbe 100644 --- a/tests/test_organizations.py +++ b/tests/test_organizations.py @@ -29,7 +29,8 @@ def test_list_organizations(self, workos, httpx_mock): ) page = workos.organizations.list_organizations() assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], Organization) def test_list_organizations_empty_page(self, workos, httpx_mock): httpx_mock.add_response(json={"data": [], "list_metadata": {}}) @@ -211,7 +212,8 @@ async def test_list_organizations(self, async_workos, httpx_mock): httpx_mock.add_response(json=load_fixture("list_organization.json")) page = await async_workos.organizations.list_organizations() assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], Organization) @pytest.mark.asyncio async def test_list_organizations_empty_page(self, async_workos, httpx_mock): diff --git a/tests/test_sso.py b/tests/test_sso.py index f26f3cbd..4f6903d7 100644 --- a/tests/test_sso.py +++ b/tests/test_sso.py @@ -32,7 +32,8 @@ def test_list_connections(self, workos, httpx_mock): ) page = workos.sso.list_connections() assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], Connection) def test_list_connections_empty_page(self, workos, httpx_mock): httpx_mock.add_response(json={"data": [], "list_metadata": {}}) @@ -220,7 +221,8 @@ async def test_list_connections(self, async_workos, httpx_mock): httpx_mock.add_response(json=load_fixture("list_connection.json")) page = await async_workos.sso.list_connections() assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], Connection) @pytest.mark.asyncio async def test_list_connections_empty_page(self, async_workos, httpx_mock): diff --git a/tests/test_user_management.py b/tests/test_user_management.py index 54640aa9..beb16bb5 100644 --- a/tests/test_user_management.py +++ b/tests/test_user_management.py @@ -8,6 +8,7 @@ from workos.user_management.models import ( AuthenticateResponse, + AuthorizedConnectApplicationListData, CORSOriginResponse, DeviceAuthorizationResponse, EmailChange, @@ -26,6 +27,7 @@ UserIdentitiesGetItem, UserInvite, UserOrganizationMembership, + UserSessionsListItem, VerifyEmailResponse, UserManagementInvitationsOrder, UserManagementOrganizationMembershipOrder, @@ -178,7 +180,8 @@ def test_list_users(self, workos, httpx_mock): ) page = workos.user_management.list_users() assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], User) def test_list_users_empty_page(self, workos, httpx_mock): httpx_mock.add_response(json={"data": [], "list_metadata": {}}) @@ -344,7 +347,8 @@ def test_list_sessions(self, workos, httpx_mock): ) page = workos.user_management.list_sessions("test_id") assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], UserSessionsListItem) def test_list_sessions_empty_page(self, workos, httpx_mock): httpx_mock.add_response(json={"data": [], "list_metadata": {}}) @@ -373,7 +377,8 @@ def test_list_invitations(self, workos, httpx_mock): ) page = workos.user_management.list_invitations() assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], UserInvite) def test_list_invitations_empty_page(self, workos, httpx_mock): httpx_mock.add_response(json={"data": [], "list_metadata": {}}) @@ -521,7 +526,8 @@ def test_list_organization_memberships(self, workos, httpx_mock): ) page = workos.user_management.list_organization_memberships() assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], UserOrganizationMembership) def test_list_organization_memberships_empty_page(self, workos, httpx_mock): httpx_mock.add_response(json={"data": [], "list_metadata": {}}) @@ -658,7 +664,8 @@ def test_list_user_authorized_applications(self, workos, httpx_mock): ) page = workos.user_management.list_user_authorized_applications("test_user_id") assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], AuthorizedConnectApplicationListData) def test_list_user_authorized_applications_empty_page(self, workos, httpx_mock): httpx_mock.add_response(json={"data": [], "list_metadata": {}}) @@ -986,7 +993,8 @@ async def test_list_users(self, async_workos, httpx_mock): httpx_mock.add_response(json=load_fixture("list_user.json")) page = await async_workos.user_management.list_users() assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], User) @pytest.mark.asyncio async def test_list_users_empty_page(self, async_workos, httpx_mock): @@ -1145,7 +1153,8 @@ async def test_list_sessions(self, async_workos, httpx_mock): httpx_mock.add_response(json=load_fixture("list_user_sessions_list_item.json")) page = await async_workos.user_management.list_sessions("test_id") assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], UserSessionsListItem) @pytest.mark.asyncio async def test_list_sessions_empty_page(self, async_workos, httpx_mock): @@ -1175,7 +1184,8 @@ async def test_list_invitations(self, async_workos, httpx_mock): httpx_mock.add_response(json=load_fixture("list_user_invite.json")) page = await async_workos.user_management.list_invitations() assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], UserInvite) @pytest.mark.asyncio async def test_list_invitations_empty_page(self, async_workos, httpx_mock): @@ -1319,7 +1329,8 @@ async def test_list_organization_memberships(self, async_workos, httpx_mock): ) page = await async_workos.user_management.list_organization_memberships() assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], UserOrganizationMembership) @pytest.mark.asyncio async def test_list_organization_memberships_empty_page( @@ -1461,7 +1472,8 @@ async def test_list_user_authorized_applications(self, async_workos, httpx_mock) "test_user_id" ) assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], AuthorizedConnectApplicationListData) @pytest.mark.asyncio async def test_list_user_authorized_applications_empty_page( diff --git a/tests/test_webhooks.py b/tests/test_webhooks.py index 08a4a6a1..8ebfee9a 100644 --- a/tests/test_webhooks.py +++ b/tests/test_webhooks.py @@ -25,7 +25,8 @@ def test_list_webhook_endpoints(self, workos, httpx_mock): ) page = workos.webhooks.list_webhook_endpoints() assert isinstance(page, SyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], WebhookEndpointJson) def test_list_webhook_endpoints_empty_page(self, workos, httpx_mock): httpx_mock.add_response(json={"data": [], "list_metadata": {}}) @@ -166,7 +167,8 @@ async def test_list_webhook_endpoints(self, async_workos, httpx_mock): httpx_mock.add_response(json=load_fixture("list_webhook_endpoint_json.json")) page = await async_workos.webhooks.list_webhook_endpoints() assert isinstance(page, AsyncPage) - assert isinstance(page.data, list) + assert len(page.data) == 1 + assert isinstance(page.data[0], WebhookEndpointJson) @pytest.mark.asyncio async def test_list_webhook_endpoints_empty_page(self, async_workos, httpx_mock):