diff --git a/.fernignore b/.fernignore index 3ba4b4a3..27fee6f8 100644 --- a/.fernignore +++ b/.fernignore @@ -13,6 +13,8 @@ src/merge/core/query_encoder.py tests/integration/test_filestorage.py tests/integration/test_knowledgebase.py tests/integration/test_email.py +tests/integration/test_ticketing.py +tests/integration/test_chat.py tests/custom/test_expand_url_format.py tests/custom/test_environment_routing.py tests/custom/test_datetime_filters.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f017887a..042c47a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,6 +41,8 @@ jobs: SDK_TESTING_KEY_SECONDARY: ${{ secrets.SDK_TESTING_KEY_SECONDARY }} SDK_TESTING_KNOWLEDGEBASE_ACCOUNT_TOKEN: ${{ secrets.SDK_TESTING_KNOWLEDGEBASE_ACCOUNT_TOKEN }} SDK_TESTING_EMAIL_ACCOUNT_TOKEN: ${{ secrets.SDK_TESTING_EMAIL_ACCOUNT_TOKEN }} + SDK_TESTING_TICKETING_ACCOUNT_TOKEN: ${{ secrets.SDK_TESTING_TICKETING_ACCOUNT_TOKEN }} + SDK_TESTING_CHAT_ACCOUNT_TOKEN: ${{ secrets.SDK_TESTING_CHAT_ACCOUNT_TOKEN }} publish: needs: [compile, test] diff --git a/tests/integration/test_chat.py b/tests/integration/test_chat.py new file mode 100644 index 00000000..0f662b5c --- /dev/null +++ b/tests/integration/test_chat.py @@ -0,0 +1,184 @@ +import os +import pytest +from merge import Merge +from merge.resources.chat.resources.conversations.types.conversations_members_list_request_expand_item import ConversationsMembersListRequestExpandItem +from merge.resources.chat.resources.messages.types.messages_list_request_order_by import MessagesListRequestOrderBy +from merge.resources.chat.resources.messages.types.messages_replies_list_request_order_by import MessagesRepliesListRequestOrderBy + + +@pytest.fixture +def client(): + account_token = os.environ["SDK_TESTING_CHAT_ACCOUNT_TOKEN"] + api_key = os.environ["SDK_TESTING_KEY_SECONDARY"] + + return Merge( + account_token=account_token, + api_key=api_key, + ) + +def test_conversations_list(client): + response = client.chat.conversations.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_conversations_retrieve(client): + conversations_response = client.chat.conversations.list(page_size=1) + + if conversations_response.results: + conversation_id = conversations_response.results[0].id + conversation = client.chat.conversations.retrieve(id=conversation_id) + assert conversation is not None + assert conversation.id == conversation_id + +def test_conversations_retrieve_with_expand_members(client): + conversations_response = client.chat.conversations.list(page_size=1) + + if conversations_response.results: + conversation_id = conversations_response.results[0].id + conversation = client.chat.conversations.retrieve(id=conversation_id, expand="members") + assert conversation is not None + assert conversation.id == conversation_id + +def test_conversations_members_list(client): + conversations_response = client.chat.conversations.list(page_size=1) + + if conversations_response.results: + conversation_id = conversations_response.results[0].id + response = client.chat.conversations.members_list(conversation_id=conversation_id) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_conversations_members_list_with_expand_user(client): + conversations_response = client.chat.conversations.list(page_size=1) + + if conversations_response.results: + conversation_id = conversations_response.results[0].id + response = client.chat.conversations.members_list( + conversation_id=conversation_id, + expand=ConversationsMembersListRequestExpandItem.USER, + ) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_conversations_members_list_with_expand_group(client): + conversations_response = client.chat.conversations.list(page_size=1) + + if conversations_response.results: + conversation_id = conversations_response.results[0].id + response = client.chat.conversations.members_list( + conversation_id=conversation_id, + expand=ConversationsMembersListRequestExpandItem.GROUP, + ) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_messages_list(client): + response = client.chat.messages.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_messages_retrieve(client): + messages_response = client.chat.messages.list(page_size=1) + + if messages_response.results: + message_id = messages_response.results[0].id + message = client.chat.messages.retrieve(id=message_id) + assert message is not None + assert message.id == message_id + +def test_messages_list_with_order_by_remote_created_at(client): + response = client.chat.messages.list(order_by=MessagesListRequestOrderBy.REMOTE_CREATED_AT_ASCENDING) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_messages_list_with_order_by_remote_created_at_descending(client): + response = client.chat.messages.list(order_by=MessagesListRequestOrderBy.REMOTE_CREATED_AT_DESCENDING) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_messages_list_with_root_message_true(client): + response = client.chat.messages.list(root_message="true") + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_messages_replies_list(client): + messages_response = client.chat.messages.list(page_size=1) + + if messages_response.results: + message_id = messages_response.results[0].id + response = client.chat.messages.replies_list(message_id=message_id) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_messages_replies_list_with_order_by(client): + messages_response = client.chat.messages.list(page_size=1) + + if messages_response.results: + message_id = messages_response.results[0].id + response = client.chat.messages.replies_list( + message_id=message_id, + order_by=MessagesRepliesListRequestOrderBy.REMOTE_CREATED_AT_ASCENDING, + ) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_users_list(client): + response = client.chat.users.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_groups_list(client): + response = client.chat.groups.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_sync_status_list(client): + response = client.chat.sync_status.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_account_details_retrieve(client): + account_details = client.chat.account_details.retrieve() + assert account_details is not None + assert hasattr(account_details, 'id') + +def test_audit_trail_list(client): + response = client.chat.audit_trail.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_available_actions_retrieve(client): + available_actions = client.chat.available_actions.retrieve() + + assert available_actions is not None + +def test_linked_accounts_list(client): + response = client.chat.linked_accounts.list() + + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_scopes_default_scopes_retrieve(client): + response = client.chat.scopes.default_scopes_retrieve() + + assert response is not None + +def test_scopes_linked_account_scopes_retrieve(client): + response = client.chat.scopes.linked_account_scopes_retrieve() + + assert response is not None diff --git a/tests/integration/test_ticketing.py b/tests/integration/test_ticketing.py new file mode 100644 index 00000000..59de8106 --- /dev/null +++ b/tests/integration/test_ticketing.py @@ -0,0 +1,288 @@ +import os +import pytest +from merge import Merge +from merge.resources.ticketing.resources.tickets.types.tickets_list_request_expand_item import TicketsListRequestExpandItem +from merge.resources.ticketing.resources.collections.types.collections_list_request_expand_item import CollectionsListRequestExpandItem +from merge.resources.ticketing.resources.comments.types.comments_list_request_expand_item import CommentsListRequestExpandItem +from merge.resources.ticketing.resources.users.types.users_list_request_expand_item import UsersListRequestExpandItem + + +@pytest.fixture +def client(): + account_token = os.environ["SDK_TESTING_TICKETING_ACCOUNT_TOKEN"] + api_key = os.environ["SDK_TESTING_KEY_SECONDARY"] + + return Merge( + account_token=account_token, + api_key=api_key, + ) + +def test_tickets_list(client): + response = client.ticketing.tickets.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_tickets_list_with_expand_assignees(client): + response = client.ticketing.tickets.list(expand=TicketsListRequestExpandItem.ASSIGNEES) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_tickets_list_with_expand_creator(client): + response = client.ticketing.tickets.list(expand=TicketsListRequestExpandItem.CREATOR) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_tickets_list_with_expand_collections(client): + response = client.ticketing.tickets.list(expand=TicketsListRequestExpandItem.COLLECTIONS) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_tickets_list_with_expand_attachments(client): + response = client.ticketing.tickets.list(expand=TicketsListRequestExpandItem.ATTACHMENTS) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_tickets_list_with_expand_account(client): + response = client.ticketing.tickets.list(expand=TicketsListRequestExpandItem.ACCOUNT) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_tickets_list_with_expand_contact(client): + response = client.ticketing.tickets.list(expand=TicketsListRequestExpandItem.CONTACT) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_tickets_list_with_expand_parent_ticket(client): + response = client.ticketing.tickets.list(expand=TicketsListRequestExpandItem.PARENT_TICKET) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_collections_list(client): + response = client.ticketing.collections.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_collections_list_with_expand_parent_collection(client): + response = client.ticketing.collections.list(expand=CollectionsListRequestExpandItem.PARENT_COLLECTION) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_collections_list_with_expand_permissions(client): + response = client.ticketing.collections.list(expand=CollectionsListRequestExpandItem.PERMISSIONS) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_comments_list(client): + response = client.ticketing.comments.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_comments_retrieve(client): + comments_response = client.ticketing.comments.list(page_size=1) + + if comments_response.results: + comment_id = comments_response.results[0].id + comment = client.ticketing.comments.retrieve(id=comment_id) + assert comment is not None + assert comment.id == comment_id + +def test_comments_list_with_expand_user(client): + response = client.ticketing.comments.list(expand=CommentsListRequestExpandItem.USER) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_comments_list_with_expand_ticket(client): + response = client.ticketing.comments.list(expand=CommentsListRequestExpandItem.TICKET) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_comments_list_with_expand_contact(client): + response = client.ticketing.comments.list(expand=CommentsListRequestExpandItem.CONTACT) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_projects_list(client): + response = client.ticketing.projects.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_projects_retrieve(client): + projects_response = client.ticketing.projects.list(page_size=1) + + if projects_response.results: + project_id = projects_response.results[0].id + project = client.ticketing.projects.retrieve(id=project_id) + assert project is not None + assert project.id == project_id + +def test_contacts_list(client): + response = client.ticketing.contacts.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_contacts_retrieve(client): + contacts_response = client.ticketing.contacts.list(page_size=1) + + if contacts_response.results: + contact_id = contacts_response.results[0].id + contact = client.ticketing.contacts.retrieve(id=contact_id) + assert contact is not None + assert contact.id == contact_id + +def test_users_list(client): + response = client.ticketing.users.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_users_retrieve(client): + users_response = client.ticketing.users.list(page_size=1) + + if users_response.results: + user_id = users_response.results[0].id + user = client.ticketing.users.retrieve(id=user_id) + assert user is not None + assert user.id == user_id + +def test_users_list_with_expand_roles(client): + response = client.ticketing.users.list(expand=UsersListRequestExpandItem.ROLES) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_users_list_with_expand_teams(client): + response = client.ticketing.users.list(expand=UsersListRequestExpandItem.TEAMS) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_teams_list(client): + response = client.ticketing.teams.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_teams_retrieve(client): + teams_response = client.ticketing.teams.list(page_size=1) + + if teams_response.results: + team_id = teams_response.results[0].id + team = client.ticketing.teams.retrieve(id=team_id) + assert team is not None + assert team.id == team_id + +def test_roles_list(client): + response = client.ticketing.roles.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_roles_retrieve(client): + roles_response = client.ticketing.roles.list(page_size=1) + + if roles_response.results: + role_id = roles_response.results[0].id + role = client.ticketing.roles.retrieve(id=role_id) + assert role is not None + assert role.id == role_id + +def test_tags_list(client): + response = client.ticketing.tags.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_tags_retrieve(client): + tags_response = client.ticketing.tags.list(page_size=1) + + if tags_response.results: + tag_id = tags_response.results[0].id + tag = client.ticketing.tags.retrieve(id=tag_id) + assert tag is not None + assert tag.id == tag_id + +def test_attachments_list(client): + response = client.ticketing.attachments.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_attachments_retrieve(client): + attachments_response = client.ticketing.attachments.list(page_size=1) + + if attachments_response.results: + attachment_id = attachments_response.results[0].id + attachment = client.ticketing.attachments.retrieve(id=attachment_id) + assert attachment is not None + assert attachment.id == attachment_id + +def test_accounts_list(client): + response = client.ticketing.accounts.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_accounts_retrieve(client): + accounts_response = client.ticketing.accounts.list(page_size=1) + + if accounts_response.results: + account_id = accounts_response.results[0].id + account = client.ticketing.accounts.retrieve(id=account_id) + assert account is not None + assert account.id == account_id + +def test_sync_status_list(client): + response = client.ticketing.sync_status.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_account_details_retrieve(client): + account_details = client.ticketing.account_details.retrieve() + assert account_details is not None + assert hasattr(account_details, 'id') + +def test_audit_trail_list(client): + response = client.ticketing.audit_trail.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_available_actions_retrieve(client): + available_actions = client.ticketing.available_actions.retrieve() + + assert available_actions is not None + +def test_linked_accounts_list(client): + response = client.ticketing.linked_accounts.list() + + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + +def test_scopes_default_scopes_retrieve(client): + response = client.ticketing.scopes.default_scopes_retrieve() + + assert response is not None + +def test_scopes_linked_account_scopes_retrieve(client): + response = client.ticketing.scopes.linked_account_scopes_retrieve() + + assert response is not None