From a1f2571fce91cb46d2ae4a89a03eea13a42ae50f Mon Sep 17 00:00:00 2001 From: Jessica Matsuoka Date: Wed, 22 Jan 2025 09:38:16 +0100 Subject: [PATCH] DEVEXP-709: Clean Up tests and Update CI Pipeline - Removed Test Categories: - Deleted e2e and acceptance tests. - Removed tests related to examples, as these will be moved to a new repository. - Updated conftest.py: - Removed unused fixtures - Modified CI pipeline: - Updated to run only unit tests - Configured it to run coverage report omitting empty files Signed-off-by: Jessica Matsuoka --- .github/workflows/run-tests.yml | 34 ++--- examples/fast_api_example.py | 24 ---- examples/flask_example.py | 36 ----- examples/logging_example.py | 42 ------ requirements-dev.txt | 14 +- .../acceptance/authentication/environment.py | 9 -- .../authentication/steps/given_steps.py | 30 ---- .../authentication/steps/then_steps.py | 26 ---- .../authentication/steps/when_steps.py | 24 ---- tests/acceptance/numbers/environment.py | 10 -- tests/acceptance/numbers/steps/given_steps.py | 48 ------- tests/acceptance/numbers/steps/then_steps.py | 12 -- tests/acceptance/numbers/steps/when_steps.py | 33 ----- tests/conftest.py | 130 +----------------- .../test_token_authentication.py | 37 ----- tests/e2e/conversation/app/test_create_app.py | 37 ----- tests/e2e/conversation/app/test_delete_app.py | 19 --- tests/e2e/conversation/app/test_get_app.py | 19 --- tests/e2e/conversation/app/test_list_apps.py | 18 --- tests/e2e/conversation/app/test_update_app.py | 21 --- .../contact/test_create_contact.py | 55 -------- .../contact/test_delete_contact.py | 21 --- .../contact/test_get_channel_profile.py | 38 ----- .../conversation/contact/test_get_contact.py | 24 ---- .../conversation/contact/test_list_contact.py | 42 ------ .../contact/test_merge_contacts.py | 26 ---- .../contact/test_update_contact.py | 32 ----- .../conversation/test_create_conversation.py | 21 --- .../conversation/test_delete_conversation.py | 27 ---- .../conversation/test_get_conversation.py | 27 ---- .../conversation/test_inject_messages.py | 34 ----- .../conversation/test_list_conversation.py | 19 --- .../conversation/test_stop_conversation.py | 25 ---- .../conversation/test_update_conversation.py | 29 ---- .../message/test_delete_message.py | 23 ---- .../conversation/message/test_get_message.py | 23 ---- .../conversation/message/test_list_message.py | 17 --- .../conversation/message/test_send_message.py | 33 ----- .../templates/test_create_template.py | 36 ----- .../templates/test_delete_template.py | 17 --- .../templates/test_get_template.py | 17 --- .../templates/test_list_templates.py | 11 -- .../templates/test_update_template.py | 27 ---- tests/e2e/conversation/test_capability.py | 23 ---- tests/e2e/conversation/test_opt_in.py | 25 ---- tests/e2e/conversation/test_opt_out.py | 26 ---- tests/e2e/conversation/test_send_events.py | 29 ---- tests/e2e/conversation/test_transcode.py | 27 ---- .../webhook/test_create_webhook.py | 19 --- .../webhook/test_delete_webhook.py | 21 --- .../conversation/webhook/test_get_webhook.py | 21 --- .../webhook/test_list_webhooks.py | 15 -- .../webhook/test_update_webhook.py | 27 ---- .../numbers/active/test_active_numbers_api.py | 126 ----------------- .../available/test_available_number_api.py | 101 -------------- .../numbers/available/test_rent_any_number.py | 17 --- .../test_get_callbacks_configuration.py | 6 - .../test_update_callback_configuration.py | 8 -- .../regions/test_available_regions_api.py | 23 ---- tests/e2e/sms/batches/test_batch_sms.py | 73 ---------- tests/e2e/sms/batches/test_cancel_batch.py | 50 ------- tests/e2e/sms/batches/test_dry_run.py | 38 ----- tests/e2e/sms/batches/test_get_batch.py | 25 ---- tests/e2e/sms/batches/test_list_batches.py | 89 ------------ tests/e2e/sms/batches/test_replace_batch.py | 40 ------ .../batches/test_send_delivery_feedback.py | 34 ----- tests/e2e/sms/batches/test_update_batch.py | 56 -------- .../test_get_delivery_report_for_batch.py | 59 -------- .../test_get_delivery_report_for_number.py | 43 ------ .../test_get_delivery_reports_for_project.py | 20 --- tests/e2e/sms/groups/test_create_group.py | 32 ----- tests/e2e/sms/groups/test_delete_group.py | 28 ---- tests/e2e/sms/groups/test_get_group.py | 28 ---- .../test_get_phone_numbers_for_group.py | 34 ----- tests/e2e/sms/groups/test_list_groups.py | 41 ------ tests/e2e/sms/groups/test_replace_group.py | 31 ----- tests/e2e/sms/groups/test_update_group.py | 45 ------ .../sms/inbounds/test_get_inbound_message.py | 20 --- .../inbounds/test_list_inbound_messages.py | 16 --- .../verification/test_get_report_using_id.py | 23 ---- .../test_get_report_using_identity.py | 23 ---- .../test_get_report_using_reference.py | 19 --- .../test_report_verification_using_id.py | 84 ----------- ...test_report_verification_using_identity.py | 85 ------------ .../verification/test_start_verification.py | 115 ---------------- .../voice/applications/test_assign_numbers.py | 21 --- .../applications/test_get_callback_urls.py | 21 --- .../voice/applications/test_get_numbers.py | 15 -- .../voice/applications/test_query_number.py | 21 --- .../applications/test_unassign_number.py | 21 --- .../applications/test_update_callback_urls.py | 25 ---- tests/e2e/voice/callouts/test_callout.py | 101 -------------- tests/e2e/voice/calls/test_get_call.py | 21 --- tests/e2e/voice/calls/test_magage_call.py | 37 ----- tests/e2e/voice/calls/test_update_call.py | 35 ----- .../voice/conferences/test_call_conference.py | 37 ----- .../voice/conferences/test_get_conference.py | 17 --- tests/e2e/voice/conferences/test_kick_all.py | 17 --- .../conferences/test_kick_participant.py | 25 ---- .../conferences/test_manage_participant.py | 29 ---- tests/examples/test_fast_api_example.py | 16 --- tests/examples/test_flask_example.py | 16 --- tests/examples/test_logging_example.py | 19 --- .../test_domain_endpoint_error_handling.py | 55 -------- tests/integration/test_http_transport.py | 41 ------ tests/integration/test_logging.py | 47 ------- tests/integration/test_request_signing.py | 60 -------- ...est_sms_endpoint_credendials_formatting.py | 23 ---- tests/integration/test_token_refresh.py | 62 --------- 109 files changed, 28 insertions(+), 3666 deletions(-) delete mode 100644 examples/fast_api_example.py delete mode 100644 examples/flask_example.py delete mode 100644 examples/logging_example.py delete mode 100644 tests/acceptance/authentication/environment.py delete mode 100644 tests/acceptance/authentication/steps/given_steps.py delete mode 100644 tests/acceptance/authentication/steps/then_steps.py delete mode 100644 tests/acceptance/authentication/steps/when_steps.py delete mode 100644 tests/acceptance/numbers/environment.py delete mode 100644 tests/acceptance/numbers/steps/given_steps.py delete mode 100644 tests/acceptance/numbers/steps/then_steps.py delete mode 100644 tests/acceptance/numbers/steps/when_steps.py delete mode 100644 tests/e2e/authentication/test_token_authentication.py delete mode 100644 tests/e2e/conversation/app/test_create_app.py delete mode 100644 tests/e2e/conversation/app/test_delete_app.py delete mode 100644 tests/e2e/conversation/app/test_get_app.py delete mode 100644 tests/e2e/conversation/app/test_list_apps.py delete mode 100644 tests/e2e/conversation/app/test_update_app.py delete mode 100644 tests/e2e/conversation/contact/test_create_contact.py delete mode 100644 tests/e2e/conversation/contact/test_delete_contact.py delete mode 100644 tests/e2e/conversation/contact/test_get_channel_profile.py delete mode 100644 tests/e2e/conversation/contact/test_get_contact.py delete mode 100644 tests/e2e/conversation/contact/test_list_contact.py delete mode 100644 tests/e2e/conversation/contact/test_merge_contacts.py delete mode 100644 tests/e2e/conversation/contact/test_update_contact.py delete mode 100644 tests/e2e/conversation/conversation/test_create_conversation.py delete mode 100644 tests/e2e/conversation/conversation/test_delete_conversation.py delete mode 100644 tests/e2e/conversation/conversation/test_get_conversation.py delete mode 100644 tests/e2e/conversation/conversation/test_inject_messages.py delete mode 100644 tests/e2e/conversation/conversation/test_list_conversation.py delete mode 100644 tests/e2e/conversation/conversation/test_stop_conversation.py delete mode 100644 tests/e2e/conversation/conversation/test_update_conversation.py delete mode 100644 tests/e2e/conversation/message/test_delete_message.py delete mode 100644 tests/e2e/conversation/message/test_get_message.py delete mode 100644 tests/e2e/conversation/message/test_list_message.py delete mode 100644 tests/e2e/conversation/message/test_send_message.py delete mode 100644 tests/e2e/conversation/templates/test_create_template.py delete mode 100644 tests/e2e/conversation/templates/test_delete_template.py delete mode 100644 tests/e2e/conversation/templates/test_get_template.py delete mode 100644 tests/e2e/conversation/templates/test_list_templates.py delete mode 100644 tests/e2e/conversation/templates/test_update_template.py delete mode 100644 tests/e2e/conversation/test_capability.py delete mode 100644 tests/e2e/conversation/test_opt_in.py delete mode 100644 tests/e2e/conversation/test_opt_out.py delete mode 100644 tests/e2e/conversation/test_send_events.py delete mode 100644 tests/e2e/conversation/test_transcode.py delete mode 100644 tests/e2e/conversation/webhook/test_create_webhook.py delete mode 100644 tests/e2e/conversation/webhook/test_delete_webhook.py delete mode 100644 tests/e2e/conversation/webhook/test_get_webhook.py delete mode 100644 tests/e2e/conversation/webhook/test_list_webhooks.py delete mode 100644 tests/e2e/conversation/webhook/test_update_webhook.py delete mode 100644 tests/e2e/numbers/active/test_active_numbers_api.py delete mode 100644 tests/e2e/numbers/available/test_available_number_api.py delete mode 100644 tests/e2e/numbers/available/test_rent_any_number.py delete mode 100644 tests/e2e/numbers/callbacks/test_get_callbacks_configuration.py delete mode 100644 tests/e2e/numbers/callbacks/test_update_callback_configuration.py delete mode 100644 tests/e2e/numbers/regions/test_available_regions_api.py delete mode 100644 tests/e2e/sms/batches/test_batch_sms.py delete mode 100644 tests/e2e/sms/batches/test_cancel_batch.py delete mode 100644 tests/e2e/sms/batches/test_dry_run.py delete mode 100644 tests/e2e/sms/batches/test_get_batch.py delete mode 100644 tests/e2e/sms/batches/test_list_batches.py delete mode 100644 tests/e2e/sms/batches/test_replace_batch.py delete mode 100644 tests/e2e/sms/batches/test_send_delivery_feedback.py delete mode 100644 tests/e2e/sms/batches/test_update_batch.py delete mode 100644 tests/e2e/sms/delivery_reports/test_get_delivery_report_for_batch.py delete mode 100644 tests/e2e/sms/delivery_reports/test_get_delivery_report_for_number.py delete mode 100644 tests/e2e/sms/delivery_reports/test_get_delivery_reports_for_project.py delete mode 100644 tests/e2e/sms/groups/test_create_group.py delete mode 100644 tests/e2e/sms/groups/test_delete_group.py delete mode 100644 tests/e2e/sms/groups/test_get_group.py delete mode 100644 tests/e2e/sms/groups/test_get_phone_numbers_for_group.py delete mode 100644 tests/e2e/sms/groups/test_list_groups.py delete mode 100644 tests/e2e/sms/groups/test_replace_group.py delete mode 100644 tests/e2e/sms/groups/test_update_group.py delete mode 100644 tests/e2e/sms/inbounds/test_get_inbound_message.py delete mode 100644 tests/e2e/sms/inbounds/test_list_inbound_messages.py delete mode 100644 tests/e2e/verification/test_get_report_using_id.py delete mode 100644 tests/e2e/verification/test_get_report_using_identity.py delete mode 100644 tests/e2e/verification/test_get_report_using_reference.py delete mode 100644 tests/e2e/verification/test_report_verification_using_id.py delete mode 100644 tests/e2e/verification/test_report_verification_using_identity.py delete mode 100644 tests/e2e/verification/test_start_verification.py delete mode 100644 tests/e2e/voice/applications/test_assign_numbers.py delete mode 100644 tests/e2e/voice/applications/test_get_callback_urls.py delete mode 100644 tests/e2e/voice/applications/test_get_numbers.py delete mode 100644 tests/e2e/voice/applications/test_query_number.py delete mode 100644 tests/e2e/voice/applications/test_unassign_number.py delete mode 100644 tests/e2e/voice/applications/test_update_callback_urls.py delete mode 100644 tests/e2e/voice/callouts/test_callout.py delete mode 100644 tests/e2e/voice/calls/test_get_call.py delete mode 100644 tests/e2e/voice/calls/test_magage_call.py delete mode 100644 tests/e2e/voice/calls/test_update_call.py delete mode 100644 tests/e2e/voice/conferences/test_call_conference.py delete mode 100644 tests/e2e/voice/conferences/test_get_conference.py delete mode 100644 tests/e2e/voice/conferences/test_kick_all.py delete mode 100644 tests/e2e/voice/conferences/test_kick_participant.py delete mode 100644 tests/e2e/voice/conferences/test_manage_participant.py delete mode 100644 tests/examples/test_fast_api_example.py delete mode 100644 tests/examples/test_flask_example.py delete mode 100644 tests/examples/test_logging_example.py delete mode 100644 tests/integration/test_domain_endpoint_error_handling.py delete mode 100644 tests/integration/test_http_transport.py delete mode 100644 tests/integration/test_logging.py delete mode 100644 tests/integration/test_request_signing.py delete mode 100644 tests/integration/test_sms_endpoint_credendials_formatting.py delete mode 100644 tests/integration/test_token_refresh.py diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index e38bf6b1..92ab75e3 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -2,33 +2,21 @@ name: Test Python SDK on: [ push ] env: + APPLICATION_KEY: ${{ secrets.APPLICATION_KEY }} + APPLICATION_SECRET: ${{ secrets.APPLICATION_SECRET }} + AUTH_ORIGIN: ${{ secrets.AUTH_ORIGIN }} + CONVERSATION_ORIGIN: ${{ secrets.CONVERSATION_ORIGIN }} + DISABLE_SSL: ${{ secrets.DISABLE_SSL }} KEY_ID: ${{ secrets.KEY_ID }} KEY_SECRET: ${{ secrets.KEY_SECRET }} - PROJECT_ID: ${{ secrets.PROJECT_ID }} NUMBERS_ORIGIN: ${{ secrets.NUMBERS_ORIGIN }} - SMS_ORIGIN: ${{ secrets.SMS_ORIGIN }} + PROJECT_ID: ${{ secrets.PROJECT_ID }} SERVICE_PLAN_ID: ${{ secrets.SERVICE_PLAN_ID }} - SMS_API_TOKEN: ${{ secrets.SMS_API_TOKEN }} - CONVERSATION_ORIGIN: ${{ secrets.CONVERSATION_ORIGIN }} - AUTH_ORIGIN: ${{ secrets.AUTH_ORIGIN }} - DISABLE_SSL: ${{ secrets.DISABLE_SSL }} - PHONE_NUMBER: ${{ secrets.PHONE_NUMBER }} - ORIGIN_PHONE_NUMBER: ${{ secrets.ORIGIN_PHONE_NUMBER }} - APP_ID: ${{ secrets.APP_ID }} - EMPTY_PROJECT_ID: ${{ secrets.EMPTY_PROJECT_ID }} + SMS_ORIGIN: ${{ secrets.SMS_ORIGIN }} TEMPLATES_ORIGIN: ${{ secrets.TEMPLATES_ORIGIN }} - APPLICATION_SECRET: ${{ secrets.APPLICATION_SECRET }} - APPLICATION_KEY: ${{ secrets.APPLICATION_KEY }} - VERIFICATION_ID: ${{ secrets.VERIFICATION_ID }} VERIFICATION_ORIGIN: ${{ secrets.VERIFICATION_ORIGIN }} - VERIFICATION_REQUEST_SIGNATURE_TIMESTAMP: ${{ secrets.VERIFICATION_REQUEST_SIGNATURE_TIMESTAMP }} - VERIFICATION_REQUEST_WITH_EMPTY_BODY_SIGNATURE: ${{ secrets.VERIFICATION_REQUEST_WITH_EMPTY_BODY_SIGNATURE }} - VERIFICATION_REQUEST_SIGNATURE: ${{ secrets.VERIFICATION_REQUEST_SIGNATURE }} - VOICE_ORIGIN: ${{ secrets.VOICE_ORIGIN }} - VOICE_ORIGIN_PHONE_NUMBER: ${{ secrets.VOICE_ORIGIN_PHONE_NUMBER }} VOICE_CALL_ID: ${{ secrets.VOICE_CALL_ID }} - CONFERENCE_ID: ${{ secrets.CONFERENCE_ID }} - CONFERENCE_CALL_ID: ${{ secrets.CONFERENCE_CALL_ID }} + VOICE_ORIGIN: ${{ secrets.VOICE_ORIGIN }} jobs: build: @@ -51,3 +39,9 @@ jobs: - name: Lint with flake8 run: | flake8 sinch --count --max-complexity=10 --max-line-length=120 --statistics + - name: Test with Pytest + run: | + coverage run --source=. -m pytest + - name: Coverage Test Report + run: | + python -m coverage report --skip-empty diff --git a/examples/fast_api_example.py b/examples/fast_api_example.py deleted file mode 100644 index d54c5514..00000000 --- a/examples/fast_api_example.py +++ /dev/null @@ -1,24 +0,0 @@ -import os -from fastapi import FastAPI -from sinch import SinchClientAsync - -""" -Run with: uvicorn fast_api_example:app --reload -""" - -app = FastAPI() - -sinch_client = SinchClientAsync( - key_id=os.getenv("KEY_ID"), - key_secret=os.getenv("KEY_SECRET"), - project_id=os.getenv("PROJECT_ID") -) - - -@app.get("/available_numbers") -async def project(): - numbers_api_response = await sinch_client.numbers.available.list( - region_code="US", - number_type="LOCAL" - ) - return {"available_numbers": numbers_api_response.available_numbers} diff --git a/examples/flask_example.py b/examples/flask_example.py deleted file mode 100644 index 4382be81..00000000 --- a/examples/flask_example.py +++ /dev/null @@ -1,36 +0,0 @@ -import os -from flask import Flask -from sinch import SinchClient -from sinch.domains.conversation.enums import ConversationChannel - -""" -Run with: export FLASK_APP=flask_example.py; flask run -""" - -app = Flask("Sinch_example") - -sinch_client = SinchClient( - key_id=os.getenv("KEY_ID"), - key_secret=os.getenv("KEY_SECRET"), - project_id=os.getenv("PROJECT_ID") -) - - -@app.route("/create_app", methods=['POST']) -def project(): - conversation_api_app = sinch_client.conversation.app.create( - display_name="Shrubbery", - channel_credentials=[ - { - "channel": ConversationChannel.TELEGRAM.value, - "telegram_credentials": { - "token": "herring" - } - } - ], - retention_policy={ - "ttl_days": 20, - "retention_type": "MESSAGE_EXPIRE_POLICY" - } - ) - return {"sinch_app_id": conversation_api_app.id} diff --git a/examples/logging_example.py b/examples/logging_example.py deleted file mode 100644 index 478326ce..00000000 --- a/examples/logging_example.py +++ /dev/null @@ -1,42 +0,0 @@ -import os -import logging -from sinch import SinchClient -""" -Custom logger configuration example. -""" - -logger = logging.getLogger("myapp.sinch") -logger.setLevel(logging.DEBUG) - -file_handler = logging.FileHandler("/tmp/test_python_logging.log") -file_handler.setLevel(logging.DEBUG) - -console_handler = logging.StreamHandler() -console_handler.setLevel(logging.DEBUG) - -formatter = logging.Formatter( - '%(asctime)s - %(name)s - %(levelname)s - %(message)s' -) -file_handler.setFormatter(formatter) - -logger.addHandler(file_handler) -logger.addHandler(console_handler) - -sinch_client = SinchClient( - key_id=os.getenv("KEY_ID"), - key_secret=os.getenv("KEY_SECRET"), - project_id=os.getenv("PROJECT_ID"), - logger=logger -) - - -def main(): - available_numbers_response = sinch_client.numbers.available.list( - region_code="US", - number_type="LOCAL" - ) - print(available_numbers_response) - - -if __name__ == "__main__": - main() diff --git a/requirements-dev.txt b/requirements-dev.txt index 65facc49..56637da2 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,9 +1,11 @@ +# Testing pytest +pytest-asyncio +coverage + +# Code Quality flake8 -bandit -requests -flask -fastapi + +# HTTP Libraries httpx -pytest-asyncio -coverage \ No newline at end of file +requests \ No newline at end of file diff --git a/tests/acceptance/authentication/environment.py b/tests/acceptance/authentication/environment.py deleted file mode 100644 index 06aa5e37..00000000 --- a/tests/acceptance/authentication/environment.py +++ /dev/null @@ -1,9 +0,0 @@ -def before_scenario(context, feature): - for tag in feature.tags: - if "contract_name" in tag: - pass - - -def after_scenario(context, feature): - for tag in feature.tags: - print(tag) diff --git a/tests/acceptance/authentication/steps/given_steps.py b/tests/acceptance/authentication/steps/given_steps.py deleted file mode 100644 index 8714ee9d..00000000 --- a/tests/acceptance/authentication/steps/given_steps.py +++ /dev/null @@ -1,30 +0,0 @@ -from os import getenv -from behave import given - - -@given("an access key {key_id} obtained from Sinch portal") -def step_impl(context, key_id): - context.key_id = getenv(key_id.strip('"')) - assert context.key_id - - -@given("secret key {key_secret} obtained from Sinch portal") -def step_impl(context, key_secret): - context.key_secret = getenv(key_secret.strip('"')) - assert context.key_secret - - -@given("an access token {access_token} obtained from another instance of the SDK") -def step_impl(context, access_token): - context.access_token = getenv(access_token.strip('"')) - assert context.access_token - - -@given("the token structure has {field_name} field and data") -def step_impl(context, field_name): - assert getattr(context.auth_token, field_name.strip('"')) - - -@given("the token structure has {field_name} field") -def step_impl(context, field_name): - getattr(context.auth_token, field_name.strip('"')) diff --git a/tests/acceptance/authentication/steps/then_steps.py b/tests/acceptance/authentication/steps/then_steps.py deleted file mode 100644 index 903dee65..00000000 --- a/tests/acceptance/authentication/steps/then_steps.py +++ /dev/null @@ -1,26 +0,0 @@ -from sinch.core.exceptions import SinchAuthenticationException -from behave import then - - -@then("the Sinch SDK accepts and processes the token without reporting any issues") -def step_impl(context): - raise NotImplementedError(u'STEP: Then the Sinch SDK accepts and processes the token without reporting any issues') - - -@then("the Sinch SDK rejects the token and raises an error") -def step_impl(context): - raise NotImplementedError(u'STEP: Then the Sinch SDK rejects the token and raises an error') - - -@then("developer is able to retrieve token using Sinch SDK") -def step_impl(context): - context.auth_token = context.sinch_instance.get_auth_token() - assert context.auth_token - - -@then("the Sinch SDK tries to acquire the token and raises an error") -def step_impl(context): - try: - context.auth_token = context.sinch_instance.get_auth_token() - except SinchAuthenticationException: - pass diff --git a/tests/acceptance/authentication/steps/when_steps.py b/tests/acceptance/authentication/steps/when_steps.py deleted file mode 100644 index 89b23c3e..00000000 --- a/tests/acceptance/authentication/steps/when_steps.py +++ /dev/null @@ -1,24 +0,0 @@ -from behave import when -from sinch import Sinch - - -@when("developer initialize Sinch SDK using token received from the Key Distribution Center or other source") -def step_impl(context): - pass - - -@when("developer initialize Sinch SDK using the invalid token") -def step_impl(context): - raise NotImplementedError(u'STEP: When developer initialize Sinch SDK using the invalid token') - - -@when("developer initialize Sinch SDK using credentials obtained from Sinch portal") -def step_impl(context): - context.sinch_instance = Sinch(key_id=context.key_id, key_secret=context.key_secret) - assert context.sinch_instance - - -@when("developer initialize Sinch SDK using invalid credentials") -def step_impl(context): - context.sinch_instance = Sinch(key_id="Spanish", key_secret="Inquisition") - assert context.sinch_instance diff --git a/tests/acceptance/numbers/environment.py b/tests/acceptance/numbers/environment.py deleted file mode 100644 index e6cfee1f..00000000 --- a/tests/acceptance/numbers/environment.py +++ /dev/null @@ -1,10 +0,0 @@ -def before_scenario(context, feature): - for tag in feature.tags: - if "contract_name" in tag: - # assert False, tag - pass - - -def after_scenario(context, feature): - for tag in feature.tags: - print(tag) diff --git a/tests/acceptance/numbers/steps/given_steps.py b/tests/acceptance/numbers/steps/given_steps.py deleted file mode 100644 index 3a26ad58..00000000 --- a/tests/acceptance/numbers/steps/given_steps.py +++ /dev/null @@ -1,48 +0,0 @@ -import os -from behave import given - -from sinch import Client - - -@given("an access key KEY_ID obtained from Sinch portal") -def step_impl(context): - context.key_id = os.getenv("KEY_ID") - - -@given("secret key KEY_SECRET obtained from Sinch portal") -def step_impl(context): - context.key_secret = os.getenv("KEY_SECRET") - - -@given("project id PROJECT_ID obtained from Sinch portal") -def step_impl(context): - context.project_id = os.getenv("PROJECT_ID") - - -@given("Sinch SDK client is configured with NUMBERS_URL and AUTHENTICATION_URL environment variables") -def step_impl(context): - context.sinch_client = Client( - key_id=context.key_id, - key_secret=context.key_secret, - project_id=context.project_id - ) - numbers_url = os.getenv("NUMBERS_URL") - authentication_url = os.getenv("AUTHENTICATION_URL") - - if numbers_url: - context.sinch_client.configuration.numbers_origin = numbers_url - context.sinch_client.configuration.disable_https = True - - if authentication_url: - context.sinch_client.configuration.auth_origin = authentication_url - context.sinch_client.configuration.disable_https = True - - -@given("the number entity contains {field} field and data") -def step_impl(context, field): - assert hasattr(context.number_entity, field.strip('"')) - - -@given("the region entity contains {field} field and data") -def step_impl(context, field): - assert hasattr(context.response.available_regions[0], field.strip('"')) diff --git a/tests/acceptance/numbers/steps/then_steps.py b/tests/acceptance/numbers/steps/then_steps.py deleted file mode 100644 index ac939a79..00000000 --- a/tests/acceptance/numbers/steps/then_steps.py +++ /dev/null @@ -1,12 +0,0 @@ -from behave import then - - -@then("the response contains list of {field_name}") -def step_impl(context, field_name): - assert context.response - assert hasattr(context.response, field_name.strip('"')) - - -@then("the response is successful and contains number details") -def step_impl(context): - assert context.number_entity diff --git a/tests/acceptance/numbers/steps/when_steps.py b/tests/acceptance/numbers/steps/when_steps.py deleted file mode 100644 index 542a95c2..00000000 --- a/tests/acceptance/numbers/steps/when_steps.py +++ /dev/null @@ -1,33 +0,0 @@ -from behave import when - - -@when("Developer invokes a method responsible for searching available numbers with region {region} and type {number_type}") -def step_impl(context, region, number_type): - context.available_numbers_response = context.sinch_client.numbers.list_available_numbers( - region_code=region.strip('"'), - number_type=number_type.strip('"') - ) - assert context.available_numbers_response - - -@when("Developer invokes a method responsible for activating a first virtual phone number from the returned list of numbers") -def step_impl(context): - context.lease_number_response = context.sinch_client.numbers.activate_number( - phone_number=context.available_numbers_response.available_numbers[0].phone_number - ) - - -@when("Developer invokes a method responsible for query of a first virtual phone number from the returned list of numbers") -def step_impl(context): - context.number_entity = context.sinch_client.numbers.search_for_number( - phone_number=context.available_numbers_response.available_numbers[0].phone_number - ) - assert context.number_entity - - -@when("Developer invokes a method responsible for searching available regions with a type {number_type}") -def step_impl(context, number_type): - context.response = context.sinch_client.numbers.list_available_regions_for_project( - number_type=number_type.strip('"') - ) - assert context.response diff --git a/tests/conftest.py b/tests/conftest.py index a6625f5d..2f3a4676 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,13 +1,13 @@ +# This file that contains fixtures that are shared across all tests in the tests directory. import os -import pytest from dataclasses import dataclass -from sinch import SinchClient -from sinch import SinchClientAsync +import pytest + +from sinch import SinchClient, SinchClientAsync +from sinch.core.models.base_model import SinchBaseModel, SinchRequestBaseModel from sinch.core.models.http_response import HTTPResponse -from sinch.core.models.http_request import HttpRequest from sinch.domains.authentication.models.authentication import OAuthToken -from sinch.core.models.base_model import SinchBaseModel, SinchRequestBaseModel @dataclass @@ -131,21 +131,6 @@ def disable_ssl(): return os.getenv("DISABLE_SSL") -@pytest.fixture -def phone_number(): - return os.getenv("PHONE_NUMBER") - - -@pytest.fixture -def origin_phone_number(): - return os.getenv("ORIGIN_PHONE_NUMBER") - - -@pytest.fixture -def voice_origin_phone_number(): - return os.getenv("VOICE_ORIGIN_PHONE_NUMBER") - - @pytest.fixture def application_key(): return os.getenv("APPLICATION_KEY") @@ -161,74 +146,6 @@ def service_plan_id(): return os.getenv("SERVICE_PLAN_ID") -@pytest.fixture -def sms_api_token(): - return os.getenv("SMS_API_TOKEN") - - -@pytest.fixture -def verification_id(): - return os.getenv("VERIFICATION_ID") - - -@pytest.fixture() -def call_id(): - return os.getenv("VOICE_CALL_ID") - - -@pytest.fixture() -def conference_id(): - return os.getenv("CONFERENCE_ID") - - -@pytest.fixture() -def conference_call_id(): - return os.getenv("CONFERENCE_CALL_ID") - - -@pytest.fixture -def app_id(): - return os.getenv("APP_ID") - - -@pytest.fixture -def contact_id(): - return os.getenv("CONTACT_ID") - - -@pytest.fixture -def empty_project_id(): - return os.getenv("EMPTY_PROJECT_ID") - - -@pytest.fixture -def verification_request_signature(): - return os.getenv("VERIFICATION_REQUEST_SIGNATURE") - - -@pytest.fixture -def verification_request_with_empty_body_signature(): - return os.getenv("VERIFICATION_REQUEST_WITH_EMPTY_BODY_SIGNATURE") - - -@pytest.fixture -def verification_request_signature_timestamp(): - return os.getenv("VERIFICATION_REQUEST_SIGNATURE_TIMESTAMP") - - -@pytest.fixture -def empty_http_request(): - return HttpRequest( - headers={}, - protocol=None, - http_method=None, - request_body=None, - query_params=None, - url=None, - auth=None - ) - - @pytest.fixture def http_response(): return HTTPResponse( @@ -244,30 +161,6 @@ def http_response(): ) -@pytest.fixture -def sms_http_response(): - return HTTPResponse( - status_code=404, - body={ - "text": "Nobody expects the Spanish Inquisition!" - }, - headers={ - "SAMPLE_HEADER": "test" - } - ) - - -@pytest.fixture -def expired_token_http_response(): - return HTTPResponse( - status_code=401, - headers={ - "www-authenticate": "Bearer error='invalid_token', error_description='Jwt expired at...'" - }, - body={} - ) - - @pytest.fixture def auth_token(): return OAuthToken( @@ -416,15 +309,4 @@ def sinch_client_async( verification_origin, voice_origin, disable_ssl - ) - - -@pytest.fixture -def sinch_client_sync_with_service_plan_id( - sinch_client_sync, - service_plan_id, - sms_api_token -): - sinch_client_sync.configuration.service_plan_id = service_plan_id - sinch_client_sync.configuration.sms_api_token = sms_api_token - return sinch_client_sync + ) \ No newline at end of file diff --git a/tests/e2e/authentication/test_token_authentication.py b/tests/e2e/authentication/test_token_authentication.py deleted file mode 100644 index 75a965b8..00000000 --- a/tests/e2e/authentication/test_token_authentication.py +++ /dev/null @@ -1,37 +0,0 @@ -import pytest - -from sinch import SinchClient -from sinch.domains.authentication.models.authentication import OAuthToken -from sinch.domains.authentication.exceptions import AuthenticationException - - -def test_basic_auth_token_generation(sinch_client_sync): - token = sinch_client_sync.authentication.get_auth_token() - assert isinstance(token, OAuthToken) - - -def test_basic_auth_token_generation_invalid_credentials(project_id): - sinch_client = SinchClient( - key_id="silly", - key_secret="walk", - project_id=project_id - ) - with pytest.raises(AuthenticationException): - sinch_client.authentication.get_auth_token() - - -def test_expired_token_refresh(sinch_client_sync, auth_token_as_dict): - sinch_client_sync.authentication.set_auth_token(auth_token_as_dict) - - token = sinch_client_sync.authentication.get_auth_token() - assert isinstance(token, OAuthToken) - - -async def test_basic_auth_token_generation_async(sinch_client_async): - token = await sinch_client_async.authentication.get_auth_token() - assert isinstance(token, OAuthToken) - - -def test_basic_auth_token_generation_sync(sinch_client_sync): - token = sinch_client_sync.authentication.get_auth_token() - assert isinstance(token, OAuthToken) diff --git a/tests/e2e/conversation/app/test_create_app.py b/tests/e2e/conversation/app/test_create_app.py deleted file mode 100644 index e37b3c73..00000000 --- a/tests/e2e/conversation/app/test_create_app.py +++ /dev/null @@ -1,37 +0,0 @@ -from sinch.domains.conversation.models.app.responses import CreateConversationAppResponse -from sinch.domains.conversation.models import SinchConversationTelegramCredentials, SinchConversationChannelCredentials -from sinch.domains.conversation.enums import ConversationRetentionPolicyType, ConversationChannel - - -def test_create_app(sinch_client_sync): - create_app_response = sinch_client_sync.conversation.app.create( - display_name="Shrubbery", - channel_credentials=[ - { - "channel": ConversationChannel.TELEGRAM.value, - "telegram_credentials": { - "token": "herring" - } - } - ], - retention_policy={ - "ttl_days": 20, - "retention_type": ConversationRetentionPolicyType.MESSAGE_EXPIRE_POLICY.value - } - ) - assert isinstance(create_app_response, CreateConversationAppResponse) - - -async def test_create_app_using_dataclass(sinch_client_async): - telegram_credentials = SinchConversationChannelCredentials( - channel=ConversationChannel.TELEGRAM.value, - telegram_credentials=SinchConversationTelegramCredentials(token="Knights of Ni!") - ) - - new_sinch_app = { - "display_name": "Dataclass", - "channel_credentials": [telegram_credentials] - } - - create_app_response = await sinch_client_async.conversation.app.create(**new_sinch_app) - assert isinstance(create_app_response, CreateConversationAppResponse) diff --git a/tests/e2e/conversation/app/test_delete_app.py b/tests/e2e/conversation/app/test_delete_app.py deleted file mode 100644 index be0272e1..00000000 --- a/tests/e2e/conversation/app/test_delete_app.py +++ /dev/null @@ -1,19 +0,0 @@ -from sinch.domains.conversation.models.app.responses import DeleteConversationAppResponse - - -def test_delete_conversation_app(sinch_client_sync): - list_apps_response = sinch_client_sync.conversation.app.list() - - delete_app_response = sinch_client_sync.conversation.app.delete( - app_id=list_apps_response.apps[0].id - ) - assert isinstance(delete_app_response, DeleteConversationAppResponse) - - -async def test_delete_conversation_app_async(sinch_client_async): - list_apps_response = await sinch_client_async.conversation.app.list() - - delete_app_response = await sinch_client_async.conversation.app.delete( - app_id=list_apps_response.apps[0].id - ) - assert isinstance(delete_app_response, DeleteConversationAppResponse) diff --git a/tests/e2e/conversation/app/test_get_app.py b/tests/e2e/conversation/app/test_get_app.py deleted file mode 100644 index d8b97fd5..00000000 --- a/tests/e2e/conversation/app/test_get_app.py +++ /dev/null @@ -1,19 +0,0 @@ -from sinch.domains.conversation.models.app.responses import GetConversationAppResponse - - -def test_get_conversation_app(sinch_client_sync): - list_apps_response = sinch_client_sync.conversation.app.list() - - get_app_response = sinch_client_sync.conversation.app.get( - app_id=list_apps_response.apps[0].id - ) - assert isinstance(get_app_response, GetConversationAppResponse) - - -async def test_get_conversation_app_async(sinch_client_async, sinch_client_sync): - list_apps_response = sinch_client_sync.conversation.app.list() - - get_app_response = await sinch_client_async.conversation.app.get( - app_id=list_apps_response.apps[0].id - ) - assert isinstance(get_app_response, GetConversationAppResponse) diff --git a/tests/e2e/conversation/app/test_list_apps.py b/tests/e2e/conversation/app/test_list_apps.py deleted file mode 100644 index 5c4643e4..00000000 --- a/tests/e2e/conversation/app/test_list_apps.py +++ /dev/null @@ -1,18 +0,0 @@ -from sinch.domains.conversation.models.app.responses import ListConversationAppsResponse - - -def test_list_conversation_apps(sinch_client_sync): - list_apps_response = sinch_client_sync.conversation.app.list() - assert isinstance(list_apps_response, ListConversationAppsResponse) - - -async def test_list_conversation_apps_async(sinch_client_async): - list_apps_response = await sinch_client_async.conversation.app.list() - assert isinstance(list_apps_response, ListConversationAppsResponse) - - -async def test_list_conversation_apps_empty_response_async(sinch_client_async, empty_project_id): - sinch_client_async.configuration.project_id = empty_project_id - list_apps_response = await sinch_client_async.conversation.app.list() - assert isinstance(list_apps_response, ListConversationAppsResponse) - assert len(list_apps_response.apps) == 0 diff --git a/tests/e2e/conversation/app/test_update_app.py b/tests/e2e/conversation/app/test_update_app.py deleted file mode 100644 index 5354155d..00000000 --- a/tests/e2e/conversation/app/test_update_app.py +++ /dev/null @@ -1,21 +0,0 @@ -from sinch.domains.conversation.models.app.responses import UpdateConversationAppResponse - - -def test_update_conversation_app(sinch_client_sync): - list_apps_response = sinch_client_sync.conversation.app.list() - - update_app_response = sinch_client_sync.conversation.app.update( - app_id=list_apps_response.apps[0].id, - display_name="Test2222" - ) - assert isinstance(update_app_response, UpdateConversationAppResponse) - - -async def test_update_conversation_app_async(sinch_client_sync, sinch_client_async): - list_apps_response = sinch_client_sync.conversation.app.list() - - update_app_response = await sinch_client_async.conversation.app.update( - app_id=list_apps_response.apps[0].id, - display_name="Test2222" - ) - assert isinstance(update_app_response, UpdateConversationAppResponse) diff --git a/tests/e2e/conversation/contact/test_create_contact.py b/tests/e2e/conversation/contact/test_create_contact.py deleted file mode 100644 index 57c87bf5..00000000 --- a/tests/e2e/conversation/contact/test_create_contact.py +++ /dev/null @@ -1,55 +0,0 @@ -from sinch.domains.conversation.models.contact.responses import CreateConversationContactResponse -from sinch.domains.conversation.enums import ConversationChannel - - -def test_create_sms_contact(sinch_client_sync, phone_number): - sms_contact_response = sinch_client_sync.conversation.contact.create( - channel_identities=[ - { - "channel": ConversationChannel.SMS.value, - "identity": "12345673932" - } - ], - language="PL", - display_name="Guido van Rossum", - email="sample@email.com", - metadata="test" - ) - assert isinstance(sms_contact_response, CreateConversationContactResponse) - assert sms_contact_response.display_name == "Guido van Rossum" - - -def test_create_messanger_contact(sinch_client_sync, phone_number): - list_apps_response = sinch_client_sync.conversation.app.list() - messanger_contact_response = sinch_client_sync.conversation.contact.create( - channel_identities=[ - { - "channel": ConversationChannel.MESSENGER.value, - "identity": "Sebastian4", - "app_id": list_apps_response.apps[0].id - } - ], - language="PL", - display_name="Sebastian", - email="sebastian@email.com", - metadata="test" - ) - assert isinstance(messanger_contact_response, CreateConversationContactResponse) - assert messanger_contact_response.display_name == "Sebastian" - - -async def test_create_sms_contact_async(sinch_client_async, phone_number): - sms_contact_response = await sinch_client_async.conversation.contact.create( - channel_identities=[ - { - "channel": ConversationChannel.SMS.value, - "identity": "12345673932" - } - ], - language="PL", - display_name="Guido van Rossum", - email="sample@email.com", - metadata="test" - ) - assert isinstance(sms_contact_response, CreateConversationContactResponse) - assert sms_contact_response.display_name == "Guido van Rossum" diff --git a/tests/e2e/conversation/contact/test_delete_contact.py b/tests/e2e/conversation/contact/test_delete_contact.py deleted file mode 100644 index 63cab865..00000000 --- a/tests/e2e/conversation/contact/test_delete_contact.py +++ /dev/null @@ -1,21 +0,0 @@ -from sinch.domains.conversation.models.contact.responses import ListConversationContactsResponse, DeleteConversationContactResponse - - -def test_delete_contact(sinch_client_sync): - list_contacts_response = sinch_client_sync.conversation.contact.list() - assert isinstance(list_contacts_response.result, ListConversationContactsResponse) - - delete_contact_response = sinch_client_sync.conversation.contact.delete( - contact_id=list_contacts_response.result.contacts[-1].id - ) - assert isinstance(delete_contact_response, DeleteConversationContactResponse) - - -async def test_delete_contact_async(sinch_client_async): - list_contacts_response = await sinch_client_async.conversation.contact.list() - assert isinstance(list_contacts_response.result, ListConversationContactsResponse) - - delete_contact_response = await sinch_client_async.conversation.contact.delete( - contact_id=list_contacts_response.result.contacts[-1].id - ) - assert isinstance(delete_contact_response, DeleteConversationContactResponse) diff --git a/tests/e2e/conversation/contact/test_get_channel_profile.py b/tests/e2e/conversation/contact/test_get_channel_profile.py deleted file mode 100644 index 1b24a28c..00000000 --- a/tests/e2e/conversation/contact/test_get_channel_profile.py +++ /dev/null @@ -1,38 +0,0 @@ -import pytest - -from sinch.domains.conversation.models.contact.responses import ( - GetConversationChannelProfileResponse, - ListConversationContactsResponse -) - - -@pytest.mark.skip(reason="More advanced testing setup required.") # TODO: fix that -def test_get_channel_profile(sinch_client_sync): - list_contacts_response = sinch_client_sync.conversation.contact.list() - list_apps_response = sinch_client_sync.conversation.app.list() - assert isinstance(list_contacts_response.result, ListConversationContactsResponse) - - get_profile_response = sinch_client_sync.conversation.contact.get_channel_profile( - channel="MESSENGER", - recipient={ - "contact_id": list_contacts_response.result.contacts[0].id - }, - app_id=list_apps_response.apps[0].id - ) - assert isinstance(get_profile_response.result, GetConversationChannelProfileResponse) - - -@pytest.mark.skip(reason="More advanced testing setup required.") # TODO: fix that -async def test_get_channel_profile_async(sinch_client_async): - list_apps_response = await sinch_client_async.conversation.app.list() - list_contacts_response = await sinch_client_async.conversation.contact.list() - assert isinstance(list_contacts_response.result, ListConversationContactsResponse) - - get_profile_response = await sinch_client_async.conversation.contact.get_channel_profile( - channel="MESSENGER", - recipient={ - "contact_id": list_contacts_response.result.contacts[0].id - }, - app_id=list_apps_response.apps[0].id - ) - assert isinstance(get_profile_response.result, GetConversationChannelProfileResponse) diff --git a/tests/e2e/conversation/contact/test_get_contact.py b/tests/e2e/conversation/contact/test_get_contact.py deleted file mode 100644 index 07b9029b..00000000 --- a/tests/e2e/conversation/contact/test_get_contact.py +++ /dev/null @@ -1,24 +0,0 @@ -from sinch.domains.conversation.models.contact.responses import ( - ListConversationContactsResponse, - GetConversationContactResponse -) - - -def test_get_contact(sinch_client_sync): - list_contacts_response = sinch_client_sync.conversation.contact.list() - assert isinstance(list_contacts_response.result, ListConversationContactsResponse) - - get_contact_response = sinch_client_sync.conversation.contact.get( - contact_id=list_contacts_response.result.contacts[0].id - ) - assert isinstance(get_contact_response, GetConversationContactResponse) - - -async def test_get_contact_async(sinch_client_async): - list_contacts_response = await sinch_client_async.conversation.contact.list() - assert isinstance(list_contacts_response.result, ListConversationContactsResponse) - - get_contact_response = await sinch_client_async.conversation.contact.get( - contact_id=list_contacts_response.result.contacts[0].id - ) - assert isinstance(get_contact_response, GetConversationContactResponse) diff --git a/tests/e2e/conversation/contact/test_list_contact.py b/tests/e2e/conversation/contact/test_list_contact.py deleted file mode 100644 index c2396941..00000000 --- a/tests/e2e/conversation/contact/test_list_contact.py +++ /dev/null @@ -1,42 +0,0 @@ -from sinch.domains.conversation.models.contact.responses import ListConversationContactsResponse -from sinch.core.pagination import TokenBasedPaginator, AsyncTokenBasedPaginator - - -def test_list_contacts_sync_limit_1(sinch_client_sync): - list_contacts_response = sinch_client_sync.conversation.contact.list( - page_size=1 - ) - assert isinstance(list_contacts_response.result, ListConversationContactsResponse) - assert len(list_contacts_response.result.contacts) == 1 - - -async def test_list_contacts_async(sinch_client_async): - list_contacts_response = await sinch_client_async.conversation.contact.list() - assert isinstance(list_contacts_response.result, ListConversationContactsResponse) - assert len(list_contacts_response.result.contacts) > 0 - - -def test_list_contacts_using_auto_pagination_sync(sinch_client_sync): - list_contacts_response = sinch_client_sync.conversation.contact.list( - page_size=1 - ) - page_counter = 1 - - for page in list_contacts_response.auto_paging_iter(): - assert isinstance(page, TokenBasedPaginator) - page_counter += 1 - - assert page_counter > 1 - - -async def test_list_contacts_using_auto_pagination_async(sinch_client_async): - list_contacts_response = await sinch_client_async.conversation.contact.list( - page_size=1 - ) - page_counter = 1 - - async for page in list_contacts_response.auto_paging_iter(): - assert isinstance(page, AsyncTokenBasedPaginator) - page_counter += 1 - - assert page_counter > 1 diff --git a/tests/e2e/conversation/contact/test_merge_contacts.py b/tests/e2e/conversation/contact/test_merge_contacts.py deleted file mode 100644 index bf1279ef..00000000 --- a/tests/e2e/conversation/contact/test_merge_contacts.py +++ /dev/null @@ -1,26 +0,0 @@ -from sinch.domains.conversation.models.contact.responses import ( - MergeConversationContactsResponse, - ListConversationContactsResponse -) - - -def test_merge_contacts(sinch_client_sync): - list_contacts_response = sinch_client_sync.conversation.contact.list() - assert isinstance(list_contacts_response.result, ListConversationContactsResponse) - - merge_contacts_response = sinch_client_sync.conversation.contact.merge( - source_id=list_contacts_response.result.contacts[1].id, - destination_id=list_contacts_response.result.contacts[0].id - ) - assert isinstance(merge_contacts_response, MergeConversationContactsResponse) - - -async def test_merge_contacts_async(sinch_client_async): - list_contacts_response = await sinch_client_async.conversation.contact.list() - assert isinstance(list_contacts_response.result, ListConversationContactsResponse) - - merge_contacts_response = await sinch_client_async.conversation.contact.merge( - source_id=list_contacts_response.result.contacts[1].id, - destination_id=list_contacts_response.result.contacts[0].id - ) - assert isinstance(merge_contacts_response, MergeConversationContactsResponse) diff --git a/tests/e2e/conversation/contact/test_update_contact.py b/tests/e2e/conversation/contact/test_update_contact.py deleted file mode 100644 index 03085935..00000000 --- a/tests/e2e/conversation/contact/test_update_contact.py +++ /dev/null @@ -1,32 +0,0 @@ -from sinch.domains.conversation.models.contact.responses import ( - UpdateConversationContactResponse, - ListConversationContactsResponse -) - - -def test_update_sms_contact(sinch_client_sync, phone_number): - list_contacts_response = sinch_client_sync.conversation.contact.list() - assert isinstance(list_contacts_response.result, ListConversationContactsResponse) - - update_contact_response = sinch_client_sync.conversation.contact.update( - contact_id=list_contacts_response.result.contacts[0].id, - email="tytusb@sample.pl", - display_name="Tytus Bomba", - language="PL" - ) - assert isinstance(update_contact_response, UpdateConversationContactResponse) - assert update_contact_response.email != list_contacts_response.result.contacts[0].email - - -async def test_update_sms_contact_async(sinch_client_async, phone_number): - list_contacts_response = await sinch_client_async.conversation.contact.list() - assert isinstance(list_contacts_response.result, ListConversationContactsResponse) - - update_contact_response = await sinch_client_async.conversation.contact.update( - contact_id=list_contacts_response.result.contacts[0].id, - email="tytusb@sample.pl", - display_name="Tytus Bomba", - language="PL" - ) - assert isinstance(update_contact_response, UpdateConversationContactResponse) - assert update_contact_response.email != list_contacts_response.result.contacts[0].email diff --git a/tests/e2e/conversation/conversation/test_create_conversation.py b/tests/e2e/conversation/conversation/test_create_conversation.py deleted file mode 100644 index 0b4cc722..00000000 --- a/tests/e2e/conversation/conversation/test_create_conversation.py +++ /dev/null @@ -1,21 +0,0 @@ -from sinch.domains.conversation.models.conversation.responses import SinchCreateConversationResponse - - -def test_create_conversation(sinch_client_sync, app_id): - list_contacts_response = sinch_client_sync.conversation.contact.list() - create_conversation_response = sinch_client_sync.conversation.conversation.create( - app_id=app_id, - active=True, - contact_id=list_contacts_response.result.contacts[0].id - ) - assert isinstance(create_conversation_response, SinchCreateConversationResponse) - - -async def test_create_conversation_async(sinch_client_async, app_id): - list_contacts_response = await sinch_client_async.conversation.contact.list() - create_conversation_response = await sinch_client_async.conversation.conversation.create( - app_id=app_id, - active=True, - contact_id=list_contacts_response.result.contacts[0].id - ) - assert isinstance(create_conversation_response, SinchCreateConversationResponse) diff --git a/tests/e2e/conversation/conversation/test_delete_conversation.py b/tests/e2e/conversation/conversation/test_delete_conversation.py deleted file mode 100644 index 698bbb69..00000000 --- a/tests/e2e/conversation/conversation/test_delete_conversation.py +++ /dev/null @@ -1,27 +0,0 @@ -from sinch.domains.conversation.models.conversation.responses import SinchDeleteConversationResponse - - -def test_delete_conversation(sinch_client_sync, app_id): - list_contacts_response = sinch_client_sync.conversation.contact.list() - list_conversations_response = sinch_client_sync.conversation.conversation.list( - only_active=False, - contact_id=list_contacts_response.result.contacts[0].id - ) - - delete_conversation_response = sinch_client_sync.conversation.conversation.delete( - conversation_id=list_conversations_response.result.conversations[-1].id - ) - assert isinstance(delete_conversation_response, SinchDeleteConversationResponse) - - -async def test_delete_conversation_async(sinch_client_async, app_id): - list_contacts_response = await sinch_client_async.conversation.contact.list() - list_conversations_response = await sinch_client_async.conversation.conversation.list( - only_active=False, - contact_id=list_contacts_response.result.contacts[0].id - ) - - delete_conversation_response = await sinch_client_async.conversation.conversation.delete( - conversation_id=list_conversations_response.result.conversations[-1].id - ) - assert isinstance(delete_conversation_response, SinchDeleteConversationResponse) diff --git a/tests/e2e/conversation/conversation/test_get_conversation.py b/tests/e2e/conversation/conversation/test_get_conversation.py deleted file mode 100644 index 4b5d359a..00000000 --- a/tests/e2e/conversation/conversation/test_get_conversation.py +++ /dev/null @@ -1,27 +0,0 @@ -from sinch.domains.conversation.models.conversation.responses import SinchGetConversationResponse - - -def test_get_conversation(sinch_client_sync, app_id): - list_contacts_response = sinch_client_sync.conversation.contact.list() - list_conversations_response = sinch_client_sync.conversation.conversation.list( - only_active=False, - contact_id=list_contacts_response.result.contacts[0].id - ) - - get_conversation_response = sinch_client_sync.conversation.conversation.get( - conversation_id=list_conversations_response.result.conversations[0].id - ) - assert isinstance(get_conversation_response, SinchGetConversationResponse) - - -async def test_get_conversation_async(sinch_client_async, app_id): - list_contacts_response = await sinch_client_async.conversation.contact.list() - list_conversations_response = await sinch_client_async.conversation.conversation.list( - only_active=False, - contact_id=list_contacts_response.result.contacts[0].id - ) - - get_conversation_response = await sinch_client_async.conversation.conversation.get( - conversation_id=list_conversations_response.result.conversations[0].id - ) - assert isinstance(get_conversation_response, SinchGetConversationResponse) diff --git a/tests/e2e/conversation/conversation/test_inject_messages.py b/tests/e2e/conversation/conversation/test_inject_messages.py deleted file mode 100644 index 679c8448..00000000 --- a/tests/e2e/conversation/conversation/test_inject_messages.py +++ /dev/null @@ -1,34 +0,0 @@ -import pytest -from sinch.domains.conversation.models.conversation.responses import SinchInjectMessageResponse - - -@pytest.mark.skip(reason="More advanced testing setup required.") # TODO: fix that -def test_inject_message_to_conversation(sinch_client_sync): - list_contacts_response = sinch_client_sync.conversation.contact.list() - list_conversations_response = sinch_client_sync.conversation.conversation.list( - only_active=False, - contact_id=list_contacts_response.result.contacts[0].id - ) - inject_message_response = sinch_client_sync.conversation.conversation.inject_message_to_conversation( - conversation_id=list_conversations_response.result.conversations[0].id, - direction="TO_APP", - contact_message={}, - channel_identity={} - ) - assert isinstance(inject_message_response, SinchInjectMessageResponse) - - -@pytest.mark.skip(reason="More advanced testing setup required.") # TODO: fix that -async def test_inject_message_to_conversation_async(sinch_client_async): - list_contacts_response = await sinch_client_async.conversation.contact.list() - list_conversations_response = await sinch_client_async.conversation.conversation.list( - only_active=False, - contact_id=list_contacts_response.result.contacts[0].id - ) - stop_conversation_response = await sinch_client_async.conversation.conversation.inject_message_to_conversation( - conversation_id=list_conversations_response.result.conversations[0].id, - direction="TO_APP", - contact_message={}, - channel_identity={} - ) - assert isinstance(stop_conversation_response, SinchInjectMessageResponse) diff --git a/tests/e2e/conversation/conversation/test_list_conversation.py b/tests/e2e/conversation/conversation/test_list_conversation.py deleted file mode 100644 index 4f40e93d..00000000 --- a/tests/e2e/conversation/conversation/test_list_conversation.py +++ /dev/null @@ -1,19 +0,0 @@ -from sinch.domains.conversation.models.conversation.responses import SinchListConversationsResponse - - -def test_list_conversation(sinch_client_sync): - list_contacts_response = sinch_client_sync.conversation.contact.list() - list_conversations_response = sinch_client_sync.conversation.conversation.list( - only_active=False, - contact_id=list_contacts_response.result.contacts[0].id - ) - assert isinstance(list_conversations_response.result, SinchListConversationsResponse) - - -async def test_list_conversation_async(sinch_client_async): - list_contacts_response = await sinch_client_async.conversation.contact.list() - list_conversations_response = await sinch_client_async.conversation.conversation.list( - only_active=False, - contact_id=list_contacts_response.result.contacts[0].id - ) - assert isinstance(list_conversations_response.result, SinchListConversationsResponse) diff --git a/tests/e2e/conversation/conversation/test_stop_conversation.py b/tests/e2e/conversation/conversation/test_stop_conversation.py deleted file mode 100644 index b968c497..00000000 --- a/tests/e2e/conversation/conversation/test_stop_conversation.py +++ /dev/null @@ -1,25 +0,0 @@ -from sinch.domains.conversation.models.conversation.responses import SinchStopConversationResponse - - -def test_stop_conversation_sync(sinch_client_sync): - list_contacts_response = sinch_client_sync.conversation.contact.list() - list_conversations_response = sinch_client_sync.conversation.conversation.list( - only_active=False, - contact_id=list_contacts_response.result.contacts[0].id - ) - stop_conversation_response = sinch_client_sync.conversation.conversation.stop( - conversation_id=list_conversations_response.result.conversations[1].id - ) - assert isinstance(stop_conversation_response, SinchStopConversationResponse) - - -async def test_stop_conversation_async(sinch_client_async): - list_contacts_response = await sinch_client_async.conversation.contact.list() - list_conversations_response = await sinch_client_async.conversation.conversation.list( - only_active=False, - contact_id=list_contacts_response.result.contacts[0].id - ) - stop_conversation_response = await sinch_client_async.conversation.conversation.stop( - conversation_id=list_conversations_response.result.conversations[1].id - ) - assert isinstance(stop_conversation_response, SinchStopConversationResponse) diff --git a/tests/e2e/conversation/conversation/test_update_conversation.py b/tests/e2e/conversation/conversation/test_update_conversation.py deleted file mode 100644 index 00341db1..00000000 --- a/tests/e2e/conversation/conversation/test_update_conversation.py +++ /dev/null @@ -1,29 +0,0 @@ -from sinch.domains.conversation.models.conversation.responses import SinchUpdateConversationResponse - - -def test_update_conversation(sinch_client_sync): - list_contacts_response = sinch_client_sync.conversation.contact.list() - list_conversations_response = sinch_client_sync.conversation.conversation.list( - only_active=False, - contact_id=list_contacts_response.result.contacts[0].id - ) - - update_conversation_response = sinch_client_sync.conversation.conversation.update( - active=False, - conversation_id=list_conversations_response.result.conversations[0].id - ) - assert isinstance(update_conversation_response, SinchUpdateConversationResponse) - - -async def test_update_conversation_async(sinch_client_async): - list_contacts_response = await sinch_client_async.conversation.contact.list() - list_conversations_response = await sinch_client_async.conversation.conversation.list( - only_active=False, - contact_id=list_contacts_response.result.contacts[0].id - ) - - update_conversation_response = await sinch_client_async.conversation.conversation.update( - active=False, - conversation_id=list_conversations_response.result.conversations[0].id - ) - assert isinstance(update_conversation_response, SinchUpdateConversationResponse) diff --git a/tests/e2e/conversation/message/test_delete_message.py b/tests/e2e/conversation/message/test_delete_message.py deleted file mode 100644 index 4d24a894..00000000 --- a/tests/e2e/conversation/message/test_delete_message.py +++ /dev/null @@ -1,23 +0,0 @@ -from sinch.domains.conversation.models.message.responses import DeleteConversationMessageResponse - - -def test_delete_message(sinch_client_sync, app_id): - list_contacts_response = sinch_client_sync.conversation.contact.list() - list_messages_response = sinch_client_sync.conversation.message.list( - contact_id=list_contacts_response.result.contacts[0].id - ) - delete_message_response = sinch_client_sync.conversation.message.delete( - message_id=list_messages_response.result.messages[0].id - ) - assert isinstance(delete_message_response, DeleteConversationMessageResponse) - - -async def test_delete_message_async(sinch_client_async, app_id): - list_contacts_response = await sinch_client_async.conversation.contact.list() - list_messages_response = await sinch_client_async.conversation.message.list( - contact_id=list_contacts_response.result.contacts[0].id - ) - delete_message_response = await sinch_client_async.conversation.message.delete( - message_id=list_messages_response.result.messages[0].id - ) - assert isinstance(delete_message_response, DeleteConversationMessageResponse) diff --git a/tests/e2e/conversation/message/test_get_message.py b/tests/e2e/conversation/message/test_get_message.py deleted file mode 100644 index 21fefe29..00000000 --- a/tests/e2e/conversation/message/test_get_message.py +++ /dev/null @@ -1,23 +0,0 @@ -from sinch.domains.conversation.models.message.responses import GetConversationMessageResponse - - -def test_get_message(sinch_client_sync, app_id): - list_contacts_response = sinch_client_sync.conversation.contact.list() - list_messages_response = sinch_client_sync.conversation.message.list( - contact_id=list_contacts_response.result.contacts[0].id - ) - get_message_response = sinch_client_sync.conversation.message.get( - message_id=list_messages_response.result.messages[0].id - ) - assert isinstance(get_message_response, GetConversationMessageResponse) - - -async def test_get_message_async(sinch_client_async, app_id): - list_contacts_response = await sinch_client_async.conversation.contact.list() - list_messages_response = await sinch_client_async.conversation.message.list( - contact_id=list_contacts_response.result.contacts[0].id - ) - get_message_response = await sinch_client_async.conversation.message.get( - message_id=list_messages_response.result.messages[0].id - ) - assert isinstance(get_message_response, GetConversationMessageResponse) diff --git a/tests/e2e/conversation/message/test_list_message.py b/tests/e2e/conversation/message/test_list_message.py deleted file mode 100644 index 00568c21..00000000 --- a/tests/e2e/conversation/message/test_list_message.py +++ /dev/null @@ -1,17 +0,0 @@ -from sinch.domains.conversation.models.message.responses import ListConversationMessagesResponse - - -def test_list_message(sinch_client_sync): - list_contacts_response = sinch_client_sync.conversation.contact.list() - list_messages_response = sinch_client_sync.conversation.message.list( - contact_id=list_contacts_response.result.contacts[0].id - ) - assert isinstance(list_messages_response.result, ListConversationMessagesResponse) - - -async def test_list_message_async(sinch_client_async): - list_contacts_response = await sinch_client_async.conversation.contact.list() - list_messages_response = await sinch_client_async.conversation.message.list( - contact_id=list_contacts_response.result.contacts[0].id - ) - assert isinstance(list_messages_response.result, ListConversationMessagesResponse) diff --git a/tests/e2e/conversation/message/test_send_message.py b/tests/e2e/conversation/message/test_send_message.py deleted file mode 100644 index 8fc914c8..00000000 --- a/tests/e2e/conversation/message/test_send_message.py +++ /dev/null @@ -1,33 +0,0 @@ -from sinch.domains.conversation.models.message.responses import SendConversationMessageResponse - - -def test_send_message_messenger_contact(sinch_client_sync, app_id): - list_contacts_response = sinch_client_sync.conversation.contact.list() - send_message_response = sinch_client_sync.conversation.message.send( - app_id=app_id, - recipient={ - "contact_id": list_contacts_response.result.contacts[0].id - }, - message={ - "text_message": { - "text": "Kluski, rolada i modro kapusta." - } - } - ) - assert isinstance(send_message_response, SendConversationMessageResponse) - - -async def test_send_message_messenger_contact_async(sinch_client_async, app_id): - list_contacts_response = await sinch_client_async.conversation.contact.list() - send_message_response = await sinch_client_async.conversation.message.send( - app_id=app_id, - recipient={ - "contact_id": list_contacts_response.result.contacts[0].id - }, - message={ - "text_message": { - "text": "Kluski, rolada i modro kapusta." - } - } - ) - assert isinstance(send_message_response, SendConversationMessageResponse) diff --git a/tests/e2e/conversation/templates/test_create_template.py b/tests/e2e/conversation/templates/test_create_template.py deleted file mode 100644 index 72f96b12..00000000 --- a/tests/e2e/conversation/templates/test_create_template.py +++ /dev/null @@ -1,36 +0,0 @@ -from sinch.domains.conversation.models.templates.responses import CreateConversationTemplateResponse - - -def test_create_template(sinch_client_sync): - create_template_response = sinch_client_sync.conversation.template.create( - channel="SMS", - description="pigdog", - default_translation="pl-PL", - translations=[ - {"language_code": "pl-PL"} - ] - - ) - assert isinstance(create_template_response, CreateConversationTemplateResponse) - - -def test_create_empty_template(sinch_client_sync): - create_template_response = sinch_client_sync.conversation.template.create( - default_translation="pl-PL", - translations=[ - {"language_code": "pl-PL"} - ] - ) - assert isinstance(create_template_response, CreateConversationTemplateResponse) - - -async def test_create_template_async(sinch_client_async): - create_template_response = await sinch_client_async.conversation.template.create( - channel="SMS", - description="pigdog", - default_translation="pl-PL", - translations=[ - {"language_code": "pl-PL"} - ] - ) - assert isinstance(create_template_response, CreateConversationTemplateResponse) diff --git a/tests/e2e/conversation/templates/test_delete_template.py b/tests/e2e/conversation/templates/test_delete_template.py deleted file mode 100644 index 28febfb5..00000000 --- a/tests/e2e/conversation/templates/test_delete_template.py +++ /dev/null @@ -1,17 +0,0 @@ -from sinch.domains.conversation.models.templates.responses import DeleteConversationTemplateResponse - - -def test_delete_template(sinch_client_sync): - list_template_response = sinch_client_sync.conversation.template.list() - delete_template_response = sinch_client_sync.conversation.template.delete( - template_id=list_template_response.templates[0].id - ) - assert isinstance(delete_template_response, DeleteConversationTemplateResponse) - - -async def test_delete_template_async(sinch_client_async): - list_template_response = await sinch_client_async.conversation.template.list() - delete_template_response = await sinch_client_async.conversation.template.delete( - template_id=list_template_response.templates[0].id - ) - assert isinstance(delete_template_response, DeleteConversationTemplateResponse) diff --git a/tests/e2e/conversation/templates/test_get_template.py b/tests/e2e/conversation/templates/test_get_template.py deleted file mode 100644 index 7743928b..00000000 --- a/tests/e2e/conversation/templates/test_get_template.py +++ /dev/null @@ -1,17 +0,0 @@ -from sinch.domains.conversation.models.templates.responses import GetConversationTemplateResponse - - -def test_get_template(sinch_client_sync): - list_template_response = sinch_client_sync.conversation.template.list() - get_template_response = sinch_client_sync.conversation.template.get( - template_id=list_template_response.templates[0].id - ) - assert isinstance(get_template_response, GetConversationTemplateResponse) - - -def test_get_template_async(sinch_client_sync): - list_template_response = sinch_client_sync.conversation.template.list() - get_template_response = sinch_client_sync.conversation.template.get( - template_id=list_template_response.templates[0].id - ) - assert isinstance(get_template_response, GetConversationTemplateResponse) diff --git a/tests/e2e/conversation/templates/test_list_templates.py b/tests/e2e/conversation/templates/test_list_templates.py deleted file mode 100644 index 350c420f..00000000 --- a/tests/e2e/conversation/templates/test_list_templates.py +++ /dev/null @@ -1,11 +0,0 @@ -from sinch.domains.conversation.models.templates.responses import ListConversationTemplatesResponse - - -def test_list_templates(sinch_client_sync): - list_template_response = sinch_client_sync.conversation.template.list() - assert isinstance(list_template_response, ListConversationTemplatesResponse) - - -async def test_list_templates_async(sinch_client_async): - list_template_response = await sinch_client_async.conversation.template.list() - assert isinstance(list_template_response, ListConversationTemplatesResponse) diff --git a/tests/e2e/conversation/templates/test_update_template.py b/tests/e2e/conversation/templates/test_update_template.py deleted file mode 100644 index e595a56a..00000000 --- a/tests/e2e/conversation/templates/test_update_template.py +++ /dev/null @@ -1,27 +0,0 @@ -from sinch.domains.conversation.models.templates.responses import UpdateConversationTemplateResponse - - -def test_update_template(sinch_client_sync): - list_template_response = sinch_client_sync.conversation.template.list() - update_template_response = sinch_client_sync.conversation.template.update( - template_id=list_template_response.templates[0].id, - description="KWK_Wójek", - default_translation="pl-PL", - translations=[ - {"language_code": "pl-PL"} - ] - ) - assert isinstance(update_template_response, UpdateConversationTemplateResponse) - - -async def test_update_template_async(sinch_client_sync, sinch_client_async): - list_template_response = sinch_client_sync.conversation.template.list() - update_template_response = await sinch_client_async.conversation.template.update( - template_id=list_template_response.templates[0].id, - description="KWK_Wójek", - default_translation="pl-PL", - translations=[ - {"language_code": "pl-PL"} - ] - ) - assert isinstance(update_template_response, UpdateConversationTemplateResponse) diff --git a/tests/e2e/conversation/test_capability.py b/tests/e2e/conversation/test_capability.py deleted file mode 100644 index 7b8d1ded..00000000 --- a/tests/e2e/conversation/test_capability.py +++ /dev/null @@ -1,23 +0,0 @@ -from sinch.domains.conversation.models.capability.responses import QueryConversationCapabilityResponse - - -def test_capability_query(sinch_client_sync, app_id): - list_contacts_response = sinch_client_sync.conversation.contact.list() - query_capability_response = sinch_client_sync.conversation.capability.query( - app_id=app_id, - recipient={ - "contact_id": list_contacts_response.result.contacts[0].id - } - ) - assert isinstance(query_capability_response, QueryConversationCapabilityResponse) - - -async def test_capability_query_async(sinch_client_async, app_id): - list_contacts_response = await sinch_client_async.conversation.contact.list() - query_capability_response = await sinch_client_async.conversation.capability.query( - app_id=app_id, - recipient={ - "contact_id": list_contacts_response.result.contacts[0].id - } - ) - assert isinstance(query_capability_response, QueryConversationCapabilityResponse) diff --git a/tests/e2e/conversation/test_opt_in.py b/tests/e2e/conversation/test_opt_in.py deleted file mode 100644 index 9299322a..00000000 --- a/tests/e2e/conversation/test_opt_in.py +++ /dev/null @@ -1,25 +0,0 @@ -from sinch.domains.conversation.models.opt_in_opt_out.responses import RegisterConversationOptInResponse - - -def test_register_opt_in(sinch_client_sync, app_id): - list_contacts_response = sinch_client_sync.conversation.contact.list() - opt_in_response = sinch_client_sync.conversation.opt_in.register( - app_id=app_id, - recipient={ - "contact_id": list_contacts_response.result.contacts[0].id - }, - channels=["WHATSAPP"] - ) - assert isinstance(opt_in_response, RegisterConversationOptInResponse) - - -async def test_register_opt_in_async(sinch_client_async, app_id): - list_contacts_response = await sinch_client_async.conversation.contact.list() - opt_in_response = await sinch_client_async.conversation.opt_in.register( - app_id=app_id, - recipient={ - "contact_id": list_contacts_response.result.contacts[0].id - }, - channels=["WHATSAPP"] - ) - assert isinstance(opt_in_response, RegisterConversationOptInResponse) diff --git a/tests/e2e/conversation/test_opt_out.py b/tests/e2e/conversation/test_opt_out.py deleted file mode 100644 index 3403a4e7..00000000 --- a/tests/e2e/conversation/test_opt_out.py +++ /dev/null @@ -1,26 +0,0 @@ -from sinch.domains.conversation.models.opt_in_opt_out.responses import RegisterConversationOptOutResponse - - -def test_register_opt_out(sinch_client_sync, app_id): - list_contacts_response = sinch_client_sync.conversation.contact.list() - opt_out_response = sinch_client_sync.conversation.opt_out.register( - app_id=app_id, - recipient={ - "contact_id": list_contacts_response.result.contacts[0].id - }, - channels=["WHATSAPP"] - ) - assert isinstance(opt_out_response, RegisterConversationOptOutResponse) - - -async def test_register_opt_out_async(sinch_client_async, app_id): - list_contacts_response = await sinch_client_async.conversation.contact.list() - opt_out_response = await sinch_client_async.conversation.opt_out.register( - app_id=app_id, - recipient={ - - "contact_id": list_contacts_response.result.contacts[0].id - }, - channels=["WHATSAPP"] - ) - assert isinstance(opt_out_response, RegisterConversationOptOutResponse) diff --git a/tests/e2e/conversation/test_send_events.py b/tests/e2e/conversation/test_send_events.py deleted file mode 100644 index a71d0609..00000000 --- a/tests/e2e/conversation/test_send_events.py +++ /dev/null @@ -1,29 +0,0 @@ -from sinch.domains.conversation.models.event.responses import SendConversationEventResponse - - -def test_send_event(sinch_client_sync, app_id): - list_contacts_response = sinch_client_sync.conversation.contact.list() - send_event_response = sinch_client_sync.conversation.event.send( - app_id=app_id, - recipient={ - "contact_id": list_contacts_response.result.contacts[0].id - }, - event={ - "composing_event": {} - } - ) - assert isinstance(send_event_response, SendConversationEventResponse) - - -async def test_send_event_async(sinch_client_async, app_id): - list_contacts_response = await sinch_client_async.conversation.contact.list() - send_event_response = await sinch_client_async.conversation.event.send( - app_id=app_id, - recipient={ - "contact_id": list_contacts_response.result.contacts[0].id - }, - event={ - "composing_event": {} - } - ) - assert isinstance(send_event_response, SendConversationEventResponse) diff --git a/tests/e2e/conversation/test_transcode.py b/tests/e2e/conversation/test_transcode.py deleted file mode 100644 index f1ee7460..00000000 --- a/tests/e2e/conversation/test_transcode.py +++ /dev/null @@ -1,27 +0,0 @@ -from sinch.domains.conversation.models.transcoding.responses import TranscodeConversationMessageResponse - - -def test_transcode_message(sinch_client_sync, app_id): - transcode_message_response = sinch_client_sync.conversation.transcoding.transcode_message( - app_id=app_id, - app_message={ - "text_message": { - "text": "This is a text message." - } - }, - channels=["TELEGRAM", "SMS"] - ) - assert isinstance(transcode_message_response, TranscodeConversationMessageResponse) - - -async def test_transcode_message_async(sinch_client_async, app_id): - transcode_message_response = await sinch_client_async.conversation.transcoding.transcode_message( - app_id=app_id, - app_message={ - "text_message": { - "text": "This is a text message." - } - }, - channels=["TELEGRAM", "SMS"] - ) - assert isinstance(transcode_message_response, TranscodeConversationMessageResponse) diff --git a/tests/e2e/conversation/webhook/test_create_webhook.py b/tests/e2e/conversation/webhook/test_create_webhook.py deleted file mode 100644 index 5859bb52..00000000 --- a/tests/e2e/conversation/webhook/test_create_webhook.py +++ /dev/null @@ -1,19 +0,0 @@ -from sinch.domains.conversation.models.webhook.responses import CreateWebhookResponse - - -def test_create_webhook(sinch_client_sync, app_id): - create_webhook_response = sinch_client_sync.conversation.webhook.create( - app_id=app_id, - target="http://import.antigravity8.pl", - triggers=["MESSAGE_DELIVERY", "CONTACT_MERGE"] - ) - assert isinstance(create_webhook_response, CreateWebhookResponse) - - -async def test_create_webhook_async(sinch_client_async, app_id): - create_webhook_response = await sinch_client_async.conversation.webhook.create( - app_id=app_id, - target="http://import.antigravity8.pl", - triggers=["MESSAGE_DELIVERY", "CONTACT_MERGE"] - ) - assert isinstance(create_webhook_response, CreateWebhookResponse) diff --git a/tests/e2e/conversation/webhook/test_delete_webhook.py b/tests/e2e/conversation/webhook/test_delete_webhook.py deleted file mode 100644 index 58dd48dc..00000000 --- a/tests/e2e/conversation/webhook/test_delete_webhook.py +++ /dev/null @@ -1,21 +0,0 @@ -from sinch.domains.conversation.models.webhook.responses import SinchDeleteWebhookResponse - - -def test_delete_webhook(sinch_client_sync, app_id): - list_webhook_response = sinch_client_sync.conversation.webhook.list( - app_id=app_id - ) - delete_webhook_response = sinch_client_sync.conversation.webhook.delete( - webhook_id=list_webhook_response.webhooks[0].id - ) - assert isinstance(delete_webhook_response, SinchDeleteWebhookResponse) - - -async def test_delete_webhook_async(sinch_client_async, app_id): - list_webhook_response = await sinch_client_async.conversation.webhook.list( - app_id=app_id, - ) - delete_webhook_response = await sinch_client_async.conversation.webhook.delete( - webhook_id=list_webhook_response.webhooks[0].id - ) - assert isinstance(delete_webhook_response, SinchDeleteWebhookResponse) diff --git a/tests/e2e/conversation/webhook/test_get_webhook.py b/tests/e2e/conversation/webhook/test_get_webhook.py deleted file mode 100644 index 5f45ed4e..00000000 --- a/tests/e2e/conversation/webhook/test_get_webhook.py +++ /dev/null @@ -1,21 +0,0 @@ -from sinch.domains.conversation.models.webhook.responses import GetWebhookResponse - - -def test_get_webhook(sinch_client_sync, app_id): - list_webhook_response = sinch_client_sync.conversation.webhook.list( - app_id=app_id - ) - get_webhook_response = sinch_client_sync.conversation.webhook.get( - webhook_id=list_webhook_response.webhooks[1].id - ) - assert isinstance(get_webhook_response, GetWebhookResponse) - - -async def test_get_webhook_async(sinch_client_async, app_id): - list_webhook_response = await sinch_client_async.conversation.webhook.list( - app_id=app_id - ) - get_webhook_response = await sinch_client_async.conversation.webhook.get( - webhook_id=list_webhook_response.webhooks[1].id - ) - assert isinstance(get_webhook_response, GetWebhookResponse) diff --git a/tests/e2e/conversation/webhook/test_list_webhooks.py b/tests/e2e/conversation/webhook/test_list_webhooks.py deleted file mode 100644 index dfc0d708..00000000 --- a/tests/e2e/conversation/webhook/test_list_webhooks.py +++ /dev/null @@ -1,15 +0,0 @@ -from sinch.domains.conversation.models.webhook.responses import SinchListWebhooksResponse - - -def test_list_webhook(sinch_client_sync, app_id): - list_webhook_response = sinch_client_sync.conversation.webhook.list( - app_id=app_id, - ) - assert isinstance(list_webhook_response, SinchListWebhooksResponse) - - -async def test_list_webhook_async(sinch_client_async, app_id): - list_webhook_response = await sinch_client_async.conversation.webhook.list( - app_id=app_id, - ) - assert isinstance(list_webhook_response, SinchListWebhooksResponse) diff --git a/tests/e2e/conversation/webhook/test_update_webhook.py b/tests/e2e/conversation/webhook/test_update_webhook.py deleted file mode 100644 index 470bd9a6..00000000 --- a/tests/e2e/conversation/webhook/test_update_webhook.py +++ /dev/null @@ -1,27 +0,0 @@ -from sinch.domains.conversation.models.webhook.responses import UpdateWebhookResponse - - -def test_update_webhook(sinch_client_sync, app_id): - list_webhook_response = sinch_client_sync.conversation.webhook.list( - app_id=app_id - ) - update_webhook_response = sinch_client_sync.conversation.webhook.update( - app_id=app_id, - webhook_id=list_webhook_response.webhooks[1].id, - target="http://import.antigravity3.pl", - triggers=["MESSAGE_DELIVERY", "CONTACT_MERGE"] - ) - assert isinstance(update_webhook_response, UpdateWebhookResponse) - - -async def test_update_webhook_async(sinch_client_async, app_id): - list_webhook_response = await sinch_client_async.conversation.webhook.list( - app_id=app_id - ) - update_webhook_response = await sinch_client_async.conversation.webhook.update( - app_id=app_id, - webhook_id=list_webhook_response.webhooks[1].id, - target="http://import.antigravity3.pl", - triggers=["MESSAGE_DELIVERY", "CONTACT_MERGE"] - ) - assert isinstance(update_webhook_response, UpdateWebhookResponse) diff --git a/tests/e2e/numbers/active/test_active_numbers_api.py b/tests/e2e/numbers/active/test_active_numbers_api.py deleted file mode 100644 index a78a9f1b..00000000 --- a/tests/e2e/numbers/active/test_active_numbers_api.py +++ /dev/null @@ -1,126 +0,0 @@ -from sinch.domains.numbers import ListActiveNumbersResponse, UpdateNumberConfigurationResponse, \ - GetNumberConfigurationResponse, ReleaseNumberFromProjectResponse - -from sinch.core.pagination import TokenBasedPaginator, AsyncTokenBasedPaginator - - -def get_active_numbers_for_project(sinch_client_sync): - active_numbers_response = sinch_client_sync.numbers.active.list( - region_code="GB", - number_type="MOBILE" - ) - assert isinstance(active_numbers_response.result, ListActiveNumbersResponse) - return active_numbers_response - - -def test_list_active_numbers(sinch_client_sync): - active_numbers_response = get_active_numbers_for_project( - sinch_client_sync - ) - assert len(active_numbers_response.result.active_numbers) > 0 - - -def test_list_active_numbers_limit_page_size(sinch_client_sync): - active_numbers_response = sinch_client_sync.numbers.active.list( - region_code="GB", - number_type="MOBILE", - page_size=1 - ) - assert len(active_numbers_response.result.active_numbers) == 1 - assert isinstance(active_numbers_response.result, ListActiveNumbersResponse) - - -def test_list_active_numbers_using_manual_pagination(sinch_client_sync): - active_numbers_response = sinch_client_sync.numbers.active.list( - region_code="GB", - number_type="MOBILE", - page_size=1 - ) - page_counter = 1 - - while active_numbers_response.has_next_page: - active_numbers_response = active_numbers_response.next_page() - page_counter += 1 - - assert page_counter > 1 - - -def test_list_active_numbers_using_auto_pagination(sinch_client_sync): - active_numbers_response = sinch_client_sync.numbers.active.list( - region_code="GB", - number_type="MOBILE", - page_size=1 - ) - page_counter = 1 - - for page in active_numbers_response.auto_paging_iter(): - assert isinstance(page, TokenBasedPaginator) - page_counter += 1 - - assert page_counter > 1 - - -def test_list_active_numbers_using_number_pattern(sinch_client_sync): - active_numbers_response = sinch_client_sync.numbers.active.list( - region_code="GB", - number_type="MOBILE", - number_pattern="626", - number_search_pattern="END" - ) - assert "626" in active_numbers_response.result.active_numbers[0].phone_number - - -async def test_list_active_numbers_using_manual_pagination_async(sinch_client_async): - active_numbers_response = await sinch_client_async.numbers.active.list( - region_code="GB", - number_type="MOBILE", - page_size=1 - ) - page_counter = 1 - - while active_numbers_response.has_next_page: - active_numbers_response = await active_numbers_response.next_page() - page_counter += 1 - - assert isinstance(active_numbers_response, AsyncTokenBasedPaginator) - assert page_counter > 1 - - -async def test_list_active_numbers_using_auto_pagination_async(sinch_client_async): - active_numbers_response = await sinch_client_async.numbers.active.list( - region_code="GB", - number_type="MOBILE", - page_size=1 - ) - page_counter = 1 - - async for page in active_numbers_response.auto_paging_iter(): - assert isinstance(page, AsyncTokenBasedPaginator) - page_counter += 1 - - assert page_counter > 1 - - -def test_get_phone_number_configuration(sinch_client_sync): - active_numbers_response = get_active_numbers_for_project(sinch_client_sync) - get_configuration_response = sinch_client_sync.numbers.active.get( - active_numbers_response.result.active_numbers[0].phone_number - ) - assert isinstance(get_configuration_response, GetNumberConfigurationResponse) - - -def test_update_phone_number_configuration(sinch_client_sync): - active_numbers_response = get_active_numbers_for_project(sinch_client_sync) - update_number_response = sinch_client_sync.numbers.active.update( - active_numbers_response.result.active_numbers[0].phone_number, - display_name="test_success!" - ) - assert isinstance(update_number_response, UpdateNumberConfigurationResponse) - - -def test_release_number_from_project(sinch_client_sync): - active_numbers_response = get_active_numbers_for_project(sinch_client_sync) - release_number_response = sinch_client_sync.numbers.active.release( - active_numbers_response.result.active_numbers[0].phone_number, - ) - assert isinstance(release_number_response, ReleaseNumberFromProjectResponse) diff --git a/tests/e2e/numbers/available/test_available_number_api.py b/tests/e2e/numbers/available/test_available_number_api.py deleted file mode 100644 index 5674bca8..00000000 --- a/tests/e2e/numbers/available/test_available_number_api.py +++ /dev/null @@ -1,101 +0,0 @@ -import pytest - -from sinch.domains.numbers.exceptions import NumbersException -from sinch.domains.numbers import Numbers, ListAvailableNumbersResponse, ActivateNumberResponse, \ - CheckNumberAvailabilityResponse - - -def fetch_available_numbers(sinch_client): - return sinch_client.numbers.available.list( - region_code="GB", - number_type="MOBILE" - ) - - -def test_list_available_numbers(sinch_client_sync): - numbers_response = fetch_available_numbers(sinch_client_sync) - assert isinstance(numbers_response, ListAvailableNumbersResponse) - assert len(numbers_response.available_numbers) > 0 - - -def test_list_available_numbers_limit_output_size(sinch_client_sync): - numbers_response = sinch_client_sync.numbers.available.list( - region_code="US", - number_type="LOCAL", - page_size=10 - ) - assert isinstance(numbers_response, ListAvailableNumbersResponse) - assert len(numbers_response.available_numbers) == 10 - - -async def test_list_available_numbers_limit_output_size_async(sinch_client_async): - numbers_response = await sinch_client_async.numbers.available.list( - region_code="US", - number_type="LOCAL", - page_size=10 - ) - assert isinstance(numbers_response, ListAvailableNumbersResponse) - assert len(numbers_response.available_numbers) == 10 - - -def test_list_available_numbers_400_error_code(sinch_client_sync): - with pytest.raises(NumbersException) as err: - sinch_client_sync.numbers.available.list( - region_code="POZNAN", - number_type="POTATO" - ) - assert err - - -async def test_list_available_numbers_with_voice_capabilities_only(sinch_client_async): - numbers_response = await sinch_client_async.numbers.available.list( - region_code="US", - number_type="LOCAL", - capabilities=["VOICE"] - ) - assert isinstance(numbers_response, ListAvailableNumbersResponse) - assert "VOICE" in numbers_response.available_numbers[0].capability - - -def test_list_available_numbers_using_number_pattern(sinch_client_sync): - numbers_response = sinch_client_sync.numbers.available.list( - region_code="US", - number_type="LOCAL", - number_pattern="122", - number_search_pattern="END" - ) - assert isinstance(numbers_response, ListAvailableNumbersResponse) - assert "122" in numbers_response.available_numbers[0].phone_number - - -def test_activate_new_number(sinch_client_sync): - available_numbers = fetch_available_numbers(sinch_client_sync) - numbers_response = sinch_client_sync.numbers.available.activate( - phone_number=available_numbers.available_numbers[0].phone_number - ) - assert isinstance(numbers_response, ActivateNumberResponse) - - -def test_search_for_specific_phone_number(sinch_client_sync): - numbers_response = fetch_available_numbers(sinch_client_sync) - numbers_response = sinch_client_sync.numbers.available.check_availability( - phone_number=numbers_response.available_numbers[0].phone_number - ) - assert isinstance(numbers_response, CheckNumberAvailabilityResponse) - - -async def test_search_for_specific_phone_number_async(sinch_client_async, sinch_client_sync): - available_numbers = fetch_available_numbers(sinch_client_sync) - numbers_response = await sinch_client_async.numbers.available.check_availability( - available_numbers.available_numbers[0].phone_number - ) - assert isinstance(numbers_response, CheckNumberAvailabilityResponse) - - -def test_list_available_numbers_using_domain_object(sinch_client_sync): - numbers_client = Numbers(sinch_client_sync) - numbers_response = numbers_client.available.list( - region_code="US", - number_type="LOCAL" - ) - assert isinstance(numbers_response, ListAvailableNumbersResponse) diff --git a/tests/e2e/numbers/available/test_rent_any_number.py b/tests/e2e/numbers/available/test_rent_any_number.py deleted file mode 100644 index 542327e8..00000000 --- a/tests/e2e/numbers/available/test_rent_any_number.py +++ /dev/null @@ -1,17 +0,0 @@ -from sinch.domains.numbers.models.available.responses import RentAnyNumberResponse - - -def test_rent_any_number_happy_path(sinch_client_sync): - numbers_response = sinch_client_sync.numbers.available.rent_any( - region_code="US", - type_="LOCAL" - ) - assert isinstance(numbers_response, RentAnyNumberResponse) - - -async def test_rent_any_number_happy_path_async(sinch_client_async): - numbers_response = await sinch_client_async.numbers.available.rent_any( - region_code="US", - type_="LOCAL" - ) - assert isinstance(numbers_response, RentAnyNumberResponse) diff --git a/tests/e2e/numbers/callbacks/test_get_callbacks_configuration.py b/tests/e2e/numbers/callbacks/test_get_callbacks_configuration.py deleted file mode 100644 index d0b36d51..00000000 --- a/tests/e2e/numbers/callbacks/test_get_callbacks_configuration.py +++ /dev/null @@ -1,6 +0,0 @@ -from sinch.domains.numbers.models.callbacks.responses import GetNumbersCallbackConfigurationResponse - - -def test_get_callback_configuration_configuration(sinch_client_sync): - get_callback_configuration_response = sinch_client_sync.numbers.callbacks.get_configuration() - assert isinstance(get_callback_configuration_response, GetNumbersCallbackConfigurationResponse) diff --git a/tests/e2e/numbers/callbacks/test_update_callback_configuration.py b/tests/e2e/numbers/callbacks/test_update_callback_configuration.py deleted file mode 100644 index 024d4dce..00000000 --- a/tests/e2e/numbers/callbacks/test_update_callback_configuration.py +++ /dev/null @@ -1,8 +0,0 @@ -from sinch.domains.numbers.models.callbacks.responses import UpdateNumbersCallbackConfigurationResponse - - -def test_update_callback_configuration_configuration(sinch_client_sync): - update_callback_configuration_response = sinch_client_sync.numbers.callbacks.update_configuration( - hmac_secret="Secret" - ) - assert isinstance(update_callback_configuration_response, UpdateNumbersCallbackConfigurationResponse) diff --git a/tests/e2e/numbers/regions/test_available_regions_api.py b/tests/e2e/numbers/regions/test_available_regions_api.py deleted file mode 100644 index 62e28354..00000000 --- a/tests/e2e/numbers/regions/test_available_regions_api.py +++ /dev/null @@ -1,23 +0,0 @@ -from sinch.domains.numbers.enums import NumberType -from sinch.domains.numbers import ListAvailableRegionsResponse - - -def test_list_available_regions(sinch_client_sync): - available_regions_response = sinch_client_sync.numbers.regions.list( - NumberType.LOCAL.value - ) - assert isinstance(available_regions_response, ListAvailableRegionsResponse) - - -def test_list_available_regions_using_types(sinch_client_sync): - available_regions_response = sinch_client_sync.numbers.regions.list( - number_types=[NumberType.LOCAL.value, NumberType.MOBILE.value] - ) - assert isinstance(available_regions_response, ListAvailableRegionsResponse) - - -async def test_list_available_regions_async(sinch_client_async): - available_regions_response = await sinch_client_async.numbers.regions.list( - number_type=NumberType.LOCAL.value - ) - assert isinstance(available_regions_response, ListAvailableRegionsResponse) diff --git a/tests/e2e/sms/batches/test_batch_sms.py b/tests/e2e/sms/batches/test_batch_sms.py deleted file mode 100644 index f28366ff..00000000 --- a/tests/e2e/sms/batches/test_batch_sms.py +++ /dev/null @@ -1,73 +0,0 @@ -import pytest -from sinch.domains.sms.models.batches.responses import SendSMSBatchResponse - - -@pytest.mark.skip() -def test_send_sms_zen_of_python(sinch_client_sync, phone_number, origin_phone_number): - zen = """ - Beautiful is better than ugly. - Explicit is better than implicit. - Simple is better than complex. - Complex is better than complicated. - Flat is better than nested. - Sparse is better than dense. - Readability counts. - Special cases aren't special enough to break the rules. - Although practicality beats purity. - Errors should never pass silently. - Unless explicitly silenced. - In the face of ambiguity, refuse the temptation to guess. - There should be one-- and preferably only one --obvious way to do it. - Although that way may not be obvious at first unless you're Dutch. - Now is better than never. - Although never is often better than *right* now. - If the implementation is hard to explain, it's a bad idea. - If the implementation is easy to explain, it may be a good idea. - Namespaces are one honking great idea -- let's do more of those! - """ - - for line in zen.split("\n"): - send_sms_response = sinch_client_sync.sms.batches.send( - to=[phone_number], - from_=origin_phone_number, - body=line, - feedback_enabled=True - ) - assert isinstance(send_sms_response, SendSMSBatchResponse) - - -async def test_send_sms_async(sinch_client_async, phone_number, origin_phone_number): - send_sms_response = await sinch_client_async.sms.batches.send( - delivery_report="summary", - to=[phone_number], - from_=origin_phone_number, - body="Asynchronous Spanish Inquisition", - feedback_enabled=True - ) - assert isinstance(send_sms_response, SendSMSBatchResponse) - - -def test_send_sms_sync(sinch_client_sync, phone_number, origin_phone_number): - send_sms_response = sinch_client_sync.sms.batches.send( - delivery_report="summary", - to=[phone_number], - from_=origin_phone_number, - body="Synchronous Spanish Inquisition", - feedback_enabled=True - ) - assert isinstance(send_sms_response, SendSMSBatchResponse) - - -def test_send_sms_sync_with_service_plan_id( - sinch_client_sync_with_service_plan_id, - phone_number, - origin_phone_number -): - send_sms_response = sinch_client_sync_with_service_plan_id.sms.batches.send( - delivery_report="none", - to=[phone_number], - from_=origin_phone_number, - body="Synchronous Spanish Inquisition", - feedback_enabled=True - ) - assert isinstance(send_sms_response, SendSMSBatchResponse) diff --git a/tests/e2e/sms/batches/test_cancel_batch.py b/tests/e2e/sms/batches/test_cancel_batch.py deleted file mode 100644 index a4bfad51..00000000 --- a/tests/e2e/sms/batches/test_cancel_batch.py +++ /dev/null @@ -1,50 +0,0 @@ -from sinch.domains.sms.models.batches.responses import CancelSMSBatchResponse - - -def test_cancel_sms_batch(sinch_client_sync, phone_number, origin_phone_number): - send_batch_response = sinch_client_sync.sms.batches.send( - delivery_report="none", - to=[phone_number], - from_=origin_phone_number, - body="Synchronous Batch Cancel", - feedback_enabled=True, - send_at="2023-08-24T21:37:00Z" - ) - cancel_batch_response = sinch_client_sync.sms.batches.cancel( - batch_id=send_batch_response.id - ) - assert isinstance(cancel_batch_response, CancelSMSBatchResponse) - - -def test_cancel_sms_batch_with_service_plan_id( - sinch_client_sync_with_service_plan_id, - phone_number, - origin_phone_number -): - send_batch_response = sinch_client_sync_with_service_plan_id.sms.batches.send( - delivery_report="none", - to=[phone_number], - from_=origin_phone_number, - body="Synchronous Batch Cancel", - feedback_enabled=True, - send_at="2024-08-24T21:37:00Z" - ) - cancel_batch_response = sinch_client_sync_with_service_plan_id.sms.batches.cancel( - batch_id=send_batch_response.id - ) - assert isinstance(cancel_batch_response, CancelSMSBatchResponse) - - -async def test_cancel_sms_batch_async(sinch_client_async, phone_number, origin_phone_number): - send_batch_response = await sinch_client_async.sms.batches.send( - delivery_report="none", - to=[phone_number], - from_=origin_phone_number, - body="Synchronous Batch Cancel", - feedback_enabled=True, - send_at="2023-08-24T21:37:00Z" - ) - cancel_batch_response = await sinch_client_async.sms.batches.cancel( - batch_id=send_batch_response.id - ) - assert isinstance(cancel_batch_response, CancelSMSBatchResponse) diff --git a/tests/e2e/sms/batches/test_dry_run.py b/tests/e2e/sms/batches/test_dry_run.py deleted file mode 100644 index 3070fd4d..00000000 --- a/tests/e2e/sms/batches/test_dry_run.py +++ /dev/null @@ -1,38 +0,0 @@ -from sinch.domains.sms.models.batches.responses import SendSMSBatchDryRunResponse - - -def test_send_sms_dry_run(sinch_client_sync, phone_number, origin_phone_number): - send_dry_run_response = sinch_client_sync.sms.batches.send_dry_run( - number_of_recipients=10, - per_recipient=True, - to=[phone_number], - from_=origin_phone_number, - body="Spanish Inquisition" - ) - assert isinstance(send_dry_run_response, SendSMSBatchDryRunResponse) - - -def test_send_sms_dry_run_with_service_plan_id( - sinch_client_sync_with_service_plan_id, - phone_number, - origin_phone_number -): - send_dry_run_response = sinch_client_sync_with_service_plan_id.sms.batches.send_dry_run( - number_of_recipients=10, - per_recipient=True, - to=[phone_number], - from_=origin_phone_number, - body="Spanish Inquisition" - ) - assert isinstance(send_dry_run_response, SendSMSBatchDryRunResponse) - - -async def test_send_sms_dry_run_async(sinch_client_async, phone_number, origin_phone_number): - send_dry_run_response = await sinch_client_async.sms.batches.send_dry_run( - number_of_recipients=10, - per_recipient=True, - to=[phone_number], - from_=origin_phone_number, - body="Spanish Inquisition" - ) - assert isinstance(send_dry_run_response, SendSMSBatchDryRunResponse) diff --git a/tests/e2e/sms/batches/test_get_batch.py b/tests/e2e/sms/batches/test_get_batch.py deleted file mode 100644 index 9a628538..00000000 --- a/tests/e2e/sms/batches/test_get_batch.py +++ /dev/null @@ -1,25 +0,0 @@ -from sinch.domains.sms.models.batches.responses import GetSMSBatchResponse - - -def test_get_sms_batch(sinch_client_sync): - list_batch_response = sinch_client_sync.sms.batches.list() - get_batch_response = sinch_client_sync.sms.batches.get( - batch_id=list_batch_response.result.batches[0].id - ) - assert isinstance(get_batch_response, GetSMSBatchResponse) - - -def test_get_sms_batch_with_service_plan_id(sinch_client_sync_with_service_plan_id): - list_batch_response = sinch_client_sync_with_service_plan_id.sms.batches.list() - get_batch_response = sinch_client_sync_with_service_plan_id.sms.batches.get( - batch_id=list_batch_response.result.batches[0].id - ) - assert isinstance(get_batch_response, GetSMSBatchResponse) - - -async def test_get_sms_batch_async(sinch_client_async): - list_batch_response = await sinch_client_async.sms.batches.list() - get_batch_response = await sinch_client_async.sms.batches.get( - batch_id=list_batch_response.result.batches[0].id - ) - assert isinstance(get_batch_response, GetSMSBatchResponse) diff --git a/tests/e2e/sms/batches/test_list_batches.py b/tests/e2e/sms/batches/test_list_batches.py deleted file mode 100644 index 42c86bd4..00000000 --- a/tests/e2e/sms/batches/test_list_batches.py +++ /dev/null @@ -1,89 +0,0 @@ -from sinch.domains.sms.models.batches.responses import ListSMSBatchesResponse -from sinch.core.pagination import IntBasedPaginator, AsyncIntBasedPaginator - - -def test_list_sms_batches(sinch_client_sync): - list_batches_response = sinch_client_sync.sms.batches.list() - assert isinstance(list_batches_response, IntBasedPaginator) - - -def test_list_sms_batches_using_service_plan_id(sinch_client_sync_with_service_plan_id): - list_batches_response = sinch_client_sync_with_service_plan_id.sms.batches.list() - assert isinstance(list_batches_response, IntBasedPaginator) - assert len(list_batches_response.result.batches) > 0 - - -def test_list_sms_batches_with_page_size_1(sinch_client_sync): - list_batches_response = sinch_client_sync.sms.batches.list( - page_size=1 - ) - assert isinstance(list_batches_response.result, ListSMSBatchesResponse) - assert len(list_batches_response.result.batches) == 1 - - -def test_list_sms_batches_with_start_date(sinch_client_sync): - list_batches_response = sinch_client_sync.sms.batches.list( - page_size=2, - start_date="2022-05-17T21:37:00.051Z" - ) - assert isinstance(list_batches_response.result, ListSMSBatchesResponse) - - -def test_list_sms_batches_using_manual_pagination(sinch_client_sync): - list_batches_response = sinch_client_sync.sms.batches.list( - start_date="2019-08-24T14:15:22Z", - page_size=1 - ) - - # Page iteration starts from 0... - page_counter = 0 - assert list_batches_response.result.page == page_counter - - while list_batches_response.has_next_page: - list_batches_response = list_batches_response.next_page() - page_counter += 1 - assert list_batches_response.result.page == page_counter - - -def test_list_sms_batches_using_auto_pagination(sinch_client_sync): - list_batches_response = sinch_client_sync.sms.batches.list( - page_size=1, - start_date="2019-08-24T14:15:22Z" - ) - - page_counter = 0 - assert list_batches_response.result.page == page_counter - - for page in list_batches_response.auto_paging_iter(): - page_counter += 1 - assert page.result.page == page_counter - assert isinstance(page, IntBasedPaginator) - - -async def test_list_sms_batches_using_manual_pagination_async(sinch_client_async): - list_batches_response = await sinch_client_async.sms.batches.list( - start_date="2019-08-24T14:15:22Z", - page_size=1 - ) - page_counter = 1 - - while list_batches_response.has_next_page: - list_batches_response = await list_batches_response.next_page() - assert isinstance(list_batches_response, AsyncIntBasedPaginator) - page_counter += 1 - - assert page_counter > 1 - - -async def test_list_sms_batches_using_auto_pagination_async(sinch_client_async): - list_batches_response = await sinch_client_async.sms.batches.list( - start_date="2019-08-24T14:15:22Z", - page_size=1 - ) - page_counter = 1 - - async for page in list_batches_response.auto_paging_iter(): - assert isinstance(page, AsyncIntBasedPaginator) - page_counter += 1 - - assert page_counter > 1 diff --git a/tests/e2e/sms/batches/test_replace_batch.py b/tests/e2e/sms/batches/test_replace_batch.py deleted file mode 100644 index 0e0c56d1..00000000 --- a/tests/e2e/sms/batches/test_replace_batch.py +++ /dev/null @@ -1,40 +0,0 @@ -from sinch.domains.sms.models.batches.responses import ReplaceSMSBatchResponse - - -def test_replace_sms_batch(sinch_client_sync, phone_number): - list_batches_response = sinch_client_sync.sms.batches.list( - start_date="2022-11-24T14:15:22Z" - ) - replace_batch_response = sinch_client_sync.sms.batches.replace( - batch_id=list_batches_response.result.batches[15].id, - to=[phone_number], - body="Replace SMS batch test" - ) - assert isinstance(replace_batch_response, ReplaceSMSBatchResponse) - - -def test_replace_sms_batch_with_service_plan_id( - sinch_client_sync_with_service_plan_id, - phone_number -): - list_batches_response = sinch_client_sync_with_service_plan_id.sms.batches.list( - start_date="2022-11-24T14:15:22Z" - ) - replace_batch_response = sinch_client_sync_with_service_plan_id.sms.batches.replace( - batch_id=list_batches_response.result.batches[0].id, - to=[phone_number], - body="Replace SMS batch test" - ) - assert isinstance(replace_batch_response, ReplaceSMSBatchResponse) - - -async def test_replace_sms_batch_async(sinch_client_async, sinch_client_sync, phone_number): - list_batches_response = sinch_client_sync.sms.batches.list( - start_date="2022-11-24T14:15:22Z" - ) - replace_batch_response = await sinch_client_async.sms.batches.replace( - batch_id=list_batches_response.result.batches[15].id, - to=[phone_number], - body="Replace SMS batch test" - ) - assert isinstance(replace_batch_response, ReplaceSMSBatchResponse) diff --git a/tests/e2e/sms/batches/test_send_delivery_feedback.py b/tests/e2e/sms/batches/test_send_delivery_feedback.py deleted file mode 100644 index a1d096bc..00000000 --- a/tests/e2e/sms/batches/test_send_delivery_feedback.py +++ /dev/null @@ -1,34 +0,0 @@ -from sinch.domains.sms.models.batches.responses import SendSMSDeliveryFeedbackResponse - - -def test_send_delivery_feedback(sinch_client_sync, phone_number): - list_batches_response = sinch_client_sync.sms.batches.list( - start_date="2019-08-24T14:15:22Z", - page_size=1 - ) - delivery_feedback_response = sinch_client_sync.sms.batches.send_delivery_feedback( - batch_id=list_batches_response.result.batches[0].id, - recipients=[phone_number] - ) - assert isinstance(delivery_feedback_response, SendSMSDeliveryFeedbackResponse) - - -def test_send_delivery_feedback_with_service_plan_id(sinch_client_sync_with_service_plan_id, phone_number): - list_batches_response = sinch_client_sync_with_service_plan_id.sms.batches.list() - delivery_feedback_response = sinch_client_sync_with_service_plan_id.sms.batches.send_delivery_feedback( - batch_id=list_batches_response.result.batches[0].id, - recipients=[phone_number] - ) - assert isinstance(delivery_feedback_response, SendSMSDeliveryFeedbackResponse) - - -async def test_send_delivery_feedback_async(sinch_client_async, phone_number): - list_batches_response = await sinch_client_async.sms.batches.list( - start_date="2019-08-24T14:15:22Z", - page_size=1 - ) - delivery_feedback_response = await sinch_client_async.sms.batches.send_delivery_feedback( - batch_id=list_batches_response.result.batches[0].id, - recipients=[phone_number] - ) - assert isinstance(delivery_feedback_response, SendSMSDeliveryFeedbackResponse) diff --git a/tests/e2e/sms/batches/test_update_batch.py b/tests/e2e/sms/batches/test_update_batch.py deleted file mode 100644 index b0b68b36..00000000 --- a/tests/e2e/sms/batches/test_update_batch.py +++ /dev/null @@ -1,56 +0,0 @@ -from sinch.domains.sms.models.batches.responses import UpdateSMSBatchResponse - - -def test_update_sms_batch_with_service_plan_id( - sinch_client_sync_with_service_plan_id, - phone_number, - origin_phone_number -): - send_batch_response = sinch_client_sync_with_service_plan_id.sms.batches.send( - delivery_report="none", - to=[phone_number], - from_=origin_phone_number, - body="Update Batch Test", - feedback_enabled=True, - send_at="2024-12-01T21:37:00Z" - ) - update_batch_response = sinch_client_sync_with_service_plan_id.sms.batches.update( - batch_id=send_batch_response.id, - body="Update Batch Test After Update" - ) - assert isinstance(update_batch_response, UpdateSMSBatchResponse) - assert update_batch_response.body == "Update Batch Test After Update" - - -def test_update_sms_batch(sinch_client_sync, phone_number, origin_phone_number): - send_batch_response = sinch_client_sync.sms.batches.send( - delivery_report="none", - to=[phone_number], - from_=origin_phone_number, - body="Update Batch Test", - feedback_enabled=True, - send_at="2022-12-01T21:37:00Z" - ) - update_batch_response = sinch_client_sync.sms.batches.update( - batch_id=send_batch_response.id, - body="Update Batch Test After Update" - ) - assert isinstance(update_batch_response, UpdateSMSBatchResponse) - assert update_batch_response.body == "Update Batch Test After Update" - - -async def test_update_sms_batch_async(sinch_client_async, phone_number, origin_phone_number): - send_batch_response = await sinch_client_async.sms.batches.send( - delivery_report="none", - to=[phone_number], - from_=origin_phone_number, - body="Update Batch Test", - feedback_enabled=True, - send_at="2022-12-01T21:37:00Z" - ) - update_batch_response = await sinch_client_async.sms.batches.update( - batch_id=send_batch_response.id, - body="Update Batch Test After Update" - ) - assert isinstance(update_batch_response, UpdateSMSBatchResponse) - assert update_batch_response.body == "Update Batch Test After Update" diff --git a/tests/e2e/sms/delivery_reports/test_get_delivery_report_for_batch.py b/tests/e2e/sms/delivery_reports/test_get_delivery_report_for_batch.py deleted file mode 100644 index 711a7107..00000000 --- a/tests/e2e/sms/delivery_reports/test_get_delivery_report_for_batch.py +++ /dev/null @@ -1,59 +0,0 @@ -from sinch.domains.sms.models.delivery_reports.responses import GetSMSDeliveryReportForBatchResponse - - -def test_get_delivery_reports_for_specific_batch(sinch_client_sync, phone_number, origin_phone_number): - send_batch_response = sinch_client_sync.sms.batches.send( - delivery_report="summary", - to=[phone_number], - from_=origin_phone_number, - body="Delivery report test.", - feedback_enabled=True, - callback_url="http://testcallback.pl" - ) - get_delivery_report_response = sinch_client_sync.sms.delivery_reports.get_for_batch( - batch_id=send_batch_response.id, - type_="summary", - status=["Queued", "Dispatched", "Delivered"], - code=[400, 405] - ) - assert isinstance(get_delivery_report_response, GetSMSDeliveryReportForBatchResponse) - - -def test_get_delivery_reports_for_specific_batch_with_service_plan_id( - sinch_client_sync_with_service_plan_id, - phone_number, - origin_phone_number -): - send_batch_response = sinch_client_sync_with_service_plan_id.sms.batches.send( - delivery_report="summary", - to=[phone_number], - from_=origin_phone_number, - body="Delivery report test.", - feedback_enabled=True, - callback_url="http://testcallback.pl" - ) - get_delivery_report_response = sinch_client_sync_with_service_plan_id.sms.delivery_reports.get_for_batch( - batch_id=send_batch_response.id, - type_="summary", - status=["Queued"], - code=[400] - ) - assert isinstance(get_delivery_report_response, GetSMSDeliveryReportForBatchResponse) - - -async def test_get_delivery_reports_for_specific_batch_async(sinch_client_async, phone_number, origin_phone_number): - send_batch_response = await sinch_client_async.sms.batches.send( - delivery_report="summary", - to=[phone_number], - from_=origin_phone_number, - body="Delivery report test.", - feedback_enabled=True, - callback_url="http://testcallback.pl" - ) - get_delivery_report_response = await sinch_client_async.sms.delivery_reports.get_for_batch( - batch_id=send_batch_response.id, - type_="summary", - status=["Queued", "Dispatched", "Delivered"], - code=[400, 405] - ) - assert isinstance(get_delivery_report_response, GetSMSDeliveryReportForBatchResponse) diff --git a/tests/e2e/sms/delivery_reports/test_get_delivery_report_for_number.py b/tests/e2e/sms/delivery_reports/test_get_delivery_report_for_number.py deleted file mode 100644 index 4b2e24b1..00000000 --- a/tests/e2e/sms/delivery_reports/test_get_delivery_report_for_number.py +++ /dev/null @@ -1,43 +0,0 @@ -from sinch.domains.sms.models.delivery_reports.responses import ( - GetSMSDeliveryReportForNumberResponse, - ListSMSDeliveryReportsResponse -) - - -def test_get_delivery_reports_for_specific_number(sinch_client_sync): - list_delivery_reports_response = sinch_client_sync.sms.delivery_reports.list( - start_date="2019-08-24T14:15:22Z" - ) - assert isinstance(list_delivery_reports_response.result, ListSMSDeliveryReportsResponse) - - get_delivery_report_response = sinch_client_sync.sms.delivery_reports.get_for_number( - batch_id=list_delivery_reports_response.result.delivery_reports[0].batch_id, - recipient_number=list_delivery_reports_response.result.delivery_reports[0].recipient - ) - assert isinstance(get_delivery_report_response, GetSMSDeliveryReportForNumberResponse) - - -def test_get_delivery_reports_for_specific_number_with_service_plan_id(sinch_client_sync_with_service_plan_id): - list_delivery_reports_response = sinch_client_sync_with_service_plan_id.sms.delivery_reports.list( - start_date="2019-08-24T14:15:22Z" - ) - assert isinstance(list_delivery_reports_response.result, ListSMSDeliveryReportsResponse) - - get_delivery_report_response = sinch_client_sync_with_service_plan_id.sms.delivery_reports.get_for_number( - batch_id=list_delivery_reports_response.result.delivery_reports[0].batch_id, - recipient_number=list_delivery_reports_response.result.delivery_reports[0].recipient - ) - assert isinstance(get_delivery_report_response, GetSMSDeliveryReportForNumberResponse) - - -async def test_get_delivery_reports_for_specific_number_async(sinch_client_async, sinch_client_sync): - list_delivery_reports_response = sinch_client_sync.sms.delivery_reports.list( - start_date="2019-08-24T14:15:22Z" - ) - assert isinstance(list_delivery_reports_response.result, ListSMSDeliveryReportsResponse) - - get_delivery_report_response = await sinch_client_async.sms.delivery_reports.get_for_number( - batch_id=list_delivery_reports_response.result.delivery_reports[0].batch_id, - recipient_number=list_delivery_reports_response.result.delivery_reports[0].recipient - ) - assert isinstance(get_delivery_report_response, GetSMSDeliveryReportForNumberResponse) diff --git a/tests/e2e/sms/delivery_reports/test_get_delivery_reports_for_project.py b/tests/e2e/sms/delivery_reports/test_get_delivery_reports_for_project.py deleted file mode 100644 index c9bdcc05..00000000 --- a/tests/e2e/sms/delivery_reports/test_get_delivery_reports_for_project.py +++ /dev/null @@ -1,20 +0,0 @@ -from sinch.domains.sms.models.delivery_reports.responses import ListSMSDeliveryReportsResponse - - -def test_get_delivery_reports_for_project(sinch_client_sync): - list_delivery_reports_response = sinch_client_sync.sms.delivery_reports.list( - start_date="2019-08-24T14:15:22Z" - ) - assert isinstance(list_delivery_reports_response.result, ListSMSDeliveryReportsResponse) - - -def test_get_delivery_reports_for_project_with_service_plan_id(sinch_client_sync_with_service_plan_id): - list_delivery_reports_response = sinch_client_sync_with_service_plan_id.sms.delivery_reports.list( - start_date="2019-08-24T14:15:22Z" - ) - assert isinstance(list_delivery_reports_response.result, ListSMSDeliveryReportsResponse) - - -async def test_get_delivery_reports_for_project_async(sinch_client_async): - list_delivery_reports_response = await sinch_client_async.sms.delivery_reports.list() - assert isinstance(list_delivery_reports_response.result, ListSMSDeliveryReportsResponse) diff --git a/tests/e2e/sms/groups/test_create_group.py b/tests/e2e/sms/groups/test_create_group.py deleted file mode 100644 index a2ef1fd3..00000000 --- a/tests/e2e/sms/groups/test_create_group.py +++ /dev/null @@ -1,32 +0,0 @@ -from sinch.domains.sms.models.groups.responses import CreateSMSGroupResponse - - -def test_create_sms_group(sinch_client_sync, phone_number): - create_group_response = sinch_client_sync.sms.groups.create( - name="KillerRabbit", - members=[phone_number] - ) - assert isinstance(create_group_response, CreateSMSGroupResponse) - - -def test_create_sms_group_with_service_plan_id(sinch_client_sync_with_service_plan_id, phone_number): - create_group_response = sinch_client_sync_with_service_plan_id.sms.groups.create( - name="KillerRabbit", - members=[phone_number] - ) - assert isinstance(create_group_response, CreateSMSGroupResponse) - - -async def test_create_sms_group_async_using_child_groups(sinch_client_async, phone_number): - create_group_response = await sinch_client_async.sms.groups.create( - name="KillerRabbit2", - members=[phone_number] - ) - assert isinstance(create_group_response, CreateSMSGroupResponse) - - create_group_response_with_child_groups = await sinch_client_async.sms.groups.create( - name="WithChildGroups", - members=[phone_number], - child_groups=[create_group_response.id] - ) - assert isinstance(create_group_response_with_child_groups, CreateSMSGroupResponse) diff --git a/tests/e2e/sms/groups/test_delete_group.py b/tests/e2e/sms/groups/test_delete_group.py deleted file mode 100644 index ba1a6390..00000000 --- a/tests/e2e/sms/groups/test_delete_group.py +++ /dev/null @@ -1,28 +0,0 @@ -from sinch.domains.sms.models.groups.responses import SinchDeleteSMSGroupResponse - - -def test_delete_sms_group(sinch_client_sync): - list_group_response = sinch_client_sync.sms.groups.list() - - delete_group_response = sinch_client_sync.sms.groups.delete( - group_id=list_group_response.result.groups[0].id - ) - assert isinstance(delete_group_response, SinchDeleteSMSGroupResponse) - - -def test_delete_sms_group_with_service_plan_id(sinch_client_sync_with_service_plan_id): - list_group_response = sinch_client_sync_with_service_plan_id.sms.groups.list() - - delete_group_response = sinch_client_sync_with_service_plan_id.sms.groups.delete( - group_id=list_group_response.result.groups[0].id - ) - assert isinstance(delete_group_response, SinchDeleteSMSGroupResponse) - - -async def test_delete_sms_group_async(sinch_client_async): - list_group_response = await sinch_client_async.sms.groups.list() - - delete_group_response = await sinch_client_async.sms.groups.delete( - group_id=list_group_response.result.groups[0].id - ) - assert isinstance(delete_group_response, SinchDeleteSMSGroupResponse) diff --git a/tests/e2e/sms/groups/test_get_group.py b/tests/e2e/sms/groups/test_get_group.py deleted file mode 100644 index a995201f..00000000 --- a/tests/e2e/sms/groups/test_get_group.py +++ /dev/null @@ -1,28 +0,0 @@ -from sinch.domains.sms.models.groups.responses import GetSMSGroupResponse - - -def test_get_sms_group_with_service_plan_id(sinch_client_sync_with_service_plan_id): - list_group_response = sinch_client_sync_with_service_plan_id.sms.groups.list() - - get_group_response = sinch_client_sync_with_service_plan_id.sms.groups.get( - group_id=list_group_response.result.groups[0].id - ) - assert isinstance(get_group_response, GetSMSGroupResponse) - - -def test_get_sms_group(sinch_client_sync): - list_group_response = sinch_client_sync.sms.groups.list() - - get_group_response = sinch_client_sync.sms.groups.get( - group_id=list_group_response.result.groups[0].id - ) - assert isinstance(get_group_response, GetSMSGroupResponse) - - -async def test_get_sms_group_async(sinch_client_async): - list_group_response = await sinch_client_async.sms.groups.list() - - get_group_response = await sinch_client_async.sms.groups.get( - group_id=list_group_response.result.groups[0].id - ) - assert isinstance(get_group_response, GetSMSGroupResponse) diff --git a/tests/e2e/sms/groups/test_get_phone_numbers_for_group.py b/tests/e2e/sms/groups/test_get_phone_numbers_for_group.py deleted file mode 100644 index 584547f3..00000000 --- a/tests/e2e/sms/groups/test_get_phone_numbers_for_group.py +++ /dev/null @@ -1,34 +0,0 @@ -from sinch.domains.sms.models.groups.responses import SinchGetSMSGroupPhoneNumbersResponse - - -def test_get_group_phone_numbers_sms_with_service_plan_id(sinch_client_sync_with_service_plan_id): - list_group_response = sinch_client_sync_with_service_plan_id.sms.groups.list() - - get_group_response = sinch_client_sync_with_service_plan_id.sms.groups.get_group_phone_numbers( - group_id=list_group_response.result.groups[0].id - ) - - assert isinstance(get_group_response, SinchGetSMSGroupPhoneNumbersResponse) - assert get_group_response.phone_numbers - - -def test_get_group_phone_numbers_sms(sinch_client_sync): - list_group_response = sinch_client_sync.sms.groups.list() - - get_group_response = sinch_client_sync.sms.groups.get_group_phone_numbers( - group_id=list_group_response.result.groups[0].id - ) - - assert isinstance(get_group_response, SinchGetSMSGroupPhoneNumbersResponse) - assert get_group_response.phone_numbers - - -async def test_get_group_phone_numbers_sms_async(sinch_client_async): - list_group_response = await sinch_client_async.sms.groups.list() - - get_group_response = await sinch_client_async.sms.groups.get_group_phone_numbers( - group_id=list_group_response.result.groups[0].id - ) - - assert isinstance(get_group_response, SinchGetSMSGroupPhoneNumbersResponse) - assert get_group_response.phone_numbers diff --git a/tests/e2e/sms/groups/test_list_groups.py b/tests/e2e/sms/groups/test_list_groups.py deleted file mode 100644 index 3190e398..00000000 --- a/tests/e2e/sms/groups/test_list_groups.py +++ /dev/null @@ -1,41 +0,0 @@ -from sinch.core.pagination import IntBasedPaginator, AsyncIntBasedPaginator -from sinch.domains.sms.models.groups.responses import SinchListSMSGroupResponse - - -def test_list_sms_groups(sinch_client_sync): - list_group_response = sinch_client_sync.sms.groups.list() - assert isinstance(list_group_response.result, SinchListSMSGroupResponse) - - -def test_list_sms_groups_with_service_plan_id(sinch_client_sync_with_service_plan_id): - list_group_response = sinch_client_sync_with_service_plan_id.sms.groups.list() - assert isinstance(list_group_response.result, SinchListSMSGroupResponse) - - -async def test_list_sms_groups_async(sinch_client_async): - list_group_response = await sinch_client_async.sms.groups.list() - assert isinstance(list_group_response.result, SinchListSMSGroupResponse) - - -def test_list_sms_groups_using_pagination(sinch_client_sync): - list_group_response = sinch_client_sync.sms.groups.list() - - page_counter = 0 - assert list_group_response.result.page == page_counter - - for page in list_group_response.auto_paging_iter(): - page_counter += 1 - assert page.result.page == page_counter - assert isinstance(page, IntBasedPaginator) - - -async def test_list_sms_groups_using_pagination_async(sinch_client_async): - list_group_response = await sinch_client_async.sms.groups.list() - - page_counter = 0 - assert list_group_response.result.page == page_counter - - async for page in list_group_response.auto_paging_iter(): - page_counter += 1 - assert page.result.page == page_counter - assert isinstance(page, AsyncIntBasedPaginator) diff --git a/tests/e2e/sms/groups/test_replace_group.py b/tests/e2e/sms/groups/test_replace_group.py deleted file mode 100644 index 74e1c2ad..00000000 --- a/tests/e2e/sms/groups/test_replace_group.py +++ /dev/null @@ -1,31 +0,0 @@ -from sinch.domains.sms.models.groups.responses import ReplaceSMSGroupResponse - - -def test_replace_sms_group_with_service_plan_id(sinch_client_sync_with_service_plan_id): - list_group_response = sinch_client_sync_with_service_plan_id.sms.groups.list() - - replace_group_response = sinch_client_sync_with_service_plan_id.sms.groups.replace( - group_id=list_group_response.result.groups[0].id, - members=["48111111111"] - ) - assert isinstance(replace_group_response, ReplaceSMSGroupResponse) - - -def test_replace_sms_group(sinch_client_sync): - list_group_response = sinch_client_sync.sms.groups.list() - - replace_group_response = sinch_client_sync.sms.groups.replace( - group_id=list_group_response.result.groups[0].id, - members=["48111111111"] - ) - assert isinstance(replace_group_response, ReplaceSMSGroupResponse) - - -async def test_replace_sms_group_async(sinch_client_async): - list_group_response = await sinch_client_async.sms.groups.list() - - replace_group_response = await sinch_client_async.sms.groups.replace( - group_id=list_group_response.result.groups[0].id, - members=["48111111111"] - ) - assert isinstance(replace_group_response, ReplaceSMSGroupResponse) diff --git a/tests/e2e/sms/groups/test_update_group.py b/tests/e2e/sms/groups/test_update_group.py deleted file mode 100644 index ffcab07d..00000000 --- a/tests/e2e/sms/groups/test_update_group.py +++ /dev/null @@ -1,45 +0,0 @@ -from sinch.domains.sms.models.groups.responses import UpdateSMSGroupResponse -from sinch.core.enums import HTTPAuthentication - - -def test_update_sms_group(sinch_client_sync, phone_number): - list_group_response = sinch_client_sync.sms.groups.list() - - update_group_response = sinch_client_sync.sms.groups.update( - name="KillerRabbit222", - group_id=list_group_response.result.groups[0].id - ) - assert isinstance(update_group_response, UpdateSMSGroupResponse) - assert update_group_response.name == "KillerRabbit222" - - -def test_update_sms_group_with_service_plan_id(sinch_client_sync_with_service_plan_id, phone_number): - list_group_response = sinch_client_sync_with_service_plan_id.sms.groups.list() - - update_group_response = sinch_client_sync_with_service_plan_id.sms.groups.update( - name="KillerRabbit222", - group_id=list_group_response.result.groups[0].id - ) - assert isinstance(update_group_response, UpdateSMSGroupResponse) - assert update_group_response.name == "KillerRabbit222" - - -def test_add_phone_number_to_sms_group(sinch_client_sync, phone_number): - list_group_response = sinch_client_sync.sms.groups.list() - - update_group_response = sinch_client_sync.sms.groups.update( - group_id=list_group_response.result.groups[20].id, - add=["+48111222333"] - ) - assert isinstance(update_group_response, UpdateSMSGroupResponse) - - -async def test_update_sms_group_async(sinch_client_async): - list_group_response = await sinch_client_async.sms.groups.list() - - update_group_response = await sinch_client_async.sms.groups.update( - name="KillerRabbit333", - group_id=list_group_response.result.groups[0].id - ) - assert isinstance(update_group_response, UpdateSMSGroupResponse) - assert update_group_response.name == "KillerRabbit333" diff --git a/tests/e2e/sms/inbounds/test_get_inbound_message.py b/tests/e2e/sms/inbounds/test_get_inbound_message.py deleted file mode 100644 index 016d62df..00000000 --- a/tests/e2e/sms/inbounds/test_get_inbound_message.py +++ /dev/null @@ -1,20 +0,0 @@ -import pytest -from sinch.domains.sms.models.inbounds.responses import GetInboundMessagesResponse - - -@pytest.mark.skip(reason="More advanced testing setup required.") # TODO: fix that -def test_get_inbound_sms(sinch_client_sync): - list_incoming_message_response = sinch_client_sync.sms.inbounds.list() - get_incoming_message_response = sinch_client_sync.sms.inbounds.get( - inbound_id=list_incoming_message_response.result.inbounds[0].id - ) - assert isinstance(get_incoming_message_response, GetInboundMessagesResponse) - - -@pytest.mark.skip(reason="More advanced testing setup required.") # TODO: fix that -async def test_get_inbound_sms_async(sinch_client_async): - list_incoming_message_response = await sinch_client_async.sms.inbounds.list() - get_incoming_message_response = await sinch_client_async.sms.inbounds.get( - inbound_id=list_incoming_message_response.result.inbounds[0].id - ) - assert isinstance(get_incoming_message_response, GetInboundMessagesResponse) diff --git a/tests/e2e/sms/inbounds/test_list_inbound_messages.py b/tests/e2e/sms/inbounds/test_list_inbound_messages.py deleted file mode 100644 index 85e00405..00000000 --- a/tests/e2e/sms/inbounds/test_list_inbound_messages.py +++ /dev/null @@ -1,16 +0,0 @@ -from sinch.domains.sms.models.inbounds.responses import SinchListInboundMessagesResponse - - -def test_list_inbound_sms(sinch_client_sync): - list_incoming_message_response = sinch_client_sync.sms.inbounds.list() - assert isinstance(list_incoming_message_response.result, SinchListInboundMessagesResponse) - - -def test_list_inbound_sms_with_service_plan_id(sinch_client_sync_with_service_plan_id): - list_incoming_message_response = sinch_client_sync_with_service_plan_id.sms.inbounds.list() - assert isinstance(list_incoming_message_response.result, SinchListInboundMessagesResponse) - - -async def test_list_inbound_sms_async(sinch_client_async): - list_incoming_message_response = await sinch_client_async.sms.inbounds.list() - assert isinstance(list_incoming_message_response.result, SinchListInboundMessagesResponse) diff --git a/tests/e2e/verification/test_get_report_using_id.py b/tests/e2e/verification/test_get_report_using_id.py deleted file mode 100644 index 68962909..00000000 --- a/tests/e2e/verification/test_get_report_using_id.py +++ /dev/null @@ -1,23 +0,0 @@ -from sinch.domains.verification.models.responses import GetVerificationStatusByIdResponse - - -def test_get_report_verification_using_id( - sinch_client_sync, - phone_number, - verification_id -): - verification_response = sinch_client_sync.verification.verification_status.get_by_id( - id=verification_id - ) - assert isinstance(verification_response, GetVerificationStatusByIdResponse) - - -async def test_get_report_verification_using_id_async( - sinch_client_async, - phone_number, - verification_id -): - verification_response = await sinch_client_async.verification.verification_status.get_by_id( - id=verification_id - ) - assert isinstance(verification_response, GetVerificationStatusByIdResponse) diff --git a/tests/e2e/verification/test_get_report_using_identity.py b/tests/e2e/verification/test_get_report_using_identity.py deleted file mode 100644 index 569369f3..00000000 --- a/tests/e2e/verification/test_get_report_using_identity.py +++ /dev/null @@ -1,23 +0,0 @@ -from sinch.domains.verification.models.responses import GetVerificationStatusByIdentityResponse - - -def test_get_report_verification_using_identity( - sinch_client_sync, - phone_number -): - verification_response = sinch_client_sync.verification.verification_status.get_by_identity( - endpoint=phone_number, - method="sms" - ) - assert isinstance(verification_response, GetVerificationStatusByIdentityResponse) - - -async def test_get_report_verification_using_identity_async( - sinch_client_async, - phone_number -): - verification_response = await sinch_client_async.verification.verification_status.get_by_identity( - endpoint=phone_number, - method="sms" - ) - assert isinstance(verification_response, GetVerificationStatusByIdentityResponse) diff --git a/tests/e2e/verification/test_get_report_using_reference.py b/tests/e2e/verification/test_get_report_using_reference.py deleted file mode 100644 index b2443f1f..00000000 --- a/tests/e2e/verification/test_get_report_using_reference.py +++ /dev/null @@ -1,19 +0,0 @@ -from sinch.domains.verification.models.responses import GetVerificationStatusByReferenceResponse - - -def test_get_report_verification_using_reference( - sinch_client_sync -): - verification_response = sinch_client_sync.verification.verification_status.get_by_reference( - reference="random" - ) - assert isinstance(verification_response, GetVerificationStatusByReferenceResponse) - - -async def test_get_report_verification_using_reference_async( - sinch_client_async -): - verification_response = await sinch_client_async.verification.verification_status.get_by_reference( - reference="random" - ) - assert isinstance(verification_response, GetVerificationStatusByReferenceResponse) diff --git a/tests/e2e/verification/test_report_verification_using_id.py b/tests/e2e/verification/test_report_verification_using_id.py deleted file mode 100644 index 61a57ef7..00000000 --- a/tests/e2e/verification/test_report_verification_using_id.py +++ /dev/null @@ -1,84 +0,0 @@ -from sinch.domains.verification.models.responses import ReportVerificationByIdResponse - - -def test_report_verification_using_id_and_sms_legacy_api( - sinch_client_sync, - phone_number, - verification_id -): - verification_response = sinch_client_sync.verification.verifications.report_by_id( - id=verification_id, - verification_report_request={ - "method": "sms", - "sms": { - "code": "2302" - } - } - ) - assert isinstance(verification_response, ReportVerificationByIdResponse) - - -def test_report_verification_using_id_and_sms( - sinch_client_sync, - verification_id -): - verification_response = sinch_client_sync.verification.verifications.report_sms_by_id( - id=verification_id, - code="2302" - ) - assert isinstance(verification_response, ReportVerificationByIdResponse) - - -def test_report_verification_using_id_and_flash_call( - sinch_client_sync, - verification_id -): - verification_response = sinch_client_sync.verification.verifications.report_flash_call_by_id( - id=verification_id, - cli="+19473452226" - ) - assert isinstance(verification_response, ReportVerificationByIdResponse) - - -def test_report_verification_using_id_and_and_phone_call( - sinch_client_sync, - verification_id -): - verification_response = sinch_client_sync.verification.verifications.report_phone_call_by_id( - id=verification_id, - code="8943" - ) - assert isinstance(verification_response, ReportVerificationByIdResponse) - - -async def test_report_verification_using_id_and_sms_async( - sinch_client_async, - verification_id -): - verification_response = await sinch_client_async.verification.verifications.report_sms_by_id( - id=verification_id, - code="2302" - ) - assert isinstance(verification_response, ReportVerificationByIdResponse) - - -async def test_report_verification_using_id_and_flash_call_async( - sinch_client_async, - verification_id -): - verification_response = await sinch_client_async.verification.verifications.report_flash_call_by_id( - id=verification_id, - cli="+19473452226" - ) - assert isinstance(verification_response, ReportVerificationByIdResponse) - - -async def test_report_verification_using_id_and_and_phone_call_async( - sinch_client_async, - verification_id -): - verification_response = await sinch_client_async.verification.verifications.report_phone_call_by_id( - id=verification_id, - code="8943" - ) - assert isinstance(verification_response, ReportVerificationByIdResponse) diff --git a/tests/e2e/verification/test_report_verification_using_identity.py b/tests/e2e/verification/test_report_verification_using_identity.py deleted file mode 100644 index eea1d6c0..00000000 --- a/tests/e2e/verification/test_report_verification_using_identity.py +++ /dev/null @@ -1,85 +0,0 @@ -from sinch.domains.verification.models.responses import ReportVerificationByIdentityResponse - - -def test_report_verification_using_identity_and_sms_legacy_api( - sinch_client_sync, - phone_number -): - verification_response = sinch_client_sync.verification.verifications.report_by_identity( - endpoint=phone_number, - verification_report_request={ - "method": "sms", - "sms": { - "code": "2302" - } - } - ) - assert isinstance(verification_response, ReportVerificationByIdentityResponse) - - -def test_report_verification_using_identity_and_sms( - sinch_client_sync, - phone_number -): - verification_response = sinch_client_sync.verification.verifications.report_sms_by_identity( - endpoint=phone_number, - code="2302" - ) - assert isinstance(verification_response, ReportVerificationByIdentityResponse) - - -def test_report_verification_using_identity_and_flash_call( - sinch_client_sync, - phone_number -): - verification_response = sinch_client_sync.verification.verifications.report_flash_call_by_identity( - endpoint=phone_number, - cli="+18488471074" - ) - assert isinstance(verification_response, ReportVerificationByIdentityResponse) - - -def test_report_verification_using_identity_and_phone_call( - sinch_client_sync, - phone_number -): - verification_response = sinch_client_sync.verification.verifications.report_phone_call_by_identity( - endpoint=phone_number, - code="4563" - ) - assert isinstance(verification_response, ReportVerificationByIdentityResponse) - - -async def test_report_verification_using_identity_and_sms_async( - sinch_client_async, - verification_id, - phone_number -): - verification_response = await sinch_client_async.verification.verifications.report_sms_by_identity( - endpoint=phone_number, - code="2302" - ) - assert isinstance(verification_response, ReportVerificationByIdentityResponse) - - -async def test_report_verification_using_identity_and_flash_call_async( - sinch_client_async, - phone_number -): - verification_response = await sinch_client_async.verification.verifications.report_flash_call_by_identity( - endpoint=phone_number, - cli="+18488471074" - ) - assert isinstance(verification_response, ReportVerificationByIdentityResponse) - - -async def test_report_verification_using_identity_and_phone_call_async( - sinch_client_async, - verification_id, - phone_number -): - verification_response = await sinch_client_async.verification.verifications.report_phone_call_by_identity( - endpoint=phone_number, - code="4563" - ) - assert isinstance(verification_response, ReportVerificationByIdentityResponse) diff --git a/tests/e2e/verification/test_start_verification.py b/tests/e2e/verification/test_start_verification.py deleted file mode 100644 index e79bed15..00000000 --- a/tests/e2e/verification/test_start_verification.py +++ /dev/null @@ -1,115 +0,0 @@ -import pytest -from sinch.domains.verification.exceptions import VerificationException -from sinch.domains.verification.models.responses import ( - StartSMSVerificationResponse, - StartFlashCallVerificationResponse, - StartPhoneCallVerificationResponse, - StartDataVerificationResponse, - StartFlashCallInitiateVerificationResponse, - StartCalloutInitiateVerificationResponse, - StartDataInitiateVerificationResponse -) - - -def test_start_verification_sms( - sinch_client_sync, - phone_number -): - verification_response = sinch_client_sync.verification.verifications.start_sms( - identity={ - "type": "number", - "endpoint": phone_number - }, - reference="random", - expiry="23:21:21" - ) - assert isinstance(verification_response, StartSMSVerificationResponse) - - -def test_start_verification_sms_malformed_phone_number( - sinch_client_sync, - phone_number -): - with pytest.raises(VerificationException) as err: - sinch_client_sync.verification.verifications.start_sms( - identity={ - "type": "number", - "endpoint": "abcd" + phone_number + "abcd" - }, - reference="random" - ) - assert "invalid" in err.value.http_response.body["message"] - - -def test_start_verification_flash_call( - sinch_client_sync, - phone_number -): - verification_response = sinch_client_sync.verification.verifications.start_flash_call( - identity={ - "type": "number", - "endpoint": phone_number - }, - reference="random7" - ) - assert isinstance(verification_response, StartFlashCallVerificationResponse) - - -def test_start_verification_phone_call( - sinch_client_sync, - phone_number -): - verification_response = sinch_client_sync.verification.verifications.start_phone_call( - identity={ - "type": "number", - "endpoint": phone_number - }, - reference="random32" - ) - assert isinstance(verification_response, StartPhoneCallVerificationResponse) - - -def test_start_verification_callout( - sinch_client_sync, - phone_number -): - verification_response = sinch_client_sync.verification.verifications.start_callout( - identity={ - "type": "number", - "endpoint": phone_number - }, - reference="random32", - speech_locale="en-US" - ) - - assert isinstance(verification_response, StartPhoneCallVerificationResponse) - - -@pytest.mark.skip(reason="Data verification. Mobile carrier support required.") -def test_start_verification_seamless( - sinch_client_sync, - phone_number -): - verification_response = sinch_client_sync.verification.verifications.start_data( - identity={ - "type": "number", - "endpoint": phone_number - }, - reference="random99" - ) - assert isinstance(verification_response, StartDataVerificationResponse) - - -async def test_start_verification_sms_async( - sinch_client_async, - phone_number -): - verification_response = await sinch_client_async.verification.verifications.start_sms( - identity={ - "type": "number", - "endpoint": phone_number - }, - reference="random", - expiry="23:21:21" - ) - assert isinstance(verification_response, StartSMSVerificationResponse) diff --git a/tests/e2e/voice/applications/test_assign_numbers.py b/tests/e2e/voice/applications/test_assign_numbers.py deleted file mode 100644 index 4ce0c6ea..00000000 --- a/tests/e2e/voice/applications/test_assign_numbers.py +++ /dev/null @@ -1,21 +0,0 @@ -from sinch.domains.voice.models.applications.responses import AssignNumbersVoiceApplicationResponse - - -def test_assign_application_numbers( - sinch_client_sync -): - get_voice_numbers_response = sinch_client_sync.voice.applications.get_numbers() - assign_voice_numbers_response = sinch_client_sync.voice.applications.assign_numbers( - numbers=[get_voice_numbers_response.numbers[0].number] - ) - assert isinstance(assign_voice_numbers_response, AssignNumbersVoiceApplicationResponse) - - -async def test_assign_application_numbers_async( - sinch_client_async -): - get_voice_numbers_response = await sinch_client_async.voice.applications.get_numbers() - assign_voice_numbers_response = await sinch_client_async.voice.applications.assign_numbers( - numbers=[get_voice_numbers_response.numbers[0].number] - ) - assert isinstance(assign_voice_numbers_response, AssignNumbersVoiceApplicationResponse) diff --git a/tests/e2e/voice/applications/test_get_callback_urls.py b/tests/e2e/voice/applications/test_get_callback_urls.py deleted file mode 100644 index 0f649668..00000000 --- a/tests/e2e/voice/applications/test_get_callback_urls.py +++ /dev/null @@ -1,21 +0,0 @@ -from sinch.domains.voice.models.applications.responses import GetCallbackUrlsVoiceApplicationResponse - - -def test_get_application_callback_urls( - sinch_client_sync, - application_key -): - callback_urls_response = sinch_client_sync.voice.applications.get_callback_urls( - application_key=application_key - ) - assert isinstance(callback_urls_response, GetCallbackUrlsVoiceApplicationResponse) - - -async def test_get_application_callback_async( - sinch_client_sync, - application_key -): - callback_urls_response = sinch_client_sync.voice.applications.get_callback_urls( - application_key=application_key - ) - assert isinstance(callback_urls_response, GetCallbackUrlsVoiceApplicationResponse) diff --git a/tests/e2e/voice/applications/test_get_numbers.py b/tests/e2e/voice/applications/test_get_numbers.py deleted file mode 100644 index b9c1fade..00000000 --- a/tests/e2e/voice/applications/test_get_numbers.py +++ /dev/null @@ -1,15 +0,0 @@ -from sinch.domains.voice.models.applications.responses import GetNumbersVoiceApplicationResponse - - -def test_get_application_numbers( - sinch_client_sync -): - get_voice_numbers_response = sinch_client_sync.voice.applications.get_numbers() - assert isinstance(get_voice_numbers_response, GetNumbersVoiceApplicationResponse) - - -async def test_get_application_numbers_async( - sinch_client_async -): - get_voice_numbers_response = await sinch_client_async.voice.applications.get_numbers() - assert isinstance(get_voice_numbers_response, GetNumbersVoiceApplicationResponse) diff --git a/tests/e2e/voice/applications/test_query_number.py b/tests/e2e/voice/applications/test_query_number.py deleted file mode 100644 index 0260c60e..00000000 --- a/tests/e2e/voice/applications/test_query_number.py +++ /dev/null @@ -1,21 +0,0 @@ -from sinch.domains.voice.models.applications.responses import QueryNumberVoiceApplicationResponse - - -def test_query_application_numbers( - sinch_client_sync -): - get_voice_numbers_response = sinch_client_sync.voice.applications.get_numbers() - query_voice_numbers_response = sinch_client_sync.voice.applications.query_number( - get_voice_numbers_response.numbers[0].number - ) - assert isinstance(query_voice_numbers_response, QueryNumberVoiceApplicationResponse) - - -async def test_query_application_numbers_async( - sinch_client_async -): - get_voice_numbers_response = await sinch_client_async.voice.applications.get_numbers() - query_voice_numbers_response = await sinch_client_async.voice.applications.query_number( - get_voice_numbers_response.numbers[0].number - ) - assert isinstance(query_voice_numbers_response, QueryNumberVoiceApplicationResponse) diff --git a/tests/e2e/voice/applications/test_unassign_number.py b/tests/e2e/voice/applications/test_unassign_number.py deleted file mode 100644 index 7672cbe1..00000000 --- a/tests/e2e/voice/applications/test_unassign_number.py +++ /dev/null @@ -1,21 +0,0 @@ -from sinch.domains.voice.models.applications.responses import UnassignNumbersVoiceApplicationResponse - - -def test_unassign_application_number( - sinch_client_sync -): - get_voice_numbers_response = sinch_client_sync.voice.applications.get_numbers() - unassign_number_response = sinch_client_sync.voice.applications.unassign_number( - number=get_voice_numbers_response.numbers[4].number - ) - assert isinstance(unassign_number_response, UnassignNumbersVoiceApplicationResponse) - - -async def test_unassign_application_number_async( - sinch_client_async -): - get_voice_numbers_response = await sinch_client_async.voice.applications.get_numbers() - unassign_number_response = await sinch_client_async.voice.applications.unassign_number( - number=get_voice_numbers_response.numbers[0].number - ) - assert isinstance(unassign_number_response, UnassignNumbersVoiceApplicationResponse) diff --git a/tests/e2e/voice/applications/test_update_callback_urls.py b/tests/e2e/voice/applications/test_update_callback_urls.py deleted file mode 100644 index 259c5de7..00000000 --- a/tests/e2e/voice/applications/test_update_callback_urls.py +++ /dev/null @@ -1,25 +0,0 @@ -from sinch.domains.voice.models.applications.responses import UpdateCallbackUrlsVoiceApplicationResponse - - -def test_update_application_callback_urls( - sinch_client_sync, - application_key -): - callback_urls_response = sinch_client_sync.voice.applications.update_callback_urls( - application_key=application_key, - primary="testprimary.com/123", - fallback="testfallback.com/123" - ) - assert isinstance(callback_urls_response, UpdateCallbackUrlsVoiceApplicationResponse) - - -async def test_update_application_callback_urls_async( - sinch_client_async, - application_key -): - callback_urls_response = await sinch_client_async.voice.applications.update_callback_urls( - application_key=application_key, - primary="testprimary.com/123", - fallback="testfallback.com/123" - ) - assert isinstance(callback_urls_response, UpdateCallbackUrlsVoiceApplicationResponse) diff --git a/tests/e2e/voice/callouts/test_callout.py b/tests/e2e/voice/callouts/test_callout.py deleted file mode 100644 index aaa0b6da..00000000 --- a/tests/e2e/voice/callouts/test_callout.py +++ /dev/null @@ -1,101 +0,0 @@ -from sinch.domains.voice.models.callouts.responses import VoiceCalloutResponse - - -def test_tts_callout( - sinch_client_sync, - phone_number, - voice_origin_phone_number -): - tts_callout_response = sinch_client_sync.voice.callouts.text_to_speech( - destination={ - "type": "number", - "endpoint": phone_number - }, - text="test message", - locale="en-US", - cli=voice_origin_phone_number - ) - assert isinstance(tts_callout_response, VoiceCalloutResponse) - - -async def test_tts_callout_async( - sinch_client_async, - phone_number, - voice_origin_phone_number -): - tts_callout_response = await sinch_client_async.voice.callouts.text_to_speech( - destination={ - "type": "number", - "endpoint": phone_number - }, - text="test message", - locale="en-US", - cli=voice_origin_phone_number - ) - assert isinstance(tts_callout_response, VoiceCalloutResponse) - - -def test_conference_callout( - sinch_client_sync, - phone_number, - voice_origin_phone_number, - conference_id -): - conference_callout_response = sinch_client_sync.voice.callouts.conference( - conference_id=conference_id, - destination={ - "type": "number", - "endpoint": phone_number - }, - locale="en-US", - cli=voice_origin_phone_number - ) - assert isinstance(conference_callout_response, VoiceCalloutResponse) - - -async def test_conference_callout_async( - sinch_client_async, - phone_number, - voice_origin_phone_number, - conference_id -): - conference_callout_response = await sinch_client_async.voice.callouts.conference( - conference_id=conference_id, - destination={ - "type": "number", - "endpoint": phone_number - }, - locale="en-US", - cli=voice_origin_phone_number - ) - assert isinstance(conference_callout_response, VoiceCalloutResponse) - - -def test_custom_callout( - sinch_client_sync, - phone_number, - voice_origin_phone_number -): - custom_callout_response = sinch_client_sync.voice.callouts.custom( - destination={ - "type": "number", - "endpoint": phone_number - }, - cli=voice_origin_phone_number - ) - assert isinstance(custom_callout_response, VoiceCalloutResponse) - - -async def test_custom_callout_async( - sinch_client_async, - phone_number, - voice_origin_phone_number -): - custom_callout_response = await sinch_client_async.voice.callouts.custom( - destination={ - "type": "number", - "endpoint": phone_number - }, - cli=voice_origin_phone_number - ) - assert isinstance(custom_callout_response, VoiceCalloutResponse) diff --git a/tests/e2e/voice/calls/test_get_call.py b/tests/e2e/voice/calls/test_get_call.py deleted file mode 100644 index 01a7a6fe..00000000 --- a/tests/e2e/voice/calls/test_get_call.py +++ /dev/null @@ -1,21 +0,0 @@ -from sinch.domains.voice.models.calls.responses import GetVoiceCallResponse - - -def test_get_call( - sinch_client_sync, - call_id -): - get_call_response = sinch_client_sync.voice.calls.get( - call_id=call_id - ) - assert isinstance(get_call_response, GetVoiceCallResponse) - - -async def test_get_call_async( - sinch_client_async, - call_id -): - get_call_response = await sinch_client_async.voice.calls.get( - call_id=call_id - ) - assert isinstance(get_call_response, GetVoiceCallResponse) diff --git a/tests/e2e/voice/calls/test_magage_call.py b/tests/e2e/voice/calls/test_magage_call.py deleted file mode 100644 index f4ac0857..00000000 --- a/tests/e2e/voice/calls/test_magage_call.py +++ /dev/null @@ -1,37 +0,0 @@ -from sinch.domains.voice.models.calls.responses import ManageVoiceCallResponse -from sinch.domains.voice.models.svaml.actions import HangupAction -from sinch.domains.voice.models.svaml.instructions import SendDtmfInstruction - - -def test_manage_call( - sinch_client_sync, - conference_call_id -): - update_call_response = sinch_client_sync.voice.calls.manage_with_call_leg( - call_id=conference_call_id, - call_leg="caller", - instructions=[ - SendDtmfInstruction( - value="1234#" - ).as_dict() - ], - action=HangupAction().as_dict() - ) - assert isinstance(update_call_response, ManageVoiceCallResponse) - - -async def test_manage_call_async( - sinch_client_async, - conference_call_id -): - update_call_response = await sinch_client_async.voice.calls.manage_with_call_leg( - call_id=conference_call_id, - call_leg="caller", - instructions=[ - SendDtmfInstruction( - value="1234#" - ).as_dict() - ], - action=HangupAction().as_dict() - ) - assert isinstance(update_call_response, ManageVoiceCallResponse) diff --git a/tests/e2e/voice/calls/test_update_call.py b/tests/e2e/voice/calls/test_update_call.py deleted file mode 100644 index 90309174..00000000 --- a/tests/e2e/voice/calls/test_update_call.py +++ /dev/null @@ -1,35 +0,0 @@ -from sinch.domains.voice.models.calls.responses import UpdateVoiceCallResponse -from sinch.domains.voice.models.svaml.actions import HangupAction -from sinch.domains.voice.models.svaml.instructions import SendDtmfInstruction - - -def test_update_voice_call( - sinch_client_sync, - call_id -): - update_call_response = sinch_client_sync.voice.calls.update( - call_id=call_id, - instructions=[ - SendDtmfInstruction( - value="1234#" - ).as_dict() - ], - action=HangupAction().as_dict() - ) - assert isinstance(update_call_response, UpdateVoiceCallResponse) - - -async def test_update_voice_call_async( - sinch_client_async, - call_id -): - update_call_response = await sinch_client_async.voice.calls.update( - call_id=call_id, - instructions=[ - SendDtmfInstruction( - value="1234#" - ).as_dict() - ], - action=HangupAction().as_dict() - ) - assert isinstance(update_call_response, UpdateVoiceCallResponse) diff --git a/tests/e2e/voice/conferences/test_call_conference.py b/tests/e2e/voice/conferences/test_call_conference.py deleted file mode 100644 index 3be04f13..00000000 --- a/tests/e2e/voice/conferences/test_call_conference.py +++ /dev/null @@ -1,37 +0,0 @@ -from sinch.domains.voice.models.callouts.responses import VoiceCalloutResponse - - -def test_conference_call( - sinch_client_sync, - phone_number, - voice_origin_phone_number, - conference_id -): - conference_callout_response = sinch_client_sync.voice.conferences.call( - conference_id=conference_id, - destination={ - "type": "number", - "endpoint": phone_number - }, - locale="en-US", - cli=voice_origin_phone_number - ) - assert isinstance(conference_callout_response, VoiceCalloutResponse) - - -async def test_conference_call_async( - sinch_client_async, - phone_number, - voice_origin_phone_number, - conference_id -): - conference_callout_response = await sinch_client_async.voice.conferences.call( - conference_id=conference_id, - destination={ - "type": "number", - "endpoint": phone_number - }, - locale="en-US", - cli=voice_origin_phone_number - ) - assert isinstance(conference_callout_response, VoiceCalloutResponse) \ No newline at end of file diff --git a/tests/e2e/voice/conferences/test_get_conference.py b/tests/e2e/voice/conferences/test_get_conference.py deleted file mode 100644 index 95df5157..00000000 --- a/tests/e2e/voice/conferences/test_get_conference.py +++ /dev/null @@ -1,17 +0,0 @@ -from sinch.domains.voice.models.conferences.responses import GetVoiceConferenceResponse - - -def test_get_conference( - sinch_client_sync, - conference_id -): - get_conference_response = sinch_client_sync.voice.conferences.get(conference_id) - assert isinstance(get_conference_response, GetVoiceConferenceResponse) - - -async def test_get_conference_async( - sinch_client_async, - conference_id -): - get_conference_response = await sinch_client_async.voice.conferences.get(conference_id) - assert isinstance(get_conference_response, GetVoiceConferenceResponse) diff --git a/tests/e2e/voice/conferences/test_kick_all.py b/tests/e2e/voice/conferences/test_kick_all.py deleted file mode 100644 index b063a043..00000000 --- a/tests/e2e/voice/conferences/test_kick_all.py +++ /dev/null @@ -1,17 +0,0 @@ -from sinch.domains.voice.models.conferences.responses import KickAllVoiceConferenceResponse - - -def test_kick_all_conference_participants( - sinch_client_sync, - conference_id -): - kick_all_participants_response = sinch_client_sync.voice.conferences.kick_all(conference_id) - assert isinstance(kick_all_participants_response, KickAllVoiceConferenceResponse) - - -async def test_kick_all_conference_participants_async( - sinch_client_async, - conference_id -): - kick_all_participants_response = await sinch_client_async.voice.conferences.kick_all(conference_id) - assert isinstance(kick_all_participants_response, KickAllVoiceConferenceResponse) diff --git a/tests/e2e/voice/conferences/test_kick_participant.py b/tests/e2e/voice/conferences/test_kick_participant.py deleted file mode 100644 index 076e3642..00000000 --- a/tests/e2e/voice/conferences/test_kick_participant.py +++ /dev/null @@ -1,25 +0,0 @@ -from sinch.domains.voice.models.conferences.responses import KickParticipantVoiceConferenceResponse - - -def test_kick_conference_participant( - sinch_client_sync, - conference_id, - conference_call_id -): - kick_participant_response = sinch_client_sync.voice.conferences.kick_participant( - conference_id=conference_id, - call_id=conference_call_id - ) - assert isinstance(kick_participant_response, KickParticipantVoiceConferenceResponse) - - -async def test_kick_conference_participant_async( - sinch_client_async, - conference_id, - conference_call_id -): - kick_participant_response = await sinch_client_async.voice.conferences.kick_participant( - conference_id=conference_id, - call_id=conference_call_id - ) - assert isinstance(kick_participant_response, KickParticipantVoiceConferenceResponse) diff --git a/tests/e2e/voice/conferences/test_manage_participant.py b/tests/e2e/voice/conferences/test_manage_participant.py deleted file mode 100644 index 7cbcdf04..00000000 --- a/tests/e2e/voice/conferences/test_manage_participant.py +++ /dev/null @@ -1,29 +0,0 @@ -from sinch.domains.voice.models.conferences.responses import ManageParticipantVoiceConferenceResponse -from sinch.domains.voice.enums import ConferenceCommand - - -def test_manage_conference_conference( - sinch_client_sync, - conference_id, - conference_call_id -): - manage_participant_response = sinch_client_sync.voice.conferences.manage_participant( - conference_id=conference_id, - call_id=conference_call_id, - command=ConferenceCommand.MUTE.value - ) - assert isinstance(manage_participant_response, ManageParticipantVoiceConferenceResponse) - - -async def test_manage_conference_conference_async( - sinch_client_async, - conference_id, - conference_call_id -): - manage_participant_response = await sinch_client_async.voice.conferences.manage_participant( - conference_id=conference_id, - call_id=conference_call_id, - command=ConferenceCommand.MUTE.value - ) - assert isinstance(manage_participant_response, ManageParticipantVoiceConferenceResponse) - diff --git a/tests/examples/test_fast_api_example.py b/tests/examples/test_fast_api_example.py deleted file mode 100644 index 71983627..00000000 --- a/tests/examples/test_fast_api_example.py +++ /dev/null @@ -1,16 +0,0 @@ -from fastapi.testclient import TestClient -from examples.fast_api_example import app, sinch_client - - -def test_get_available_numbers_get_endpoint( - auth_origin, - numbers_origin -): - sinch_client.configuration.auth_origin = auth_origin - sinch_client.configuration.numbers_origin = numbers_origin - sinch_client.configuration.disable_https = True - - client = TestClient(app) - response = client.get("/available_numbers") - assert response.status_code == 200 - assert "available_numbers" in response.json() diff --git a/tests/examples/test_flask_example.py b/tests/examples/test_flask_example.py deleted file mode 100644 index a317b60d..00000000 --- a/tests/examples/test_flask_example.py +++ /dev/null @@ -1,16 +0,0 @@ -from examples.flask_example import app, sinch_client - - -def test_flask_create_app_get_endpoint( - auth_origin, - conversation_origin -): - sinch_client.configuration.auth_origin = auth_origin - sinch_client.configuration.conversation_origin = conversation_origin - sinch_client.configuration.disable_https = True - app.testing = True - flask_client = app.test_client() - - response = flask_client.post("/create_app") - assert response.status_code == 200 - assert "sinch_app_id" in response.json diff --git a/tests/examples/test_logging_example.py b/tests/examples/test_logging_example.py deleted file mode 100644 index 3b05df8b..00000000 --- a/tests/examples/test_logging_example.py +++ /dev/null @@ -1,19 +0,0 @@ -from examples.logging_example import main, sinch_client - - -def test_sinch_client_logging_with_e2e_test( - caplog, - auth_origin, - numbers_origin -): - sinch_client.configuration.auth_origin = auth_origin - sinch_client.configuration.numbers_origin = numbers_origin - sinch_client.configuration.disable_https = True - main() - - assert len(caplog.records) - - with open("/tmp/test_python_logging.log") as fd: - log_messages = fd.read() - assert "DEBUG" in log_messages - assert "myapp.sinch" in log_messages diff --git a/tests/integration/test_domain_endpoint_error_handling.py b/tests/integration/test_domain_endpoint_error_handling.py deleted file mode 100644 index 59cb6f3d..00000000 --- a/tests/integration/test_domain_endpoint_error_handling.py +++ /dev/null @@ -1,55 +0,0 @@ -import pytest -from sinch.domains.numbers.endpoints.numbers_endpoint import NumbersEndpoint -from sinch.domains.conversation.endpoints.conversation_endpoint import ConversationEndpoint -from sinch.domains.sms.endpoints.sms_endpoint import SMSEndpoint -from sinch.domains.authentication.endpoints.oauth import OAuthEndpoint - -from sinch.domains.numbers.exceptions import NumbersException -from sinch.domains.conversation.exceptions import ConversationException -from sinch.domains.sms.exceptions import SMSException -from sinch.domains.authentication.exceptions import AuthenticationException - - -def test_numbers_endpoint_error_handling(project_id, http_response): - numbers_endpoint = NumbersEndpoint( - project_id=project_id, - request_data={} - ) - with pytest.raises(NumbersException) as error: - numbers_endpoint.handle_response(http_response) - assert str(error) == http_response.body["error"]["message"] - assert error.is_from_server is True - assert error.response_status_code == http_response.status_code - - -def test_conversation_endpoint_error_handling(project_id, http_response): - numbers_endpoint = ConversationEndpoint( - project_id=project_id, - request_data={} - ) - with pytest.raises(ConversationException) as error: - numbers_endpoint.handle_response(http_response) - assert str(error) == http_response.body["error"]["message"] - assert error.is_from_server is True - assert error.response_status_code == http_response.status_code - - -def test_sms_endpoint_error_handling(sinch_client_sync, sms_http_response): - numbers_endpoint = SMSEndpoint( - request_data={}, - sinch=sinch_client_sync - ) - with pytest.raises(SMSException) as error: - numbers_endpoint.handle_response(sms_http_response) - assert str(error) == sms_http_response.body["error"]["message"] - assert error.is_from_server is True - assert error.response_status_code == sms_http_response.status_code - - -def test_authentication_endpoint_error_handling(http_response): - numbers_endpoint = OAuthEndpoint() - with pytest.raises(AuthenticationException) as error: - numbers_endpoint.handle_response(http_response) - assert str(error) == http_response.body["error"]["message"] - assert error.is_from_server is True - assert error.response_status_code == http_response.status_code diff --git a/tests/integration/test_http_transport.py b/tests/integration/test_http_transport.py deleted file mode 100644 index af4e44a8..00000000 --- a/tests/integration/test_http_transport.py +++ /dev/null @@ -1,41 +0,0 @@ -from sinch.core.adapters.requests_http_transport import HTTPTransportRequests -from sinch.domains.sms.endpoints.batches.send_batch import SendBatchSMSEndpoint - - -def test_authenticate_method_with_service_plan_id_version_of_sms_api( - sinch_client_sync_with_service_plan_id, - empty_http_request -): - sms_endpoint = SendBatchSMSEndpoint( - sinch=sinch_client_sync_with_service_plan_id, - request_data=empty_http_request - ) - http_transport = HTTPTransportRequests(sinch=sinch_client_sync_with_service_plan_id) - http_transport.authenticate(endpoint=sms_endpoint, request_data=empty_http_request) - - assert empty_http_request.headers - assert "Bearer" in empty_http_request.headers["Authorization"] - assert ( - empty_http_request.headers["Authorization"] == - f"Bearer {sinch_client_sync_with_service_plan_id.configuration.sms_api_token}" - ) - assert empty_http_request.headers["Content-Type"] == "application/json" - - -def test_authenticate_method_with_project_id_version_of_sms_api( - sinch_client_sync, - empty_http_request -): - sms_endpoint = SendBatchSMSEndpoint( - sinch=sinch_client_sync, - request_data=empty_http_request, - ) - http_transport = HTTPTransportRequests(sinch=sinch_client_sync) - http_transport.authenticate(endpoint=sms_endpoint, request_data=empty_http_request) - - assert empty_http_request.headers - assert ( - empty_http_request.headers["Authorization"] == - f"Bearer {sinch_client_sync.configuration.token_manager.token.access_token}" - ) - assert empty_http_request.headers["Content-Type"] == "application/json" diff --git a/tests/integration/test_logging.py b/tests/integration/test_logging.py deleted file mode 100644 index 0e62482f..00000000 --- a/tests/integration/test_logging.py +++ /dev/null @@ -1,47 +0,0 @@ -import logging -import tempfile -from unittest.mock import Mock - - -def mock_http_transport(client): - client.configuration.transport.http_session = Mock() - client.configuration.transport.http_session.request.return_value.content = None - client.configuration.transport.http_session.request.return_value.headers = None - client.configuration.transport.prepare_request = Mock() - client.configuration.transport.authenticate = Mock() - return client - - -def test_default_logger(sinch_client_sync, caplog): - sinch_client_sync.configuration.logger.setLevel(logging.DEBUG) - sinch_client = mock_http_transport(sinch_client_sync) - http_endpoint = Mock() - sinch_client.configuration.transport.request(http_endpoint) - assert len(caplog.get_records("call")) == 2 - assert caplog.records[0].levelname == "DEBUG" - - -def test_changing_logger_name_within_the_client(sinch_client_sync, caplog): - logger_name = "SumOlimpijczyk" - sinch_client_sync.configuration.logger.setLevel(logging.DEBUG) - sinch_client_sync.configuration.logger.name = logger_name - sinch_client = mock_http_transport(sinch_client_sync) - caplog.set_level(logging.DEBUG, logger=logger_name) - http_endpoint = Mock() - sinch_client.configuration.transport.request(http_endpoint) - - assert len([record for record in caplog.records if record.name == logger_name]) == 2 - assert caplog.records[0].name == logger_name - - -def test_logger_with_logging_to_file(sinch_client_sync): - with tempfile.NamedTemporaryFile() as fp: - file_handler = logging.FileHandler(fp.name) - sinch_client_sync.configuration.logger.setLevel(logging.DEBUG) - sinch_client_sync.configuration.logger.addHandler(file_handler) - sinch_client = mock_http_transport(sinch_client_sync) - http_endpoint = Mock() - sinch_client.configuration.transport.request(http_endpoint) - logging_output = fp.read().decode("utf-8") - assert "HTTP" in logging_output - assert "response" in logging_output diff --git a/tests/integration/test_request_signing.py b/tests/integration/test_request_signing.py deleted file mode 100644 index 46e49abc..00000000 --- a/tests/integration/test_request_signing.py +++ /dev/null @@ -1,60 +0,0 @@ -import json -from sinch.core.signature import Signature - - -def test_request_signature( - sinch_client_sync, - verification_request_signature, - verification_request_signature_timestamp -): - signature = Signature( - sinch_client_sync, - http_method="GET", - request_data=json.dumps({"test": "test"}), - request_uri="/verification/v1/verifications", - signature_timestamp=verification_request_signature_timestamp - ) - signature.calculate() - - assert signature.authorization_signature - assert isinstance(signature.authorization_signature, str) - assert verification_request_signature == signature.authorization_signature - - -def test_request_signature_using_empty_body( - sinch_client_sync, - verification_request_with_empty_body_signature, - verification_request_signature_timestamp -): - signature = Signature( - sinch_client_sync, - http_method="POST", - request_data=None, - request_uri="/verification/v1/verifications", - signature_timestamp=verification_request_signature_timestamp - ) - signature.calculate() - - assert signature.authorization_signature - assert isinstance(signature.authorization_signature, str) - assert verification_request_with_empty_body_signature == signature.authorization_signature - - -def test_get_headers_with_signature_and_async_client( - sinch_client_async, - verification_request_with_empty_body_signature, - verification_request_signature_timestamp -): - signature = Signature( - sinch_client_async, - http_method="POST", - request_data=None, - request_uri="/verification/v1/verifications", - signature_timestamp=verification_request_signature_timestamp - ) - headers = signature.get_http_headers_with_signature() - - assert "x-timestamp" in headers - assert "Authorization" in headers - assert "Content-Type" in headers - assert verification_request_with_empty_body_signature in headers["Authorization"] diff --git a/tests/integration/test_sms_endpoint_credendials_formatting.py b/tests/integration/test_sms_endpoint_credendials_formatting.py deleted file mode 100644 index 4c8a0151..00000000 --- a/tests/integration/test_sms_endpoint_credendials_formatting.py +++ /dev/null @@ -1,23 +0,0 @@ -from sinch.domains.sms.endpoints.sms_endpoint import SMSEndpoint -from sinch.core.enums import HTTPAuthentication - - -def test_sms_endpoint_service_plan_id_credentials_processing(sinch_client_sync_with_service_plan_id, service_plan_id): - sms_endpoint = SMSEndpoint( - sinch=sinch_client_sync_with_service_plan_id, - request_data={} - ) - assert sms_endpoint.project_or_service_id == service_plan_id - assert sms_endpoint.HTTP_AUTHENTICATION == HTTPAuthentication.SMS_TOKEN.value - assert ( - sms_endpoint.sms_origin == sinch_client_sync_with_service_plan_id.configuration.sms_origin_with_service_plan_id - ) - - -def test_sms_endpoint_with_project_id_credentials_processing(sinch_client_sync, project_id): - sms_endpoint = SMSEndpoint( - sinch=sinch_client_sync, - request_data={} - ) - assert sms_endpoint.project_or_service_id == project_id - assert sms_endpoint.sms_origin == sinch_client_sync.configuration.sms_origin diff --git a/tests/integration/test_token_refresh.py b/tests/integration/test_token_refresh.py deleted file mode 100644 index 36b97fd3..00000000 --- a/tests/integration/test_token_refresh.py +++ /dev/null @@ -1,62 +0,0 @@ -import pytest -from unittest.mock import Mock, AsyncMock - -from sinch.core.models.http_response import HTTPResponse -from sinch.domains.authentication.endpoints.oauth import OAuthEndpoint -from sinch.domains.numbers.endpoints.available.list_available_numbers import AvailableNumbersEndpoint -from sinch.domains.authentication.exceptions import AuthenticationException - - -def test_handling_401_without_expiration( - sinch_client_sync, - auth_token_as_dict, - project_id -): - http_response = HTTPResponse( - status_code=401, - headers={ - "wwww-authenticaiton": "Bearer error='invalid_token', error_description='Unable to parse token'" - }, - body={} - ) - sinch_client_sync.configuration.token_manager.set_auth_token(auth_token_as_dict) - - with pytest.raises(AuthenticationException): - sinch_client_sync.configuration.transport.handle_response( - http_response=http_response, - endpoint=OAuthEndpoint() - ) - - -def test_handling_401_with_expired_token_gets_invalidated_and_refreshed( - sinch_client_sync, - auth_token_as_dict, - expired_token_http_response, - project_id -): - sinch_client_sync.configuration.token_manager.set_auth_token(auth_token_as_dict) - sinch_client_sync.configuration.transport.request = Mock() - sinch_client_sync.configuration.transport.request.return_value = "Token Refresh!" - - transport_response = sinch_client_sync.configuration.transport.handle_response( - http_response=expired_token_http_response, - endpoint=AvailableNumbersEndpoint(project_id, {}) - ) - assert transport_response == "Token Refresh!" - - -async def test_handling_401_with_expired_token_gets_refreshed_async( - sinch_client_async, - auth_token_as_dict, - expired_token_http_response, - project_id -): - sinch_client_async.configuration.token_manager.set_auth_token(auth_token_as_dict) - sinch_client_async.configuration.transport.request = AsyncMock() - sinch_client_async.configuration.transport.request.return_value = "Token Refresh!" - - transport_response = await sinch_client_async.configuration.transport.handle_response( - http_response=expired_token_http_response, - endpoint=AvailableNumbersEndpoint(project_id, {}) - ) - assert transport_response == "Token Refresh!"