diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1732f62e..feec5024 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,9 +36,16 @@ jobs: - name: Test run: poetry run pytest -rP . env: + SDK_TESTING_ACCOUNTING_ACCOUNT_TOKEN: ${{ secrets.SDK_TESTING_ACCOUNTING_ACCOUNT_TOKEN }} + SDK_TESTING_ATS_ACCOUNT_TOKEN: ${{ secrets.SDK_TESTING_ATS_ACCOUNT_TOKEN }} + SDK_TESTING_CHAT_ACCOUNT_TOKEN: ${{ secrets.SDK_TESTING_CHAT_ACCOUNT_TOKEN }} + SDK_TESTING_CRM_ACCOUNT_TOKEN: ${{ secrets.SDK_TESTING_CRM_ACCOUNT_TOKEN }} SDK_TESTING_FILE_STORAGE_ACCOUNT_TOKEN: ${{ secrets.SDK_TESTING_FILE_STORAGE_ACCOUNT_TOKEN }} + SDK_TESTING_HRIS_ACCOUNT_TOKEN: ${{ secrets.SDK_TESTING_HRIS_ACCOUNT_TOKEN }} SDK_TESTING_KEY: ${{ secrets.SDK_TESTING_KEY }} + SDK_TESTING_KEY_SECONDARY: ${{ secrets.SDK_TESTING_KEY_SECONDARY }} SDK_TESTING_KNOWLEDGEBASE_ACCOUNT_TOKEN: ${{ secrets.SDK_TESTING_KNOWLEDGEBASE_ACCOUNT_TOKEN }} + SDK_TESTING_TICKETING_ACCOUNT_TOKEN: ${{ secrets.SDK_TESTING_TICKETING_ACCOUNT_TOKEN }} publish: needs: [compile, test] diff --git a/tests/integration/test_accounting.py b/tests/integration/test_accounting.py new file mode 100644 index 00000000..e05dc8c3 --- /dev/null +++ b/tests/integration/test_accounting.py @@ -0,0 +1,455 @@ +import os +import pytest +from merge import Merge +from merge.resources.accounting.resources.contacts.types.contacts_list_request_expand import ContactsListRequestExpand +from merge.resources.accounting.resources.contacts.types.contacts_retrieve_request_expand import ContactsRetrieveRequestExpand +from merge.resources.accounting.resources.invoices.types.invoices_list_request_expand import InvoicesListRequestExpand +from merge.resources.accounting.resources.invoices.types.invoices_retrieve_request_expand import InvoicesRetrieveRequestExpand + + +@pytest.fixture +def client(): + account_token = os.environ["SDK_TESTING_ACCOUNTING_ACCOUNT_TOKEN"] + api_key = os.environ["SDK_TESTING_KEY_SECONDARY"] + + return Merge( + account_token=account_token, + api_key=api_key, + ) + + +def test_account_details_retrieve(client): + account_details = client.accounting.account_details.retrieve() + assert account_details is not None + assert hasattr(account_details, 'id') + + +def test_accounts_list(client): + response = client.accounting.accounts.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_accounts_retrieve(client): + accounts_response = client.accounting.accounts.list(page_size=1) + + if accounts_response.results: + account_id = accounts_response.results[0].id + account = client.accounting.accounts.retrieve(id=account_id) + assert account is not None + assert account.id == account_id + + +def test_attachments_list(client): + response = client.accounting.attachments.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_attachments_retrieve(client): + attachments_response = client.accounting.attachments.list(page_size=1) + + if attachments_response.results: + attachment_id = attachments_response.results[0].id + attachment = client.accounting.attachments.retrieve(id=attachment_id) + assert attachment is not None + assert attachment.id == attachment_id + + +def test_balance_sheets_list(client): + response = client.accounting.balance_sheets.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_balance_sheets_retrieve(client): + balance_sheets_response = client.accounting.balance_sheets.list(page_size=1) + + if balance_sheets_response.results: + balance_sheet_id = balance_sheets_response.results[0].id + balance_sheet = client.accounting.balance_sheets.retrieve(id=balance_sheet_id) + assert balance_sheet is not None + assert balance_sheet.id == balance_sheet_id + + +def test_vendor_credits_list(client): + response = client.accounting.vendor_credits.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_vendor_credits_retrieve(client): + vendor_credits_response = client.accounting.vendor_credits.list(page_size=1) + + if vendor_credits_response.results: + vendor_credit_id = vendor_credits_response.results[0].id + vendor_credit = client.accounting.vendor_credits.retrieve(id=vendor_credit_id) + assert vendor_credit is not None + assert vendor_credit.id == vendor_credit_id + + +def test_transactions_list(client): + response = client.accounting.transactions.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_transactions_retrieve(client): + transactions_response = client.accounting.transactions.list(page_size=1) + + if transactions_response.results: + transaction_id = transactions_response.results[0].id + transaction = client.accounting.transactions.retrieve(id=transaction_id) + assert transaction is not None + assert transaction.id == transaction_id + + +def test_tracking_categories_list(client): + response = client.accounting.tracking_categories.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_tracking_categories_retrieve(client): + tracking_categories_response = client.accounting.tracking_categories.list(page_size=1) + + if tracking_categories_response.results: + tracking_category_id = tracking_categories_response.results[0].id + tracking_category = client.accounting.tracking_categories.retrieve(id=tracking_category_id) + assert tracking_category is not None + assert tracking_category.id == tracking_category_id + + +def test_tax_rates_list(client): + response = client.accounting.tax_rates.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_tax_rates_retrieve(client): + tax_rates_response = client.accounting.tax_rates.list(page_size=1) + + if tax_rates_response.results: + tax_rate_id = tax_rates_response.results[0].id + tax_rate = client.accounting.tax_rates.retrieve(id=tax_rate_id) + assert tax_rate is not None + assert tax_rate.id == tax_rate_id + + +def test_purchase_orders_list(client): + response = client.accounting.purchase_orders.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_purchase_orders_retrieve(client): + purchase_orders_response = client.accounting.purchase_orders.list(page_size=1) + + if purchase_orders_response.results: + purchase_order_id = purchase_orders_response.results[0].id + purchase_order = client.accounting.purchase_orders.retrieve(id=purchase_order_id) + assert purchase_order is not None + assert purchase_order.id == purchase_order_id + + +def test_projects_list(client): + response = client.accounting.projects.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_projects_retrieve(client): + projects_response = client.accounting.projects.list(page_size=1) + + if projects_response.results: + project_id = projects_response.results[0].id + project = client.accounting.projects.retrieve(id=project_id) + assert project is not None + assert project.id == project_id + + +def test_payment_terms_list(client): + response = client.accounting.payment_terms.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_payment_terms_retrieve(client): + payment_terms_response = client.accounting.payment_terms.list(page_size=1) + + if payment_terms_response.results: + payment_term_id = payment_terms_response.results[0].id + payment_term = client.accounting.payment_terms.retrieve(id=payment_term_id) + assert payment_term is not None + assert payment_term.id == payment_term_id + + +def test_payment_methods_list(client): + response = client.accounting.payment_methods.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_payment_methods_retrieve(client): + payment_methods_response = client.accounting.payment_methods.list(page_size=1) + + if payment_methods_response.results: + payment_method_id = payment_methods_response.results[0].id + payment_method = client.accounting.payment_methods.retrieve(id=payment_method_id) + assert payment_method is not None + assert payment_method.id == payment_method_id + + +def test_payments_list(client): + response = client.accounting.payments.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_payments_retrieve(client): + payments_response = client.accounting.payments.list(page_size=1) + + if payments_response.results: + payment_id = payments_response.results[0].id + payment = client.accounting.payments.retrieve(id=payment_id) + assert payment is not None + assert payment.id == payment_id + + +def test_journal_entries_list(client): + response = client.accounting.journal_entries.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_journal_entries_retrieve(client): + journal_entries_response = client.accounting.journal_entries.list(page_size=1) + + if journal_entries_response.results: + journal_entry_id = journal_entries_response.results[0].id + journal_entry = client.accounting.journal_entries.retrieve(id=journal_entry_id) + assert journal_entry is not None + assert journal_entry.id == journal_entry_id + + +def test_items_list(client): + response = client.accounting.items.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_items_retrieve(client): + items_response = client.accounting.items.list(page_size=1) + + if items_response.results: + item_id = items_response.results[0].id + item = client.accounting.items.retrieve(id=item_id) + assert item is not None + assert item.id == item_id + + +def test_invoices_list(client): + response = client.accounting.invoices.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_invoices_retrieve(client): + invoices_response = client.accounting.invoices.list(page_size=1) + + if invoices_response.results: + invoice_id = invoices_response.results[0].id + invoice = client.accounting.invoices.retrieve(id=invoice_id) + assert invoice is not None + assert invoice.id == invoice_id + + +def test_income_statements_list(client): + response = client.accounting.income_statements.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_income_statements_retrieve(client): + income_statements_response = client.accounting.income_statements.list(page_size=1) + + if income_statements_response.results: + income_statement_id = income_statements_response.results[0].id + income_statement = client.accounting.income_statements.retrieve(id=income_statement_id) + assert income_statement is not None + assert income_statement.id == income_statement_id + + +def test_general_ledger_transactions_list(client): + response = client.accounting.general_ledger_transactions.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_general_ledger_transactions_retrieve(client): + general_ledger_transactions_response = client.accounting.general_ledger_transactions.list(page_size=1) + + if general_ledger_transactions_response.results: + general_ledger_transaction_id = general_ledger_transactions_response.results[0].id + general_ledger_transaction = client.accounting.general_ledger_transactions.retrieve(id=general_ledger_transaction_id) + assert general_ledger_transaction is not None + assert general_ledger_transaction.id == general_ledger_transaction_id + + +def test_expenses_list(client): + response = client.accounting.expenses.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_expenses_retrieve(client): + expenses_response = client.accounting.expenses.list(page_size=1) + + if expenses_response.results: + expense_id = expenses_response.results[0].id + expense = client.accounting.expenses.retrieve(id=expense_id) + assert expense is not None + assert expense.id == expense_id + + +def test_employees_list(client): + response = client.accounting.employees.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_employees_retrieve(client): + employees_response = client.accounting.employees.list(page_size=1) + + if employees_response.results: + employee_id = employees_response.results[0].id + employee = client.accounting.employees.retrieve(id=employee_id) + assert employee is not None + assert employee.id == employee_id + + +def test_credit_notes_list(client): + response = client.accounting.credit_notes.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_credit_notes_retrieve(client): + credit_notes_response = client.accounting.credit_notes.list(page_size=1) + + if credit_notes_response.results: + credit_note_id = credit_notes_response.results[0].id + credit_note = client.accounting.credit_notes.retrieve(id=credit_note_id) + assert credit_note is not None + assert credit_note.id == credit_note_id + + +def test_contacts_list(client): + response = client.accounting.contacts.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_contacts_retrieve(client): + contacts_response = client.accounting.contacts.list(page_size=1) + + if contacts_response.results: + contact_id = contacts_response.results[0].id + contact = client.accounting.contacts.retrieve(id=contact_id) + assert contact is not None + assert contact.id == contact_id + + +def test_company_info_list(client): + response = client.accounting.company_info.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_company_info_retrieve(client): + company_info_response = client.accounting.company_info.list(page_size=1) + + if company_info_response.results: + company_info_id = company_info_response.results[0].id + company_info = client.accounting.company_info.retrieve(id=company_info_id) + assert company_info is not None + assert company_info.id == company_info_id + + +def test_contacts_list_with_expand_addresses(client): + response = client.accounting.contacts.list(expand=ContactsListRequestExpand.ADDRESSES) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_contacts_list_with_expand_company(client): + response = client.accounting.contacts.list(expand=ContactsListRequestExpand.COMPANY) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_contacts_retrieve_with_expand_addresses(client): + contacts_response = client.accounting.contacts.list(page_size=1) + + if contacts_response.results: + contact_id = contacts_response.results[0].id + contact = client.accounting.contacts.retrieve(id=contact_id, expand=ContactsRetrieveRequestExpand.ADDRESSES) + assert contact is not None + assert contact.id == contact_id + + +def test_invoices_list_with_expand_line_items(client): + response = client.accounting.invoices.list(expand=InvoicesListRequestExpand.LINE_ITEMS) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_invoices_retrieve_with_expand_line_items(client): + invoices_response = client.accounting.invoices.list(page_size=1) + + if invoices_response.results: + invoice_id = invoices_response.results[0].id + invoice = client.accounting.invoices.retrieve(id=invoice_id, expand=InvoicesRetrieveRequestExpand.LINE_ITEMS) + assert invoice is not None + assert invoice.id == invoice_id + + +def test_contacts_list_with_expand_string(client): + response = client.accounting.contacts.list(expand="addresses") + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_invoices_list_with_expand_string(client): + response = client.accounting.invoices.list(expand="line_items") + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + diff --git a/tests/integration/test_chat.py b/tests/integration/test_chat.py new file mode 100644 index 00000000..096a3771 --- /dev/null +++ b/tests/integration/test_chat.py @@ -0,0 +1,104 @@ +import os +import pytest +from merge import Merge + + +@pytest.fixture +def client(): + account_token = os.environ["SDK_TESTING_CHAT_ACCOUNT_TOKEN"] + api_key = os.environ["SDK_TESTING_KEY"] + + return Merge( + account_token=account_token, + api_key=api_key, + ) + + +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_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_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_users_list(client): + response = client.chat.users.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_users_retrieve(client): + users_response = client.chat.users.list(page_size=1) + + if users_response.results: + user_id = users_response.results[0].id + user = client.chat.users.retrieve(id=user_id) + assert user is not None + assert user.id == user_id + + +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_groups_retrieve(client): + groups_response = client.chat.groups.list(page_size=1) + + if groups_response.results: + group_id = groups_response.results[0].id + group = client.chat.groups.retrieve(id=group_id) + assert group is not None + assert group.id == group_id + + +def test_conversations_list_with_expand_string(client): + response = client.chat.conversations.list(expand="members") + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_messages_list_with_expand_string(client): + response = client.chat.messages.list(expand="conversation") + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + diff --git a/tests/integration/test_crm.py b/tests/integration/test_crm.py new file mode 100644 index 00000000..19ad520c --- /dev/null +++ b/tests/integration/test_crm.py @@ -0,0 +1,244 @@ +import os +import pytest +from merge import Merge +from merge.resources.crm.resources.contacts.types.contacts_list_request_expand import ContactsListRequestExpand +from merge.resources.crm.resources.contacts.types.contacts_retrieve_request_expand import ContactsRetrieveRequestExpand +from merge.resources.crm.resources.opportunities.types.opportunities_list_request_expand import OpportunitiesListRequestExpand +from merge.resources.crm.resources.opportunities.types.opportunities_retrieve_request_expand import OpportunitiesRetrieveRequestExpand + + +@pytest.fixture +def client(): + account_token = os.environ["SDK_TESTING_CRM_ACCOUNT_TOKEN"] + api_key = os.environ["SDK_TESTING_KEY_SECONDARY"] + + return Merge( + account_token=account_token, + api_key=api_key, + ) + + +def test_account_details_retrieve(client): + account_details = client.crm.account_details.retrieve() + assert account_details is not None + assert hasattr(account_details, 'id') + + +def test_accounts_list(client): + response = client.crm.accounts.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_accounts_retrieve(client): + accounts_response = client.crm.accounts.list(page_size=1) + + if accounts_response.results: + account_id = accounts_response.results[0].id + account = client.crm.accounts.retrieve(id=account_id) + assert account is not None + assert account.id == account_id + + +def test_contacts_list(client): + response = client.crm.contacts.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_contacts_retrieve(client): + contacts_response = client.crm.contacts.list(page_size=1) + + if contacts_response.results: + contact_id = contacts_response.results[0].id + contact = client.crm.contacts.retrieve(id=contact_id) + assert contact is not None + assert contact.id == contact_id + + +def test_leads_list(client): + response = client.crm.leads.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_leads_retrieve(client): + leads_response = client.crm.leads.list(page_size=1) + + if leads_response.results: + lead_id = leads_response.results[0].id + lead = client.crm.leads.retrieve(id=lead_id) + assert lead is not None + assert lead.id == lead_id + + +def test_opportunities_list(client): + response = client.crm.opportunities.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_opportunities_retrieve(client): + opportunities_response = client.crm.opportunities.list(page_size=1) + + if opportunities_response.results: + opportunity_id = opportunities_response.results[0].id + opportunity = client.crm.opportunities.retrieve(id=opportunity_id) + assert opportunity is not None + assert opportunity.id == opportunity_id + + +def test_users_list(client): + response = client.crm.users.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_users_retrieve(client): + users_response = client.crm.users.list(page_size=1) + + if users_response.results: + user_id = users_response.results[0].id + user = client.crm.users.retrieve(id=user_id) + assert user is not None + assert user.id == user_id + + +def test_tasks_list(client): + response = client.crm.tasks.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_tasks_retrieve(client): + tasks_response = client.crm.tasks.list(page_size=1) + + if tasks_response.results: + task_id = tasks_response.results[0].id + task = client.crm.tasks.retrieve(id=task_id) + assert task is not None + assert task.id == task_id + + +def test_notes_list(client): + response = client.crm.notes.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_notes_retrieve(client): + notes_response = client.crm.notes.list(page_size=1) + + if notes_response.results: + note_id = notes_response.results[0].id + note = client.crm.notes.retrieve(id=note_id) + assert note is not None + assert note.id == note_id + + +def test_engagements_list(client): + response = client.crm.engagements.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_engagements_retrieve(client): + engagements_response = client.crm.engagements.list(page_size=1) + + if engagements_response.results: + engagement_id = engagements_response.results[0].id + engagement = client.crm.engagements.retrieve(id=engagement_id) + assert engagement is not None + assert engagement.id == engagement_id + + +def test_stages_list(client): + response = client.crm.stages.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_stages_retrieve(client): + stages_response = client.crm.stages.list(page_size=1) + + if stages_response.results: + stage_id = stages_response.results[0].id + stage = client.crm.stages.retrieve(id=stage_id) + assert stage is not None + assert stage.id == stage_id + + +def test_custom_object_classes_list(client): + response = client.crm.custom_object_classes.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_custom_object_classes_retrieve(client): + custom_object_classes_response = client.crm.custom_object_classes.list(page_size=1) + + if custom_object_classes_response.results: + custom_object_class_id = custom_object_classes_response.results[0].id + custom_object_class = client.crm.custom_object_classes.retrieve(id=custom_object_class_id) + assert custom_object_class is not None + assert custom_object_class.id == custom_object_class_id + + +def test_contacts_list_with_expand_account(client): + response = client.crm.contacts.list(expand=ContactsListRequestExpand.ACCOUNT) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_contacts_retrieve_with_expand_account(client): + contacts_response = client.crm.contacts.list(page_size=1) + + if contacts_response.results: + contact_id = contacts_response.results[0].id + contact = client.crm.contacts.retrieve(id=contact_id, expand=ContactsRetrieveRequestExpand.ACCOUNT) + assert contact is not None + assert contact.id == contact_id + + +def test_opportunities_list_with_expand_account(client): + response = client.crm.opportunities.list(expand=OpportunitiesListRequestExpand.ACCOUNT) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_opportunities_retrieve_with_expand_stage(client): + opportunities_response = client.crm.opportunities.list(page_size=1) + + if opportunities_response.results: + opportunity_id = opportunities_response.results[0].id + opportunity = client.crm.opportunities.retrieve(id=opportunity_id, expand=OpportunitiesRetrieveRequestExpand.STAGE) + assert opportunity is not None + assert opportunity.id == opportunity_id + + +def test_contacts_list_with_expand_string(client): + response = client.crm.contacts.list(expand="account") + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_opportunities_list_with_expand_string(client): + response = client.crm.opportunities.list(expand="stage") + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + diff --git a/tests/integration/test_hris.py b/tests/integration/test_hris.py new file mode 100644 index 00000000..140fb9a9 --- /dev/null +++ b/tests/integration/test_hris.py @@ -0,0 +1,261 @@ +import os +import pytest +from merge import Merge +from merge.resources.hris.resources.employees.types.employees_list_request_expand import EmployeesListRequestExpand +from merge.resources.hris.resources.employees.types.employees_retrieve_request_expand import EmployeesRetrieveRequestExpand +from merge.resources.hris.resources.employments.types.employments_list_request_expand import EmploymentsListRequestExpand +from merge.resources.hris.resources.employments.types.employments_retrieve_request_expand import EmploymentsRetrieveRequestExpand + + +@pytest.fixture +def client(): + account_token = os.environ["SDK_TESTING_HRIS_ACCOUNT_TOKEN"] + api_key = os.environ["SDK_TESTING_KEY_SECONDARY"] + + return Merge( + account_token=account_token, + api_key=api_key, + ) + + +def test_account_details_retrieve(client): + account_details = client.hris.account_details.retrieve() + assert account_details is not None + assert hasattr(account_details, 'id') + + +def test_employees_list(client): + response = client.hris.employees.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_employees_retrieve(client): + employees_response = client.hris.employees.list(page_size=1) + + if employees_response.results: + employee_id = employees_response.results[0].id + employee = client.hris.employees.retrieve(id=employee_id) + assert employee is not None + assert employee.id == employee_id + + +def test_employments_list(client): + response = client.hris.employments.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_employments_retrieve(client): + employments_response = client.hris.employments.list(page_size=1) + + if employments_response.results: + employment_id = employments_response.results[0].id + employment = client.hris.employments.retrieve(id=employment_id) + assert employment is not None + assert employment.id == employment_id + + +def test_teams_list(client): + response = client.hris.teams.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_teams_retrieve(client): + teams_response = client.hris.teams.list(page_size=1) + + if teams_response.results: + team_id = teams_response.results[0].id + team = client.hris.teams.retrieve(id=team_id) + assert team is not None + assert team.id == team_id + + +def test_locations_list(client): + response = client.hris.locations.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_locations_retrieve(client): + locations_response = client.hris.locations.list(page_size=1) + + if locations_response.results: + location_id = locations_response.results[0].id + location = client.hris.locations.retrieve(id=location_id) + assert location is not None + assert location.id == location_id + + +def test_benefits_list(client): + response = client.hris.benefits.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_benefits_retrieve(client): + benefits_response = client.hris.benefits.list(page_size=1) + + if benefits_response.results: + benefit_id = benefits_response.results[0].id + benefit = client.hris.benefits.retrieve(id=benefit_id) + assert benefit is not None + assert benefit.id == benefit_id + + +def test_pay_groups_list(client): + response = client.hris.pay_groups.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_pay_groups_retrieve(client): + pay_groups_response = client.hris.pay_groups.list(page_size=1) + + if pay_groups_response.results: + pay_group_id = pay_groups_response.results[0].id + pay_group = client.hris.pay_groups.retrieve(id=pay_group_id) + assert pay_group is not None + assert pay_group.id == pay_group_id + + +def test_dependents_list(client): + response = client.hris.dependents.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_dependents_retrieve(client): + dependents_response = client.hris.dependents.list(page_size=1) + + if dependents_response.results: + dependent_id = dependents_response.results[0].id + dependent = client.hris.dependents.retrieve(id=dependent_id) + assert dependent is not None + assert dependent.id == dependent_id + + +def test_groups_list(client): + response = client.hris.groups.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_groups_retrieve(client): + groups_response = client.hris.groups.list(page_size=1) + + if groups_response.results: + group_id = groups_response.results[0].id + group = client.hris.groups.retrieve(id=group_id) + assert group is not None + assert group.id == group_id + + +def test_time_off_list(client): + response = client.hris.time_off.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_time_off_retrieve(client): + time_off_response = client.hris.time_off.list(page_size=1) + + if time_off_response.results: + time_off_id = time_off_response.results[0].id + time_off = client.hris.time_off.retrieve(id=time_off_id) + assert time_off is not None + assert time_off.id == time_off_id + + +def test_time_off_balances_list(client): + response = client.hris.time_off_balances.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_time_off_balances_retrieve(client): + time_off_balances_response = client.hris.time_off_balances.list(page_size=1) + + if time_off_balances_response.results: + time_off_balance_id = time_off_balances_response.results[0].id + time_off_balance = client.hris.time_off_balances.retrieve(id=time_off_balance_id) + assert time_off_balance is not None + assert time_off_balance.id == time_off_balance_id + + +def test_bank_info_list(client): + response = client.hris.bank_info.list() + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_bank_info_retrieve(client): + bank_info_response = client.hris.bank_info.list(page_size=1) + + if bank_info_response.results: + bank_info_id = bank_info_response.results[0].id + bank_info = client.hris.bank_info.retrieve(id=bank_info_id) + assert bank_info is not None + assert bank_info.id == bank_info_id + + +def test_employees_list_with_expand_company(client): + response = client.hris.employees.list(expand=EmployeesListRequestExpand.COMPANY) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_employees_retrieve_with_expand_employments(client): + employees_response = client.hris.employees.list(page_size=1) + + if employees_response.results: + employee_id = employees_response.results[0].id + employee = client.hris.employees.retrieve(id=employee_id, expand=EmployeesRetrieveRequestExpand.EMPLOYMENTS) + assert employee is not None + assert employee.id == employee_id + + +def test_employments_list_with_expand_employee(client): + response = client.hris.employments.list(expand=EmploymentsListRequestExpand.EMPLOYEE) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_employments_retrieve_with_expand_pay_group(client): + employments_response = client.hris.employments.list(page_size=1) + + if employments_response.results: + employment_id = employments_response.results[0].id + employment = client.hris.employments.retrieve(id=employment_id, expand=EmploymentsRetrieveRequestExpand.PAY_GROUP) + assert employment is not None + assert employment.id == employment_id + + +def test_employees_list_with_expand_string(client): + response = client.hris.employees.list(expand="company") + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_employments_list_with_expand_string(client): + response = client.hris.employments.list(expand="employee") + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + diff --git a/tests/integration/test_ticketing.py b/tests/integration/test_ticketing.py new file mode 100644 index 00000000..164baef8 --- /dev/null +++ b/tests/integration/test_ticketing.py @@ -0,0 +1,228 @@ +import os +import pytest +from merge import Merge +from merge.resources.ticketing.resources.tickets.types.tickets_list_request_expand import TicketsListRequestExpand +from merge.resources.ticketing.resources.tickets.types.tickets_retrieve_request_expand import TicketsRetrieveRequestExpand + + +@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_account_details_retrieve(client): + account_details = client.ticketing.account_details.retrieve() + assert account_details is not None + assert hasattr(account_details, '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_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_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_retrieve(client): + collections_response = client.ticketing.collections.list(page_size=1) + + if collections_response.results: + collection_id = collections_response.results[0].id + collection = client.ticketing.collections.retrieve(id=collection_id) + assert collection is not None + assert collection.id == collection_id + + +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_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_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_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_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_retrieve(client): + tickets_response = client.ticketing.tickets.list(page_size=1) + + if tickets_response.results: + ticket_id = tickets_response.results[0].id + ticket = client.ticketing.tickets.retrieve(id=ticket_id) + assert ticket is not None + assert ticket.id == ticket_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_tickets_list_with_expand_assignees(client): + response = client.ticketing.tickets.list(expand=TicketsListRequestExpand.ASSIGNEES) + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_tickets_retrieve_with_expand_assignees(client): + tickets_response = client.ticketing.tickets.list(page_size=1) + + if tickets_response.results: + ticket_id = tickets_response.results[0].id + ticket = client.ticketing.tickets.retrieve(id=ticket_id, expand=TicketsRetrieveRequestExpand.ASSIGNEES) + assert ticket is not None + assert ticket.id == ticket_id + + +def test_tickets_list_with_expand_string(client): + response = client.ticketing.tickets.list(expand="assignees") + assert response is not None + assert hasattr(response, 'results') + assert isinstance(response.results, list) + + +def test_tickets_retrieve_with_expand_string(client): + tickets_response = client.ticketing.tickets.list(page_size=1) + + if tickets_response.results: + ticket_id = tickets_response.results[0].id + ticket = client.ticketing.tickets.retrieve(id=ticket_id, expand="collections") + assert ticket is not None + assert ticket.id == ticket_id + +