From c78e3a92c70423cd6c60bbcd7e3d2cd15c74c03a Mon Sep 17 00:00:00 2001 From: vionash <61507189+vionash@users.noreply.github.com> Date: Fri, 25 Feb 2022 23:47:49 -0600 Subject: [PATCH] 2.0 Update + Prism Mock Support (#67) * API Parity Update + Prism Mock Server * lint/formatting changes * more formatting changes * prism-mock fix * version increment Co-authored-by: Vladii --- .github/scripts/before_install.sh | 18 +++-- .github/workflows/python.yml | 4 +- .gitignore | 3 +- setup.py | 2 +- telnyx/__init__.py | 2 +- telnyx/api_requestor.py | 2 +- telnyx/api_resources/__init__.py | 78 ++++++++++++++++++- .../abstract/updateable_api_resource.py | 12 +++ telnyx/api_resources/access_control_ip.py | 11 +++ telnyx/api_resources/access_ip_address.py | 15 ++++ .../api_resources/authentication_provider.py | 17 ++++ telnyx/api_resources/brand.py | 34 ++++++++ telnyx/api_resources/bulk_creation.py | 28 +++++++ telnyx/api_resources/campaign.py | 44 +++++++++++ telnyx/api_resources/comment.py | 7 ++ telnyx/api_resources/conference.py | 14 ++++ .../custom_storage_credential.py | 17 ++++ telnyx/api_resources/document.py | 26 +++++++ .../dynamic_emergency_address.py | 21 +++++ telnyx/api_resources/fax.py | 5 ++ telnyx/api_resources/inventory_coverage.py | 18 +++++ telnyx/api_resources/managed_account.py | 20 +++++ telnyx/api_resources/media.py | 26 +++++++ .../api_resources/messaging_hosted_number.py | 4 +- .../messaging_hosted_number_order.py | 4 +- telnyx/api_resources/messaging_profile.py | 4 + telnyx/api_resources/notification_channel.py | 17 ++++ ...y_requirement.py => notification_event.py} | 4 +- .../notification_event_condition.py | 7 ++ telnyx/api_resources/notification_profiles.py | 17 ++++ telnyx/api_resources/notification_setting.py | 13 ++++ .../api_resources/phone_assignment_profile.py | 28 +++++++ telnyx/api_resources/phone_number_campaign.py | 21 +++++ telnyx/api_resources/phone_number_jobs.py | 49 ++++++++++++ telnyx/api_resources/portability_check.py | 4 +- telnyx/api_resources/porting_order.py | 23 ++++++ telnyx/api_resources/portout.py | 12 +++ telnyx/api_resources/queue.py | 4 +- telnyx/api_resources/room.py | 36 +++++++++ telnyx/api_resources/room_participant.py | 7 ++ telnyx/api_resources/room_session.py | 33 ++++++++ telnyx/api_resources/sim_card.py | 35 ++++++++- telnyx/api_resources/sim_card_action.py | 7 ++ telnyx/api_resources/sim_card_group.py | 17 ++++ telnyx/api_resources/sim_card_order.py | 15 ++++ telnyx/api_resources/sub_number_order.py | 17 ++++ telnyx/api_resources/telephony_credential.py | 5 ++ telnyx/api_resources/verification.py | 4 +- telnyx/api_resources/webhook_deliveries.py | 11 +++ .../whatsapp_business_account.py | 7 ++ telnyx/api_resources/whatsapp_contact.py | 7 ++ telnyx/api_resources/whatsapp_media.py | 15 ++++ telnyx/api_resources/whatsapp_message.py | 13 ++++ telnyx/api_resources/whatsapp_phone_number.py | 7 ++ .../wireless_detail_record_report.py | 17 ++++ telnyx/error.py | 4 +- telnyx/multipart_data_generator.py | 2 +- telnyx/util.py | 42 +++++++++- tests/api_resources/test_access_control_ip.py | 32 ++++++++ tests/api_resources/test_address.py | 2 +- .../test_authentication_provider.py | 56 +++++++++++++ tests/api_resources/test_billing_group.py | 2 +- .../test_call_control_application.py | 2 +- tests/api_resources/test_campaign.py | 35 +++++++++ tests/api_resources/test_comment.py | 26 +++++++ tests/api_resources/test_conference.py | 18 ++++- .../test_custom_storage_credential.py | 43 ++++++++++ tests/api_resources/test_document.py | 55 +++++++++++++ .../test_dynamic_emergency_address.py | 34 ++++++++ tests/api_resources/test_fax.py | 11 +++ tests/api_resources/test_fax_applications.py | 2 +- tests/api_resources/test_fqdn.py | 2 +- tests/api_resources/test_fqdn_connection.py | 51 ------------ .../api_resources/test_inventory_coverage.py | 16 ++++ tests/api_resources/test_managed_account.py | 51 ++++++++++++ tests/api_resources/test_media.py | 40 ++++++++++ .../test_messaging_hosted_number.py | 2 +- .../test_messaging_phone_number.py | 44 ----------- tests/api_resources/test_messaging_profile.py | 12 ++- .../test_notification_channel.py | 43 ++++++++++ .../api_resources/test_notification_event.py | 10 +++ .../test_notification_event_condition.py | 10 +++ .../test_notification_profile.py | 43 ++++++++++ .../test_notification_setting.py | 35 +++++++++ .../api_resources/test_number_reservation.py | 6 +- ...ile.py => test_outbound_voice_profiles.py} | 2 +- .../test_phone_number_campaign.py | 44 +++++++++++ tests/api_resources/test_phone_number_job.py | 41 ++++++++++ ...est_phone_number_regulatory_requirement.py | 7 +- tests/api_resources/test_porting_order.py | 39 ++++++++-- tests/api_resources/test_portout.py | 16 ++++ tests/api_resources/test_public_key.py | 2 +- .../test_regulatory_requirement.py | 20 ----- tests/api_resources/test_room.py | 55 +++++++++++++ tests/api_resources/test_room_participant.py | 18 +++++ tests/api_resources/test_room_sessions.py | 52 +++++++++++++ tests/api_resources/test_short_code.py | 2 +- tests/api_resources/test_sim_card.py | 40 +++++++++- tests/api_resources/test_sim_card_action.py | 20 +++++ tests/api_resources/test_sim_card_group.py | 49 ++++++++++++ tests/api_resources/test_sim_card_order.py | 28 +++++++ tests/api_resources/test_sub_number_order.py | 25 ++++++ .../test_telephony_credential.py | 13 +++- tests/api_resources/test_verification.py | 8 +- tests/api_resources/test_verify_profiles.py | 6 +- .../api_resources/test_webhook_deliveries.py | 17 ++++ .../test_whatsapp_business_account.py | 17 ++++ tests/api_resources/test_whatsapp_contact.py | 14 ++++ tests/api_resources/test_whatsapp_media.py | 20 +++++ tests/api_resources/test_whatsapp_message.py | 24 ++++++ .../test_whatsapp_phone_number.py | 22 ++++++ .../test_wireless_details_record_report.py | 29 +++++++ tests/conftest.py | 3 +- tests/test_api_requestor.py | 4 +- tests/test_error.py | 20 ++--- tests/test_multipart_data_generator.py | 2 +- tests/test_telnyx_object.py | 8 +- 117 files changed, 2077 insertions(+), 209 deletions(-) create mode 100644 telnyx/api_resources/access_control_ip.py create mode 100644 telnyx/api_resources/access_ip_address.py create mode 100644 telnyx/api_resources/authentication_provider.py create mode 100644 telnyx/api_resources/brand.py create mode 100644 telnyx/api_resources/bulk_creation.py create mode 100644 telnyx/api_resources/campaign.py create mode 100644 telnyx/api_resources/comment.py create mode 100644 telnyx/api_resources/custom_storage_credential.py create mode 100644 telnyx/api_resources/document.py create mode 100644 telnyx/api_resources/dynamic_emergency_address.py create mode 100644 telnyx/api_resources/inventory_coverage.py create mode 100644 telnyx/api_resources/managed_account.py create mode 100644 telnyx/api_resources/media.py create mode 100644 telnyx/api_resources/notification_channel.py rename telnyx/api_resources/{regulatory_requirement.py => notification_event.py} (58%) create mode 100644 telnyx/api_resources/notification_event_condition.py create mode 100644 telnyx/api_resources/notification_profiles.py create mode 100644 telnyx/api_resources/notification_setting.py create mode 100644 telnyx/api_resources/phone_assignment_profile.py create mode 100644 telnyx/api_resources/phone_number_campaign.py create mode 100644 telnyx/api_resources/phone_number_jobs.py create mode 100644 telnyx/api_resources/room.py create mode 100644 telnyx/api_resources/room_participant.py create mode 100644 telnyx/api_resources/room_session.py create mode 100644 telnyx/api_resources/sim_card_action.py create mode 100644 telnyx/api_resources/sim_card_group.py create mode 100644 telnyx/api_resources/sim_card_order.py create mode 100644 telnyx/api_resources/sub_number_order.py create mode 100644 telnyx/api_resources/webhook_deliveries.py create mode 100644 telnyx/api_resources/whatsapp_business_account.py create mode 100644 telnyx/api_resources/whatsapp_contact.py create mode 100644 telnyx/api_resources/whatsapp_media.py create mode 100644 telnyx/api_resources/whatsapp_message.py create mode 100644 telnyx/api_resources/whatsapp_phone_number.py create mode 100644 telnyx/api_resources/wireless_detail_record_report.py create mode 100644 tests/api_resources/test_access_control_ip.py create mode 100644 tests/api_resources/test_authentication_provider.py create mode 100644 tests/api_resources/test_campaign.py create mode 100644 tests/api_resources/test_comment.py create mode 100644 tests/api_resources/test_custom_storage_credential.py create mode 100644 tests/api_resources/test_document.py create mode 100644 tests/api_resources/test_dynamic_emergency_address.py delete mode 100644 tests/api_resources/test_fqdn_connection.py create mode 100644 tests/api_resources/test_inventory_coverage.py create mode 100644 tests/api_resources/test_managed_account.py create mode 100644 tests/api_resources/test_media.py delete mode 100644 tests/api_resources/test_messaging_phone_number.py create mode 100644 tests/api_resources/test_notification_channel.py create mode 100644 tests/api_resources/test_notification_event.py create mode 100644 tests/api_resources/test_notification_event_condition.py create mode 100644 tests/api_resources/test_notification_profile.py create mode 100644 tests/api_resources/test_notification_setting.py rename tests/api_resources/{test_outbound_voice_profile.py => test_outbound_voice_profiles.py} (98%) create mode 100644 tests/api_resources/test_phone_number_campaign.py create mode 100644 tests/api_resources/test_phone_number_job.py delete mode 100644 tests/api_resources/test_regulatory_requirement.py create mode 100644 tests/api_resources/test_room.py create mode 100644 tests/api_resources/test_room_participant.py create mode 100644 tests/api_resources/test_room_sessions.py create mode 100644 tests/api_resources/test_sim_card_action.py create mode 100644 tests/api_resources/test_sim_card_group.py create mode 100644 tests/api_resources/test_sim_card_order.py create mode 100644 tests/api_resources/test_sub_number_order.py create mode 100644 tests/api_resources/test_webhook_deliveries.py create mode 100644 tests/api_resources/test_whatsapp_business_account.py create mode 100644 tests/api_resources/test_whatsapp_contact.py create mode 100644 tests/api_resources/test_whatsapp_media.py create mode 100644 tests/api_resources/test_whatsapp_message.py create mode 100644 tests/api_resources/test_whatsapp_phone_number.py create mode 100644 tests/api_resources/test_wireless_details_record_report.py diff --git a/.github/scripts/before_install.sh b/.github/scripts/before_install.sh index 986e8b3..dbcab8c 100755 --- a/.github/scripts/before_install.sh +++ b/.github/scripts/before_install.sh @@ -1,8 +1,10 @@ -if [ ! -d "telnyx-mock/${TELNYX_MOCK_VERSION}" ]; then - mkdir -p telnyx-mock/${TELNYX_MOCK_VERSION} - curl -L "https://github.com/team-telnyx/telnyx-mock/releases/download/v${TELNYX_MOCK_VERSION}/telnyx-mock_${TELNYX_MOCK_VERSION}_linux_amd64.tar.gz" -o "telnyx-mock/${TELNYX_MOCK_VERSION}_linux_amd64.tar.gz" - tar -zxf "telnyx-mock/${TELNYX_MOCK_VERSION}_linux_amd64.tar.gz" -C "telnyx-mock/${TELNYX_MOCK_VERSION}/" -fi -telnyx-mock/${TELNYX_MOCK_VERSION}/telnyx-mock >/dev/null & -TELNYX_MOCK_PID=$! -export PATH="${PATH}:${PWD}/telnyx-mock/${TELNYX_MOCK_VERSION}" +npm install -g @stoplight/prism-cli + +echo "Starting up Prism Mock Server with spec file at ${TELNYX_MOCK_OPEN_API_URI}" +prism mock ${TELNYX_MOCK_OPEN_API_URI} > /dev/null & + +git clone https://github.com/team-telnyx/telnyx-prism-mock.git +cd telnyx-prism-mock/proxy +npm install +node index.js > /dev/null & +cd - \ No newline at end of file diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index a03912c..06dd19a 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -4,9 +4,9 @@ on: jobs: test: env: - TELNYX_MOCK_VERSION: 0.8.13 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }} + TELNYX_MOCK_OPEN_API_URI: https://raw.githubusercontent.com/team-telnyx/openapi/master/openapi/spec3.json runs-on: ${{ matrix.os }} strategy: matrix: @@ -20,7 +20,7 @@ jobs: python-version: ${{ matrix.python-version }} - uses: gabrielfalcao/pyenv-action@v7 - uses: dschep/install-pipenv-action@v1 - - name: setup-telnyx-mock + - name: setup-telnyx-prism-mock run: source ./.github/scripts/before_install.sh - name: init run: make init diff --git a/.gitignore b/.gitignore index 05b89e7..6fdafd2 100644 --- a/.gitignore +++ b/.gitignore @@ -31,4 +31,5 @@ htmlcov/ sonar-project.* .pypirc-telnyx -Pipfile.lock \ No newline at end of file +Pipfile.lock +requirements.txt diff --git a/setup.py b/setup.py index cb210ef..99f959d 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ def run_tests(self): setup( name="telnyx", - version="1.5.0", + version="2.0.0", description="Python bindings for the Telnyx API", long_description=long_description, long_description_content_type="text/markdown", diff --git a/telnyx/__init__.py b/telnyx/__init__.py index 7522ca2..ab9418f 100644 --- a/telnyx/__init__.py +++ b/telnyx/__init__.py @@ -24,7 +24,7 @@ log = None -__version__ = "1.5.0" +__version__ = "2.0.0" # Sets some basic information about the running application that's sent along diff --git a/telnyx/api_requestor.py b/telnyx/api_requestor.py index 1fa2dd4..7c8f70b 100644 --- a/telnyx/api_requestor.py +++ b/telnyx/api_requestor.py @@ -225,7 +225,7 @@ def request_raw(self, method, url, params=None, supplied_headers=None): if params: abs_url = _build_api_url(abs_url, encoded_params) post_data = None - elif method == "post" or method == "patch": + elif method == "post" or method == "patch" or method == "put": if ( supplied_headers.get("Content-Type", "application/json") == "application/json" diff --git a/telnyx/api_resources/__init__.py b/telnyx/api_resources/__init__.py index eef97c2..d291688 100644 --- a/telnyx/api_resources/__init__.py +++ b/telnyx/api_resources/__init__.py @@ -1,25 +1,38 @@ from __future__ import absolute_import, division, print_function +from telnyx.api_resources.access_control_ip import AccessControlIP +from telnyx.api_resources.access_ip_address import AccessIPAddress from telnyx.api_resources.address import Address from telnyx.api_resources.api_key import APIKey +from telnyx.api_resources.authentication_provider import AuthenticationProvider from telnyx.api_resources.available_phone_number import AvailablePhoneNumber from telnyx.api_resources.balance import Balance from telnyx.api_resources.billing_group import BillingGroup +from telnyx.api_resources.brand import Brand +from telnyx.api_resources.bulk_creation import BulkCreation from telnyx.api_resources.call import Call from telnyx.api_resources.call_control_application import CallControlApplication +from telnyx.api_resources.campaign import Campaign +from telnyx.api_resources.comment import Comment from telnyx.api_resources.conference import Conference from telnyx.api_resources.connection import Connection from telnyx.api_resources.credential_connection import CredentialConnection +from telnyx.api_resources.custom_storage_credential import CustomStorageCredential from telnyx.api_resources.detail_records_report import DetailRecordsReport +from telnyx.api_resources.document import Document, DocumentLink +from telnyx.api_resources.dynamic_emergency_address import DynamicEmergencyAddress from telnyx.api_resources.event import Event from telnyx.api_resources.fax import Fax from telnyx.api_resources.fax_application import FaxApplication from telnyx.api_resources.fqdn import FQDN from telnyx.api_resources.fqdn_connection import FQDNConnection from telnyx.api_resources.inbound_channel import InboundChannel +from telnyx.api_resources.inventory_coverage import InventoryCoverage from telnyx.api_resources.ip import IP from telnyx.api_resources.ip_connection import IPConnection from telnyx.api_resources.list_object import ListObject +from telnyx.api_resources.managed_account import ManagedAccount +from telnyx.api_resources.media import Media from telnyx.api_resources.message import Message from telnyx.api_resources.messaging_hosted_number import MessagingHostedNumber from telnyx.api_resources.messaging_hosted_number_order import ( @@ -27,16 +40,24 @@ ) from telnyx.api_resources.messaging_phone_number import MessagingPhoneNumber from telnyx.api_resources.messaging_profile import MessagingProfile +from telnyx.api_resources.notification_channel import NotificationChannel +from telnyx.api_resources.notification_event import NotificationEvent +from telnyx.api_resources.notification_event_condition import NotificationEventCondition +from telnyx.api_resources.notification_profiles import NotificationProfile +from telnyx.api_resources.notification_setting import NotificationSetting from telnyx.api_resources.number_lookup import NumberLookup from telnyx.api_resources.number_order import NumberOrder from telnyx.api_resources.number_order_phone_number import NumberOrderPhoneNumber from telnyx.api_resources.number_reservation import NumberReservation from telnyx.api_resources.outbound_voice_profile import OutboundVoiceProfile +from telnyx.api_resources.phone_assignment_profile import PhoneNumberByProfile from telnyx.api_resources.phone_number import ( MessagingSettings, PhoneNumber, VoiceSettings, ) +from telnyx.api_resources.phone_number_campaign import PhoneNumberCampaign +from telnyx.api_resources.phone_number_jobs import PhoneNumberJob from telnyx.api_resources.phone_number_regulatory_requirement import ( PhoneNumberRegulatoryRequirement, ) @@ -45,49 +66,86 @@ from telnyx.api_resources.portout import PortOut from telnyx.api_resources.public_key import PublicKey from telnyx.api_resources.queue import Queue, QueueCall -from telnyx.api_resources.regulatory_requirement import RegulatoryRequirement +from telnyx.api_resources.room import Room +from telnyx.api_resources.room_participant import RoomParticipant +from telnyx.api_resources.room_session import RoomSession, RoomSessionList from telnyx.api_resources.short_code import ShortCode from telnyx.api_resources.sim_card import SIMCard +from telnyx.api_resources.sim_card_action import SIMCardAction +from telnyx.api_resources.sim_card_group import SIMCardGroup +from telnyx.api_resources.sim_card_order import SIMCardOrder, SIMCardOrderPreview +from telnyx.api_resources.sub_number_order import SubNumberOrder from telnyx.api_resources.telephony_credential import TelephonyCredential from telnyx.api_resources.verification import Verification from telnyx.api_resources.verify_profile import VerifyProfile +from telnyx.api_resources.webhook_deliveries import WebhookDeliveries +from telnyx.api_resources.whatsapp_business_account import WhatsappBusinessAccount +from telnyx.api_resources.whatsapp_contact import WhatsappContact +from telnyx.api_resources.whatsapp_media import WhatsappMedia +from telnyx.api_resources.whatsapp_message import WhatsappMessage +from telnyx.api_resources.whatsapp_phone_number import WhatsappPhoneNumber +from telnyx.api_resources.wireless_detail_record_report import ( + WirelessDetailRecordsReports, +) # flake8: noqa __all__ = [ + "AccessControlIP", + "AccessIPAddress", + "AuthenticationProvider", "Address", "APIKey", "AvailablePhoneNumber", "Balance", "BillingGroup", + "Brand", + "BulkCreation", "Call", "CallControlApplication", + "Campaign", + "Comment", "Conference", "Connection", "CredentialConnection", + "CustomStorageCredential", "DetailRecordsReport", + "Document", + "DocumentLink", + "DynamicEmergencyAddress", "Event", "Fax", "FaxApplication", "FQDN", "FQDNConnection", "InboundChannel", + "InventoryCoverage", "IP", "IPConnection", "ListObject", + "ManagedAccount", + "Media", "Message", "MessagingHostedNumber", "MessagingHostedNumberOrder", "MessagingPhoneNumber", "MessagingProfile", "MessagingSettings", + "NotificationChannel", + "NotificationEvent", + "NotificationEventCondition", + "NotificationProfile", + "NotificationSetting", "NumberLookup", "NumberOrder", "NumberOrderPhoneNumber", "NumberReservation", "OutboundVoiceProfile", "PhoneNumber", + "PhoneNumberByProfile", + "PhoneNumberCampaign", + "PhoneNumberJob", "PhoneNumberRegulatoryRequirement", "PortabilityCheck", "PortingOrder", @@ -96,11 +154,25 @@ "PublicKey", "Queue", "QueueCall", - "RegulatoryRequirement", - "SIMCard", + "Room", + "RoomParticipant", + "RoomSession", "ShortCode", + "SIMCard", + "SIMCardAction", + "SIMCardGroup", + "SIMCardOrder", + "SIMCardOrderPreview", + "SubNumberOrder", "TelephonyCredential", "Verification", "VerifyProfile", "VoiceSettings", + "WebhookDeliveries", + "WhatsappBusinessAccount", + "WhatsappContact", + "WhatsappMedia", + "WhatsappMessage", + "WhatsappPhoneNumber", + "WirelessDetailRecordsReports", ] diff --git a/telnyx/api_resources/abstract/updateable_api_resource.py b/telnyx/api_resources/abstract/updateable_api_resource.py index f65fc15..0cb3b69 100644 --- a/telnyx/api_resources/abstract/updateable_api_resource.py +++ b/telnyx/api_resources/abstract/updateable_api_resource.py @@ -18,6 +18,18 @@ def modify(cls, sid, **params): url = "%s/%s" % (cls.class_url(), quote_plus(util.utf8(sid))) return cls._modify(url, **params) + @classmethod + def _putify(cls, url, api_key=None, **params): + requestor = api_requestor.APIRequestor(api_key) + params = util.rewrite_reserved_words(params) + response, api_key = requestor.request("put", url, params) + return util.convert_to_telnyx_object(response, api_key) + + @classmethod + def putify(cls, sid, **params): + url = "%s/%s" % (cls.class_url(), quote_plus(util.utf8(sid))) + return cls._putify(url, **params) + def save(self): updated_params = self.serialize(None) diff --git a/telnyx/api_resources/access_control_ip.py b/telnyx/api_resources/access_control_ip.py new file mode 100644 index 0000000..d550e0c --- /dev/null +++ b/telnyx/api_resources/access_control_ip.py @@ -0,0 +1,11 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, +) + + +class AccessControlIP(CreateableAPIResource, DeletableAPIResource, ListableAPIResource): + OBJECT_NAME = "access_control_ip" diff --git a/telnyx/api_resources/access_ip_address.py b/telnyx/api_resources/access_ip_address.py new file mode 100644 index 0000000..486272e --- /dev/null +++ b/telnyx/api_resources/access_ip_address.py @@ -0,0 +1,15 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, +) + + +class AccessIPAddress(CreateableAPIResource, DeletableAPIResource, ListableAPIResource): + OBJECT_NAME = "access_ip_address" + + @classmethod + def class_url(cls): + return "/v2/access_ip_address" diff --git a/telnyx/api_resources/authentication_provider.py b/telnyx/api_resources/authentication_provider.py new file mode 100644 index 0000000..b9c91a3 --- /dev/null +++ b/telnyx/api_resources/authentication_provider.py @@ -0,0 +1,17 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +) + + +class AuthenticationProvider( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +): + OBJECT_NAME = "authentication_provider" diff --git a/telnyx/api_resources/brand.py b/telnyx/api_resources/brand.py new file mode 100644 index 0000000..fa47729 --- /dev/null +++ b/telnyx/api_resources/brand.py @@ -0,0 +1,34 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, + nested_resource_class_methods, +) + + +@nested_resource_class_methods( + "list_external_vetting", path="externalVetting", operations=["list"] +) +@nested_resource_class_methods( + "order_external_vetting", path="externalVetting", operations=["create"] +) +class Brand( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +): + OBJECT_NAME = "brand" + + @classmethod + def class_url(cls): + return "/10dlc/brand" + + def list_external_vetting(self, **params): + return Brand.list_external_vetting(self.name, **params) + + def operation_status(self, **params): + return Brand.create_external_vetting(self.id, **params) diff --git a/telnyx/api_resources/bulk_creation.py b/telnyx/api_resources/bulk_creation.py new file mode 100644 index 0000000..99574cc --- /dev/null +++ b/telnyx/api_resources/bulk_creation.py @@ -0,0 +1,28 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, + nested_resource_class_methods, +) + + +@nested_resource_class_methods( + "detailed_status", path="detailedStatus", operations=["list"] +) +class BulkCreation( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +): + OBJECT_NAME = "bulk_creation" + + @classmethod + def class_url(cls): + return "/10dlc/bulkCreation" + + def detailed_status(self, **params): + return BulkCreation.list_detailed_status(self.name, **params) diff --git a/telnyx/api_resources/campaign.py b/telnyx/api_resources/campaign.py new file mode 100644 index 0000000..be316ee --- /dev/null +++ b/telnyx/api_resources/campaign.py @@ -0,0 +1,44 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, + nested_resource_class_methods, +) + + +@nested_resource_class_methods("mno_metadata", path="mnoMetadata", operations=["list"]) +@nested_resource_class_methods( + "operation_status", path="operationStatus", operations=["list"] +) +class Campaign( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +): + OBJECT_NAME = "campaign" + + @classmethod + def class_url(cls): + return "/10dlc/campaign" + + def mno_metadata(self, **params): + return Campaign.list_mno_metadata(self.name, **params) + + def operation_status(self, **params): + return Campaign.list_mno_metadata(self.name, **params) + + +class CampaignBuilder(CreateableAPIResource): + OBJECT_NAME = "campaign_builder" + + +@nested_resource_class_methods("usecase", path="usecase", operations=["retrieve"]) +class CampaignBuilderBrand(ListableAPIResource): + OBJECT_NAME = "campaign_builder_brand" + + def download(self, **params): + return Campaign.create_usecase(self.id, **params) diff --git a/telnyx/api_resources/comment.py b/telnyx/api_resources/comment.py new file mode 100644 index 0000000..d01b3ba --- /dev/null +++ b/telnyx/api_resources/comment.py @@ -0,0 +1,7 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import CreateableAPIResource, ListableAPIResource + + +class Comment(ListableAPIResource, CreateableAPIResource): + OBJECT_NAME = "comment" diff --git a/telnyx/api_resources/conference.py b/telnyx/api_resources/conference.py index 2e4aa7c..cd237f7 100644 --- a/telnyx/api_resources/conference.py +++ b/telnyx/api_resources/conference.py @@ -22,12 +22,20 @@ "record_stop", path="actions/record_stop", operations=["create"] ) @nested_resource_class_methods("update", path="actions/update", operations=["create"]) +@nested_resource_class_methods("leave", path="actions/leave", operations=["create"]) +@nested_resource_class_methods( + "dial_participant", path="actions/dial_participant", operations=["create"] +) +@nested_resource_class_methods("participants", path="participants", operations=["list"]) class Conference(CreateableAPIResource, ListableAPIResource): OBJECT_NAME = "conference" def join(self, **params): return Conference.create_join(self.id, **params) + def dial_participant(self, **params): + return Conference.create_dial_participant(self.id, **params) + def mute(self, **params): return Conference.create_mute(self.id, **params) @@ -57,3 +65,9 @@ def record_stop(self, **params): def update(self, **params): return Conference.create_update(self.id, **params) + + def leave(self, **params): + return Conference.create_leave(self.id, **params) + + def participants(self, **params): + return Conference.create_participants(self.name, **params) diff --git a/telnyx/api_resources/custom_storage_credential.py b/telnyx/api_resources/custom_storage_credential.py new file mode 100644 index 0000000..18c2928 --- /dev/null +++ b/telnyx/api_resources/custom_storage_credential.py @@ -0,0 +1,17 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +) + + +class CustomStorageCredential( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +): + OBJECT_NAME = "custom_storage_credential" diff --git a/telnyx/api_resources/document.py b/telnyx/api_resources/document.py new file mode 100644 index 0000000..dbcf04d --- /dev/null +++ b/telnyx/api_resources/document.py @@ -0,0 +1,26 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, + nested_resource_class_methods, +) + + +@nested_resource_class_methods("download", path="download", operations=["list"]) +class Document( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +): + OBJECT_NAME = "document" + + def download(self, **params): + return Document.list_download(self.name, **params) + + +class DocumentLink(ListableAPIResource): + OBJECT_NAME = "document_link" diff --git a/telnyx/api_resources/dynamic_emergency_address.py b/telnyx/api_resources/dynamic_emergency_address.py new file mode 100644 index 0000000..7743883 --- /dev/null +++ b/telnyx/api_resources/dynamic_emergency_address.py @@ -0,0 +1,21 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +) + + +class DynamicEmergencyAddress( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +): + OBJECT_NAME = "dynamic_emergency_address" + + @classmethod + def class_url(cls): + return "/v2/dynamic_emergency_addresses" diff --git a/telnyx/api_resources/fax.py b/telnyx/api_resources/fax.py index 9460a21..ee45c26 100644 --- a/telnyx/api_resources/fax.py +++ b/telnyx/api_resources/fax.py @@ -5,9 +5,11 @@ DeletableAPIResource, ListableAPIResource, UpdateableAPIResource, + nested_resource_class_methods, ) +@nested_resource_class_methods("refresh", path="actions/refresh", operations=["create"]) class Fax( CreateableAPIResource, DeletableAPIResource, @@ -19,3 +21,6 @@ class Fax( @classmethod def class_url(cls): return "/v2/faxes" + + def refresh(self, **params): + return Fax.create_refresh(self.id, **params) diff --git a/telnyx/api_resources/inventory_coverage.py b/telnyx/api_resources/inventory_coverage.py new file mode 100644 index 0000000..a971666 --- /dev/null +++ b/telnyx/api_resources/inventory_coverage.py @@ -0,0 +1,18 @@ +from __future__ import absolute_import, division, print_function + +from telnyx import error +from telnyx.api_resources.abstract import ListableAPIResource + + +class InventoryCoverage(ListableAPIResource): + OBJECT_NAME = "inventory_coverage" + + @classmethod + def retrieve(cls, id, api_key=None, **params): + raise error.InvalidRequestError( + "%s does not support retrieve()" % cls.class_url() + ) + + @classmethod + def class_url(cls): + return "/v2/inventory_coverage" diff --git a/telnyx/api_resources/managed_account.py b/telnyx/api_resources/managed_account.py new file mode 100644 index 0000000..32f8feb --- /dev/null +++ b/telnyx/api_resources/managed_account.py @@ -0,0 +1,20 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + ListableAPIResource, + UpdateableAPIResource, + nested_resource_class_methods, +) + + +@nested_resource_class_methods("enable", path="actions/enable", operations=["create"]) +@nested_resource_class_methods("disable", path="actions/disable", operations=["create"]) +class ManagedAccount(CreateableAPIResource, ListableAPIResource, UpdateableAPIResource): + OBJECT_NAME = "managed_account" + + def enable(self, **params): + return ManagedAccount.create_enable(self.id, **params) + + def disable(self, **params): + return ManagedAccount.create_disable(self.id, **params) diff --git a/telnyx/api_resources/media.py b/telnyx/api_resources/media.py new file mode 100644 index 0000000..88df0ed --- /dev/null +++ b/telnyx/api_resources/media.py @@ -0,0 +1,26 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, + nested_resource_class_methods, +) + + +@nested_resource_class_methods("download", path="download", operations=["list"]) +class Media( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +): + OBJECT_NAME = "media" + + @classmethod + def class_url(cls): + return "/v2/media" + + def download(self, **params): + return Media.download(self.id, **params) diff --git a/telnyx/api_resources/messaging_hosted_number.py b/telnyx/api_resources/messaging_hosted_number.py index ae232f6..f959152 100644 --- a/telnyx/api_resources/messaging_hosted_number.py +++ b/telnyx/api_resources/messaging_hosted_number.py @@ -3,7 +3,5 @@ from telnyx.api_resources.abstract import DeletableAPIResource -class MessagingHostedNumber( - DeletableAPIResource, -): +class MessagingHostedNumber(DeletableAPIResource): OBJECT_NAME = "messaging_hosted_number" diff --git a/telnyx/api_resources/messaging_hosted_number_order.py b/telnyx/api_resources/messaging_hosted_number_order.py index c3773b1..7441d2b 100644 --- a/telnyx/api_resources/messaging_hosted_number_order.py +++ b/telnyx/api_resources/messaging_hosted_number_order.py @@ -8,8 +8,6 @@ class MessagingHostedNumberOrder( - CreateableAPIResource, - ListableAPIResource, - UpdateableAPIResource, + CreateableAPIResource, ListableAPIResource, UpdateableAPIResource ): OBJECT_NAME = "messaging_hosted_number_order" diff --git a/telnyx/api_resources/messaging_profile.py b/telnyx/api_resources/messaging_profile.py index 7f25710..3ecad8e 100644 --- a/telnyx/api_resources/messaging_profile.py +++ b/telnyx/api_resources/messaging_profile.py @@ -11,6 +11,7 @@ @nested_resource_class_methods("phone_number", operations=["list"]) @nested_resource_class_methods("short_code", operations=["list"]) +@nested_resource_class_methods("metrics", operations=["list"]) class MessagingProfile( CreateableAPIResource, DeletableAPIResource, @@ -24,3 +25,6 @@ def phone_numbers(self, **params): def short_codes(self, **params): return MessagingProfile.list_short_codes(self.id, **params) + + def metrics(self, **params): + return MessagingProfile.list_metrics(self.id, **params) diff --git a/telnyx/api_resources/notification_channel.py b/telnyx/api_resources/notification_channel.py new file mode 100644 index 0000000..490c835 --- /dev/null +++ b/telnyx/api_resources/notification_channel.py @@ -0,0 +1,17 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +) + + +class NotificationChannel( + ListableAPIResource, + CreateableAPIResource, + UpdateableAPIResource, + DeletableAPIResource, +): + OBJECT_NAME = "notification_channel" diff --git a/telnyx/api_resources/regulatory_requirement.py b/telnyx/api_resources/notification_event.py similarity index 58% rename from telnyx/api_resources/regulatory_requirement.py rename to telnyx/api_resources/notification_event.py index 288dfe5..a78ea00 100644 --- a/telnyx/api_resources/regulatory_requirement.py +++ b/telnyx/api_resources/notification_event.py @@ -3,5 +3,5 @@ from telnyx.api_resources.abstract import ListableAPIResource -class RegulatoryRequirement(ListableAPIResource): - OBJECT_NAME = "regulatory_requirement" +class NotificationEvent(ListableAPIResource): + OBJECT_NAME = "notification_event" diff --git a/telnyx/api_resources/notification_event_condition.py b/telnyx/api_resources/notification_event_condition.py new file mode 100644 index 0000000..d6c4df7 --- /dev/null +++ b/telnyx/api_resources/notification_event_condition.py @@ -0,0 +1,7 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ListableAPIResource + + +class NotificationEventCondition(ListableAPIResource): + OBJECT_NAME = "notification_event_condition" diff --git a/telnyx/api_resources/notification_profiles.py b/telnyx/api_resources/notification_profiles.py new file mode 100644 index 0000000..3255628 --- /dev/null +++ b/telnyx/api_resources/notification_profiles.py @@ -0,0 +1,17 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +) + + +class NotificationProfile( + ListableAPIResource, + CreateableAPIResource, + UpdateableAPIResource, + DeletableAPIResource, +): + OBJECT_NAME = "notification_profile" diff --git a/telnyx/api_resources/notification_setting.py b/telnyx/api_resources/notification_setting.py new file mode 100644 index 0000000..6cb1a0f --- /dev/null +++ b/telnyx/api_resources/notification_setting.py @@ -0,0 +1,13 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, +) + + +class NotificationSetting( + ListableAPIResource, CreateableAPIResource, DeletableAPIResource +): + OBJECT_NAME = "notification_setting" diff --git a/telnyx/api_resources/phone_assignment_profile.py b/telnyx/api_resources/phone_assignment_profile.py new file mode 100644 index 0000000..fb2bb6f --- /dev/null +++ b/telnyx/api_resources/phone_assignment_profile.py @@ -0,0 +1,28 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, + nested_resource_class_methods, +) + + +@nested_resource_class_methods( + "phone_numbers", path="phoneNumbers", operations=["list"] +) +class PhoneNumberByProfile( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +): + OBJECT_NAME = "phone_number_assignment_by_profile" + + @classmethod + def class_url(cls): + return "/10dlc/phoneNumberAssignmentByProfile" + + def phone_numbers(self, **params): + return PhoneNumberByProfile.list_mno_metadata(self.name, **params) diff --git a/telnyx/api_resources/phone_number_campaign.py b/telnyx/api_resources/phone_number_campaign.py new file mode 100644 index 0000000..61c997e --- /dev/null +++ b/telnyx/api_resources/phone_number_campaign.py @@ -0,0 +1,21 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +) + + +class PhoneNumberCampaign( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +): + OBJECT_NAME = "phone_number_campaign" + + @classmethod + def class_url(cls): + return "/10dlc/phoneNumberCampaign" diff --git a/telnyx/api_resources/phone_number_jobs.py b/telnyx/api_resources/phone_number_jobs.py new file mode 100644 index 0000000..3c5755f --- /dev/null +++ b/telnyx/api_resources/phone_number_jobs.py @@ -0,0 +1,49 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, + nested_resource_class_methods, +) + + +@nested_resource_class_methods( + "update_emergency_settings", + path="/v2/phone_numbers/jobs/update_emergency_settings", + operations=["create"], +) +@nested_resource_class_methods( + "update_phone_numbers", + path="/v2/phone_numbers/jobs/update_phone_numbers", + operations=["create"], +) +@nested_resource_class_methods( + "delete_phone_numbers", + path="/v2/phone_numbers/jobs/delete_phone_numbers", + operations=["create"], +) +class PhoneNumberJob( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +): + OBJECT_NAME = "phone_number_job" + + @classmethod + def class_url(cls): + return "/v2/phone_numbers/jobs" + + @classmethod + def update_emergency_settings(cls, **params): + return PhoneNumberJob.create_update_emergency_settings(None, **params) + + @classmethod + def update_phone_numbers(cls, **params): + return PhoneNumberJob.create_update_phone_numbers(None, **params) + + @classmethod + def delete_phone_numbers(cls, **params): + return PhoneNumberJob.create_delete_phone_numbers(None, **params) diff --git a/telnyx/api_resources/portability_check.py b/telnyx/api_resources/portability_check.py index 38da772..ade4c17 100644 --- a/telnyx/api_resources/portability_check.py +++ b/telnyx/api_resources/portability_check.py @@ -3,7 +3,5 @@ from telnyx.api_resources.abstract import CreateableAPIResource -class PortabilityCheck( - CreateableAPIResource, -): +class PortabilityCheck(CreateableAPIResource): OBJECT_NAME = "portability_check" diff --git a/telnyx/api_resources/porting_order.py b/telnyx/api_resources/porting_order.py index f1a2685..49c2f41 100644 --- a/telnyx/api_resources/porting_order.py +++ b/telnyx/api_resources/porting_order.py @@ -10,9 +10,19 @@ @nested_resource_class_methods("confirm", path="actions/confirm", operations=["create"]) +@nested_resource_class_methods("cancel", path="actions/cancel", operations=["create"]) @nested_resource_class_methods( "loa_template", path="loa_template", operations=["retrieve"] ) +@nested_resource_class_methods( + "allowed_foc_windows", path="allowed_foc_windows", operations=["list"] +) +@nested_resource_class_methods( + "activation_jobs", path="activation_jobs", operations=["list"] +) +@nested_resource_class_methods( + "exception_types", path="/v2/porting_orders/exception_types", operations=["list"] +) class PortingOrder( CreateableAPIResource, DeletableAPIResource, @@ -27,6 +37,19 @@ def confirm(self, **params): def loaTemplate(self, **params): return PortingOrder.retrieve_loa_template(self.id, **params) + def cancel(self, **params): + return PortingOrder.create_cancel(self.id, **params) + + def allowed_foc_windows(self, **params): + return PortingOrder.list_loa_template(self.id, **params) + + def activation_jobs(self, **params): + return PortingOrder.list_activation_jobs(self.id, **params) + + @classmethod + def exception_types(cls, **params): + return PortingOrder.create_exception_types(None, **params) + class PortingPhoneNumber(ListableAPIResource): OBJECT_NAME = "porting_phone_number" diff --git a/telnyx/api_resources/portout.py b/telnyx/api_resources/portout.py index 4db25b9..741c7c2 100644 --- a/telnyx/api_resources/portout.py +++ b/telnyx/api_resources/portout.py @@ -12,6 +12,12 @@ @nested_resource_class_methods( "comments", path="comments", operations=["create", "list"], pluralize_path=False ) +@nested_resource_class_methods( + "supporting_documents", + path="supporting_documents", + operations=["create", "list"], + pluralize_path=False, +) class PortOut( CreateableAPIResource, DeletableAPIResource, @@ -25,3 +31,9 @@ def list_comments(self, **params): def create_comments(self, **params): return PortOut.create_comments(self, **params) + + def list_supporting_documents(self, **params): + return PortOut.list_supporting_documents(self.id, **params) + + def create_supporting_documents(self, **params): + return PortOut.create_supporting_documents(self, **params) diff --git a/telnyx/api_resources/queue.py b/telnyx/api_resources/queue.py index b22204e..54db2a9 100644 --- a/telnyx/api_resources/queue.py +++ b/telnyx/api_resources/queue.py @@ -6,9 +6,7 @@ @nested_resource_class_methods( "queue_call", path="calls", operations=["list", "retrieve"] ) -class Queue( - APIResource, -): +class Queue(APIResource): OBJECT_NAME = "queue" def list_calls(self, **params): diff --git a/telnyx/api_resources/room.py b/telnyx/api_resources/room.py new file mode 100644 index 0000000..a18e57b --- /dev/null +++ b/telnyx/api_resources/room.py @@ -0,0 +1,36 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, + nested_resource_class_methods, +) + + +@nested_resource_class_methods( + "sessions", path="sessions", operations=["list", "retrieve"] +) +@nested_resource_class_methods( + "generate_token", path="actions/generate_join_client_token", operations=["create"] +) +@nested_resource_class_methods( + "refresh_token", path="actions/refresh_client_token", operations=["create"] +) +class Room( + CreateableAPIResource, + ListableAPIResource, + DeletableAPIResource, + UpdateableAPIResource, +): + OBJECT_NAME = "room" + + def list_sessions(self, **params): + return Room.list_sessions(self.name, **params) + + def generate_token(self, **params): + return Room.create_generate_token(self.id, **params) + + def refresh_token(self, **params): + return Room.create_refresh_token(self.id, **params) diff --git a/telnyx/api_resources/room_participant.py b/telnyx/api_resources/room_participant.py new file mode 100644 index 0000000..a84ca78 --- /dev/null +++ b/telnyx/api_resources/room_participant.py @@ -0,0 +1,7 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ListableAPIResource + + +class RoomParticipant(ListableAPIResource): + OBJECT_NAME = "room_participant" diff --git a/telnyx/api_resources/room_session.py b/telnyx/api_resources/room_session.py new file mode 100644 index 0000000..7688132 --- /dev/null +++ b/telnyx/api_resources/room_session.py @@ -0,0 +1,33 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + APIResource, + ListableAPIResource, + nested_resource_class_methods, +) + + +@nested_resource_class_methods("mute", path="actions/mute", operations=["create"]) +@nested_resource_class_methods("unmute", path="actions/unmute", operations=["create"]) +@nested_resource_class_methods("kick", path="actions/kick", operations=["create"]) +@nested_resource_class_methods( + "participants", path="participants", operations=["list", "retrieve"] +) +class RoomSession(ListableAPIResource): + OBJECT_NAME = "room_session" + + def mute(self, **params): + return RoomSession.create_mute(self.id, **params) + + def unmute(self, **params): + return RoomSession.create_unmute(self.id, **params) + + def kick(self, **params): + return RoomSession.create_kick(self.id, **params) + + def list_participants(self, **params): + return RoomSession.list_participants(self.name, **params) + + +class RoomSessionList(APIResource): + OBJECT_NAME = "room_session_list" diff --git a/telnyx/api_resources/sim_card.py b/telnyx/api_resources/sim_card.py index 26f6ce9..6319cc9 100644 --- a/telnyx/api_resources/sim_card.py +++ b/telnyx/api_resources/sim_card.py @@ -1,6 +1,8 @@ from __future__ import absolute_import, division, print_function from telnyx.api_resources.abstract import ( + CreateableAPIResource, + DeletableAPIResource, ListableAPIResource, UpdateableAPIResource, nested_resource_class_methods, @@ -12,7 +14,24 @@ @nested_resource_class_methods( "register", path="/v2/actions/register/sim_cards", operations=["create"] ) -class SIMCard(ListableAPIResource, UpdateableAPIResource): +@nested_resource_class_methods( + "set_standby", path="actions/set_standby", operations=["create"] +) +@nested_resource_class_methods( + "remove_public_ip", path="actions/remove_public_ip", operations=["create"] +) +@nested_resource_class_methods( + "set_public_ip", path="actions/set_public_ip", operations=["create"] +) +@nested_resource_class_methods( + "wireless_logs", path="wireless_connectivity_logs", operations=["list"] +) +class SIMCard( + ListableAPIResource, + UpdateableAPIResource, + CreateableAPIResource, + DeletableAPIResource, +): OBJECT_NAME = "sim_card" def enable(self, **params): @@ -21,6 +40,20 @@ def enable(self, **params): def disable(self, **params): return SIMCard.create_disable(self.id, **params) + def set_standby(self, **params): + return SIMCard.create_set_standby(self.id, **params) + + def remove_public_ip(self, **params): + return SIMCard.create_remove_public_ip(self.id, **params) + + def set_public_ip(self, **params): + return SIMCard.create_set_public_ip(self.id, **params) + + """ deprecated? + def wireless_logs(self, **params): + return SIMCard.list_wireless_logs(self.id, **params) + """ + @classmethod def register(cls, **params): return SIMCard.create_register(None, **params) diff --git a/telnyx/api_resources/sim_card_action.py b/telnyx/api_resources/sim_card_action.py new file mode 100644 index 0000000..a23287b --- /dev/null +++ b/telnyx/api_resources/sim_card_action.py @@ -0,0 +1,7 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ListableAPIResource + + +class SIMCardAction(ListableAPIResource): + OBJECT_NAME = "sim_card_action" diff --git a/telnyx/api_resources/sim_card_group.py b/telnyx/api_resources/sim_card_group.py new file mode 100644 index 0000000..a0e0ea7 --- /dev/null +++ b/telnyx/api_resources/sim_card_group.py @@ -0,0 +1,17 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +) + + +class SIMCardGroup( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +): + OBJECT_NAME = "sim_card_group" diff --git a/telnyx/api_resources/sim_card_order.py b/telnyx/api_resources/sim_card_order.py new file mode 100644 index 0000000..5e9cad1 --- /dev/null +++ b/telnyx/api_resources/sim_card_order.py @@ -0,0 +1,15 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import CreateableAPIResource, ListableAPIResource + + +class SIMCardOrder(CreateableAPIResource, ListableAPIResource): + OBJECT_NAME = "sim_card_order" + + +class SIMCardOrderPreview(CreateableAPIResource): + OBJECT_NAME = "sim_card_order_preview" + + @classmethod + def class_url(cls): + return "/v2/sim_card_order_preview" diff --git a/telnyx/api_resources/sub_number_order.py b/telnyx/api_resources/sub_number_order.py new file mode 100644 index 0000000..00bb4f2 --- /dev/null +++ b/telnyx/api_resources/sub_number_order.py @@ -0,0 +1,17 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +) + + +class SubNumberOrder( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +): + OBJECT_NAME = "sub_number_order" diff --git a/telnyx/api_resources/telephony_credential.py b/telnyx/api_resources/telephony_credential.py index d4ac8aa..6e9bb18 100644 --- a/telnyx/api_resources/telephony_credential.py +++ b/telnyx/api_resources/telephony_credential.py @@ -5,9 +5,11 @@ DeletableAPIResource, ListableAPIResource, UpdateableAPIResource, + nested_resource_class_methods, ) +@nested_resource_class_methods("token", path="token", operations=["create"]) class TelephonyCredential( CreateableAPIResource, DeletableAPIResource, @@ -16,3 +18,6 @@ class TelephonyCredential( ): OBJECT_NAME = "telephony_credential" API_RECORD_TYPE_NAME = "credential" + + def token(self, **params): + return TelephonyCredential.create_token(self.id, **params) diff --git a/telnyx/api_resources/verification.py b/telnyx/api_resources/verification.py index 15fd287..6f2ec7b 100644 --- a/telnyx/api_resources/verification.py +++ b/telnyx/api_resources/verification.py @@ -23,13 +23,13 @@ class Verification(CreateableAPIResource, ListableAPIResource): OBJECT_NAME = "verification" - def verify_by_phone_number(self, code, phone_number): + def verify_by_phone_number(self, code, phone_number, verify_profile_id): return self.request( method="post", url="/v2/verifications/by_phone_number/{}/actions/verify".format( phone_number ), - params={"code": code}, + params={"code": code, "verify_profile_id": verify_profile_id}, ) @classmethod diff --git a/telnyx/api_resources/webhook_deliveries.py b/telnyx/api_resources/webhook_deliveries.py new file mode 100644 index 0000000..565572c --- /dev/null +++ b/telnyx/api_resources/webhook_deliveries.py @@ -0,0 +1,11 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ListableAPIResource + + +class WebhookDeliveries(ListableAPIResource): + OBJECT_NAME = "webhook_deliveries" + + @classmethod + def class_url(cls): + return "/v2/webhook_deliveries" diff --git a/telnyx/api_resources/whatsapp_business_account.py b/telnyx/api_resources/whatsapp_business_account.py new file mode 100644 index 0000000..e47d380 --- /dev/null +++ b/telnyx/api_resources/whatsapp_business_account.py @@ -0,0 +1,7 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ListableAPIResource + + +class WhatsappBusinessAccount(ListableAPIResource): + OBJECT_NAME = "whatsapp_business_account" diff --git a/telnyx/api_resources/whatsapp_contact.py b/telnyx/api_resources/whatsapp_contact.py new file mode 100644 index 0000000..d9c7c8a --- /dev/null +++ b/telnyx/api_resources/whatsapp_contact.py @@ -0,0 +1,7 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import CreateableAPIResource + + +class WhatsappContact(CreateableAPIResource): + OBJECT_NAME = "whatsapp_contact" diff --git a/telnyx/api_resources/whatsapp_media.py b/telnyx/api_resources/whatsapp_media.py new file mode 100644 index 0000000..152eb90 --- /dev/null +++ b/telnyx/api_resources/whatsapp_media.py @@ -0,0 +1,15 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, +) + + +class WhatsappMedia(ListableAPIResource, CreateableAPIResource, DeletableAPIResource): + OBJECT_NAME = "whatsapp_media" + + @classmethod + def class_url(cls): + return "/v2/whatsapp_media" diff --git a/telnyx/api_resources/whatsapp_message.py b/telnyx/api_resources/whatsapp_message.py new file mode 100644 index 0000000..3148151 --- /dev/null +++ b/telnyx/api_resources/whatsapp_message.py @@ -0,0 +1,13 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +) + + +class WhatsappMessage( + CreateableAPIResource, ListableAPIResource, UpdateableAPIResource +): + OBJECT_NAME = "whatsapp_message" diff --git a/telnyx/api_resources/whatsapp_phone_number.py b/telnyx/api_resources/whatsapp_phone_number.py new file mode 100644 index 0000000..855c6e8 --- /dev/null +++ b/telnyx/api_resources/whatsapp_phone_number.py @@ -0,0 +1,7 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ListableAPIResource, UpdateableAPIResource + + +class WhatsappPhoneNumber(ListableAPIResource, UpdateableAPIResource): + OBJECT_NAME = "whatsapp_phone_number" diff --git a/telnyx/api_resources/wireless_detail_record_report.py b/telnyx/api_resources/wireless_detail_record_report.py new file mode 100644 index 0000000..f751f04 --- /dev/null +++ b/telnyx/api_resources/wireless_detail_record_report.py @@ -0,0 +1,17 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, +) + + +class WirelessDetailRecordsReports( + CreateableAPIResource, ListableAPIResource, DeletableAPIResource +): + OBJECT_NAME = "wireless_detail_records_report" + + @classmethod + def class_url(cls): + return "/v2/wireless/detail_records_reports" diff --git a/telnyx/error.py b/telnyx/error.py index fcf4147..f2e42d9 100644 --- a/telnyx/error.py +++ b/telnyx/error.py @@ -35,7 +35,7 @@ def __init__( self.http_body = http_body def build_message(self): - return u"{message}{other_errors_message}{full_details}".format( + return "{message}{other_errors_message}{full_details}".format( message=self.extract_message(), other_errors_message=self.other_errors_message(), full_details=self.full_details(), @@ -76,7 +76,7 @@ def errors_count(self): def __str__(self): msg = self._message or "" if self.request_id is not None: - return u"Request {0}: {1}".format(self.request_id, msg) + return "Request {0}: {1}".format(self.request_id, msg) else: return msg diff --git a/telnyx/multipart_data_generator.py b/telnyx/multipart_data_generator.py index 948f00b..e2346fe 100644 --- a/telnyx/multipart_data_generator.py +++ b/telnyx/multipart_data_generator.py @@ -77,4 +77,4 @@ def _write_file(self, f): self._write(file_contents) def _initialize_boundary(self): - return random.randint(0, 2 ** 63) + return random.randint(0, 2**63) diff --git a/telnyx/util.py b/telnyx/util.py index 258cbaa..77bd95e 100644 --- a/telnyx/util.py +++ b/telnyx/util.py @@ -90,9 +90,9 @@ def fmt(key, val): # key should already be a string if re.search(r"\s", key): key = repr(key) - return u"{key}={val}".format(key=key, val=val) + return "{key}={val}".format(key=key, val=val) - return u" ".join([fmt(key, val) for key, val in sorted(props.items())]) + return " ".join([fmt(key, val) for key, val in sorted(props.items())]) OBJECT_CLASSES = {} @@ -106,36 +106,58 @@ def load_object_classes(): OBJECT_CLASSES = { # business objects + api_resources.AccessControlIP.OBJECT_NAME: api_resources.AccessControlIP, + api_resources.AccessIPAddress.OBJECT_NAME: api_resources.AccessIPAddress, + api_resources.AuthenticationProvider.OBJECT_NAME: api_resources.AuthenticationProvider, api_resources.Address.OBJECT_NAME: api_resources.Address, api_resources.APIKey.OBJECT_NAME: api_resources.APIKey, api_resources.AvailablePhoneNumber.OBJECT_NAME: api_resources.AvailablePhoneNumber, api_resources.Balance.OBJECT_NAME: api_resources.Balance, api_resources.BillingGroup.OBJECT_NAME: api_resources.BillingGroup, + api_resources.Brand.OBJECT_NAME: api_resources.Brand, + api_resources.BulkCreation.OBJECT_NAME: api_resources.BulkCreation, api_resources.Call.OBJECT_NAME: api_resources.Call, api_resources.CallControlApplication.OBJECT_NAME: api_resources.CallControlApplication, + api_resources.Campaign.OBJECT_NAME: api_resources.Campaign, + api_resources.Comment.OBJECT_NAME: api_resources.Comment, api_resources.Conference.OBJECT_NAME: api_resources.Conference, api_resources.Connection.OBJECT_NAME: api_resources.Connection, api_resources.CredentialConnection.OBJECT_NAME: api_resources.CredentialConnection, + api_resources.CustomStorageCredential.OBJECT_NAME: api_resources.CustomStorageCredential, api_resources.DetailRecordsReport.OBJECT_NAME: api_resources.DetailRecordsReport, + api_resources.Document.OBJECT_NAME: api_resources.Document, + api_resources.DocumentLink.OBJECT_NAME: api_resources.DocumentLink, + api_resources.DynamicEmergencyAddress.OBJECT_NAME: api_resources.DynamicEmergencyAddress, api_resources.Fax.OBJECT_NAME: api_resources.Fax, api_resources.FaxApplication.OBJECT_NAME: api_resources.FaxApplication, api_resources.FQDN.OBJECT_NAME: api_resources.FQDN, api_resources.FQDNConnection.OBJECT_NAME: api_resources.FQDNConnection, api_resources.InboundChannel.OBJECT_NAME: api_resources.InboundChannel, + api_resources.InventoryCoverage.OBJECT_NAME: api_resources.InventoryCoverage, api_resources.IP.OBJECT_NAME: api_resources.IP, api_resources.IPConnection.OBJECT_NAME: api_resources.IPConnection, + api_resources.ManagedAccount.OBJECT_NAME: api_resources.ManagedAccount, + api_resources.Media.OBJECT_NAME: api_resources.Media, api_resources.Message.OBJECT_NAME: api_resources.Message, api_resources.MessagingHostedNumber.OBJECT_NAME: api_resources.MessagingHostedNumber, api_resources.MessagingHostedNumberOrder.OBJECT_NAME: api_resources.MessagingHostedNumberOrder, api_resources.MessagingPhoneNumber.OBJECT_NAME: api_resources.MessagingPhoneNumber, api_resources.MessagingProfile.OBJECT_NAME: api_resources.MessagingProfile, api_resources.MessagingSettings.OBJECT_NAME: api_resources.MessagingSettings, + api_resources.NotificationChannel.OBJECT_NAME: api_resources.NotificationChannel, + api_resources.NotificationEvent.OBJECT_NAME: api_resources.NotificationEvent, + api_resources.NotificationEventCondition.OBJECT_NAME: api_resources.NotificationEventCondition, + api_resources.NotificationProfile.OBJECT_NAME: api_resources.NotificationProfile, + api_resources.NotificationSetting.OBJECT_NAME: api_resources.NotificationSetting, api_resources.NumberLookup.OBJECT_NAME: api_resources.NumberLookup, api_resources.NumberOrder.OBJECT_NAME: api_resources.NumberOrder, api_resources.NumberOrderPhoneNumber.OBJECT_NAME: api_resources.NumberOrderPhoneNumber, api_resources.NumberReservation.OBJECT_NAME: api_resources.NumberReservation, api_resources.OutboundVoiceProfile.OBJECT_NAME: api_resources.OutboundVoiceProfile, api_resources.PhoneNumber.OBJECT_NAME: api_resources.PhoneNumber, + api_resources.PhoneNumberByProfile.OBJECT_NAME: api_resources.PhoneNumberByProfile, + api_resources.PhoneNumberCampaign.OBJECT_NAME: api_resources.PhoneNumberCampaign, + api_resources.PhoneNumberJob.OBJECT_NAME: api_resources.PhoneNumberJob, api_resources.PhoneNumberRegulatoryRequirement.OBJECT_NAME: api_resources.PhoneNumberRegulatoryRequirement, api_resources.PortabilityCheck.OBJECT_NAME: api_resources.PortabilityCheck, api_resources.PortingOrder.OBJECT_NAME: api_resources.PortingOrder, @@ -144,14 +166,28 @@ def load_object_classes(): api_resources.PublicKey.OBJECT_NAME: api_resources.PublicKey, api_resources.Queue.OBJECT_NAME: api_resources.Queue, api_resources.QueueCall.OBJECT_NAME: api_resources.QueueCall, - api_resources.RegulatoryRequirement.OBJECT_NAME: api_resources.RegulatoryRequirement, + api_resources.RoomParticipant.OBJECT_NAME: api_resources.RoomParticipant, + api_resources.RoomSession.OBJECT_NAME: api_resources.RoomSession, + api_resources.RoomSessionList.OBJECT_NAME: api_resources.RoomSessionList, api_resources.SIMCard.OBJECT_NAME: api_resources.SIMCard, + api_resources.SIMCardAction.OBJECT_NAME: api_resources.SIMCardAction, + api_resources.SIMCardGroup.OBJECT_NAME: api_resources.SIMCardGroup, + api_resources.SIMCardOrder.OBJECT_NAME: api_resources.SIMCardOrder, + api_resources.SIMCardOrderPreview.OBJECT_NAME: api_resources.SIMCardOrderPreview, api_resources.ShortCode.OBJECT_NAME: api_resources.ShortCode, + api_resources.SubNumberOrder.OBJECT_NAME: api_resources.SubNumberOrder, api_resources.TelephonyCredential.OBJECT_NAME: api_resources.TelephonyCredential, api_resources.TelephonyCredential.API_RECORD_TYPE_NAME: api_resources.TelephonyCredential, api_resources.VoiceSettings.OBJECT_NAME: api_resources.VoiceSettings, api_resources.Verification.OBJECT_NAME: api_resources.Verification, api_resources.VerifyProfile.OBJECT_NAME: api_resources.VerifyProfile, + api_resources.WebhookDeliveries.OBJECT_NAME: api_resources.WebhookDeliveries, + api_resources.WhatsappBusinessAccount.OBJECT_NAME: api_resources.WhatsappBusinessAccount, + api_resources.WhatsappContact.OBJECT_NAME: api_resources.WhatsappContact, + api_resources.WhatsappMedia.OBJECT_NAME: api_resources.WhatsappMedia, + api_resources.WhatsappMessage.OBJECT_NAME: api_resources.WhatsappMessage, + api_resources.WhatsappPhoneNumber.OBJECT_NAME: api_resources.WhatsappPhoneNumber, + api_resources.WirelessDetailRecordsReports.OBJECT_NAME: api_resources.WirelessDetailRecordsReports, } diff --git a/tests/api_resources/test_access_control_ip.py b/tests/api_resources/test_access_control_ip.py new file mode 100644 index 0000000..86a8081 --- /dev/null +++ b/tests/api_resources/test_access_control_ip.py @@ -0,0 +1,32 @@ +from __future__ import absolute_import, division, print_function + +import telnyx + +TEST_RESOURCE_ID = "0ccc7b54-4df3-4bca-a65a-3da1ecc777f0" + + +class TestAddress(object): + def test_is_listable(self, request_mock): + resources = telnyx.AccessControlIP.list() + request_mock.assert_requested("get", "/v2/access_control_ips") + assert isinstance(resources.data, list) + assert isinstance(resources.data[0], telnyx.AccessControlIP) + + def test_is_retrievable(self, request_mock): + resource = telnyx.AccessControlIP.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested( + "get", "/v2/access_control_ips/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.AccessControlIP) + + def test_is_creatable(self, request_mock): + resource = telnyx.AccessControlIP.create(ip_address="100.101.102.103") + request_mock.assert_requested("post", "/v2/access_control_ips") + assert isinstance(resource, telnyx.AccessControlIP) + + def test_is_deletable(self, request_mock): + resource = telnyx.AccessControlIP.retrieve(TEST_RESOURCE_ID) + resource.delete() + request_mock.assert_requested( + "delete", "/v2/access_control_ips/%s" % TEST_RESOURCE_ID + ) diff --git a/tests/api_resources/test_address.py b/tests/api_resources/test_address.py index 6cba08c..0ccd8eb 100644 --- a/tests/api_resources/test_address.py +++ b/tests/api_resources/test_address.py @@ -31,6 +31,6 @@ def test_is_creatable(self, request_mock): assert isinstance(resource, telnyx.Address) def test_is_deletable(self, request_mock): - resource = telnyx.Address.retrieve(TEST_RESOURCE_ID) + resource = telnyx.Address(TEST_RESOURCE_ID) resource.delete() request_mock.assert_requested("delete", "/v2/addresses/%s" % TEST_RESOURCE_ID) diff --git a/tests/api_resources/test_authentication_provider.py b/tests/api_resources/test_authentication_provider.py new file mode 100644 index 0000000..e19bccd --- /dev/null +++ b/tests/api_resources/test_authentication_provider.py @@ -0,0 +1,56 @@ +from __future__ import absolute_import, division, print_function + +import pytest + +import telnyx + +TEST_RESOURCE_ID = "35146afd-df93-4963-b1e9-1a085e2ae874" + + +class TestAuthenticationProvider(object): + def test_is_listable(self, request_mock): + resources = telnyx.AuthenticationProvider.list() + request_mock.assert_requested("get", "/v2/authentication_providers") + assert isinstance(resources.data, list) + assert isinstance(resources.data[0], telnyx.AuthenticationProvider) + + def test_is_retrievable(self, request_mock): + resource = telnyx.AuthenticationProvider.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested( + "get", "/v2/authentication_providers/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.AuthenticationProvider) + + @pytest.mark.skip(reason="Formatting for setting param is off") + def test_is_creatable(self, request_mock): + resource = telnyx.AuthenticationProvider.create( + name="Okta", setting=[], short_name="myorg" + ) + request_mock.assert_requested("post", "/v2/authentication_providers") + assert isinstance(resource, telnyx.AuthenticationProvider) + + def test_is_saveable(self, request_mock): + authentication_provider = telnyx.AuthenticationProvider.retrieve( + TEST_RESOURCE_ID + ) + authentication_provider.name = "value" + resource = authentication_provider.save() + request_mock.assert_requested( + "patch", "/v2/authentication_providers/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.AuthenticationProvider) + assert resource is authentication_provider + + def test_is_modifiable(self, request_mock): + resource = telnyx.AuthenticationProvider.modify(TEST_RESOURCE_ID, active=False) + request_mock.assert_requested( + "patch", "/v2/authentication_providers/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.AuthenticationProvider) + + def test_is_deletable(self, request_mock): + resource = telnyx.AuthenticationProvider.retrieve(TEST_RESOURCE_ID) + resource.delete() + request_mock.assert_requested( + "delete", "/v2/authentication_providers/%s" % TEST_RESOURCE_ID + ) diff --git a/tests/api_resources/test_billing_group.py b/tests/api_resources/test_billing_group.py index fed078f..7f1074e 100644 --- a/tests/api_resources/test_billing_group.py +++ b/tests/api_resources/test_billing_group.py @@ -2,7 +2,7 @@ import telnyx -TEST_RESOURCE_ID = "123" +TEST_RESOURCE_ID = "f5586561-8ff0-4291-a0ac-84fe544797bd" class TestBillingGroup(object): diff --git a/tests/api_resources/test_call_control_application.py b/tests/api_resources/test_call_control_application.py index f553c78..2a1f648 100644 --- a/tests/api_resources/test_call_control_application.py +++ b/tests/api_resources/test_call_control_application.py @@ -2,7 +2,7 @@ import telnyx -TEST_RESOURCE_ID = "123" +TEST_RESOURCE_ID = "1293384261075731499" class TestCallControlApplication(object): diff --git a/tests/api_resources/test_campaign.py b/tests/api_resources/test_campaign.py new file mode 100644 index 0000000..4d7296e --- /dev/null +++ b/tests/api_resources/test_campaign.py @@ -0,0 +1,35 @@ +from __future__ import absolute_import, division, print_function + +import pytest + +import telnyx + +TEST_RESOURCE_ID = "1293384261075731499" + + +@pytest.mark.skip(reason="Not implemented yet") +class TestCampaign(object): + def test_is_listable(self, request_mock): + resources = telnyx.Campaign.list() + request_mock.assert_requested("get", "/10dlc/campaign") + assert isinstance(resources.data, list) + assert isinstance(resources.data[0], telnyx.Campaign) + + def test_is_retrievable(self, request_mock): + resource = telnyx.Campaign.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested("get", "/v2/campaign/%s" % TEST_RESOURCE_ID) + assert isinstance(resource, telnyx.Campaign) + + def test_is_creatable(self, request_mock): + resource = telnyx.FaxApplication.create( + active=True, + application_name="Test Name", + webhook_event_url="https://test.com", + ) + request_mock.assert_requested("post", "/v2/fax_applications") + assert isinstance(resource, telnyx.FaxApplication) + + def test_is_deletable(self, request_mock): + resource = telnyx.Campaign.retrieve(TEST_RESOURCE_ID) + resource.delete() + request_mock.assert_requested("delete", "/10dlc/campaign/%s" % TEST_RESOURCE_ID) diff --git a/tests/api_resources/test_comment.py b/tests/api_resources/test_comment.py new file mode 100644 index 0000000..5ea7926 --- /dev/null +++ b/tests/api_resources/test_comment.py @@ -0,0 +1,26 @@ +from __future__ import absolute_import, division, print_function + +import pytest + +import telnyx + +TEST_RESOURCE_ID = "6a09cdc3-8948-47f0-aa62-74ac943d6c58" + + +@pytest.mark.skip(reason="Filter off") +class TestComment(object): + def test_is_listable(self, request_mock): + resources = telnyx.Comment.list( + filter={ + "comment_record_type": "sub_number_order", + "comment_record_id": "8ffb3622-7c6b-4ccc-b65f-7a3dc0099576", + } + ) + request_mock.assert_requested("get", "/v2/comments") + assert isinstance(resources.data, list) + assert isinstance(resources.data[0], telnyx.Comment) + + def test_is_creatable(self, request_mock): + resource = telnyx.Comment.create() + request_mock.assert_requested("post", "/v2/comments") + assert isinstance(resource, telnyx.Comment) diff --git a/tests/api_resources/test_conference.py b/tests/api_resources/test_conference.py index b555e5b..a653804 100644 --- a/tests/api_resources/test_conference.py +++ b/tests/api_resources/test_conference.py @@ -1,7 +1,5 @@ from __future__ import absolute_import, division, print_function -import pytest - import telnyx CONFERENCE_ID = "3fa85f64-5717-4562-b3fc-2c963f66afa6" @@ -224,7 +222,6 @@ def test_can_call_create_record_stop(self, request_mock): ) assert isinstance(resource, telnyx.Conference) - @pytest.mark.skip(reason="Fix mock for multi args") def test_can_call_update(self, request_mock): resource = create_conference() resource.create_update( @@ -234,6 +231,19 @@ def test_can_call_update(self, request_mock): command_id="891510ac-f3e4-11e8-af5b-de00688a4901", ) request_mock.assert_requested( - "post", "/v2/conference/%s/actions/update" % CONFERENCE_ID + "post", "/v2/conferences/%s/actions/update" % CONFERENCE_ID + ) + assert isinstance(resource, telnyx.Conference) + + def test_can_call_leave(self, request_mock): + resource = create_conference() + resource.create_leave( + CONFERENCE_ID, + call_control_id=_call_control_id, + supervisor_role="whisper", + command_id="891510ac-f3e4-11e8-af5b-de00688a4901", + ) + request_mock.assert_requested( + "post", "/v2/conferences/%s/actions/leave" % CONFERENCE_ID ) assert isinstance(resource, telnyx.Conference) diff --git a/tests/api_resources/test_custom_storage_credential.py b/tests/api_resources/test_custom_storage_credential.py new file mode 100644 index 0000000..e08aea3 --- /dev/null +++ b/tests/api_resources/test_custom_storage_credential.py @@ -0,0 +1,43 @@ +from __future__ import absolute_import, division, print_function + +import pytest + +import telnyx + +TEST_RESOURCE_ID = "1293384261075731499" + + +@pytest.mark.skip(reason="Not implemented yet") +class TestCustomStorageCredential(object): + def test_is_retrievable(self, request_mock): + resource = telnyx.CustomStorageCredential.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested( + "get", "/v2/custom_storage_credentials/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.CustomStorageCredential) + + def test_is_creatable(self, request_mock): + resource = telnyx.CustomStorageCredential.create( + backend="gcs", configuration=[] + ) + request_mock.assert_requested("post", "/v2/custom_storage_credentials") + assert isinstance(resource, telnyx.CustomStorageCredential) + + def test_is_modifiable(self, request_mock): + resource = telnyx.CustomStorageCredential.modify( + TEST_RESOURCE_ID, + active=False, + webhook_event_url="https://update.com", + application_name="updated name", + ) + request_mock.assert_requested( + "patch", "/v2/custom_application/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.FaxApplication) + + def test_is_deletable(self, request_mock): + resource = telnyx.CustomStorageCredential.retrieve(TEST_RESOURCE_ID) + resource.delete() + request_mock.assert_requested( + "delete", "/v2/custom_storage_credentials/%s" % TEST_RESOURCE_ID + ) diff --git a/tests/api_resources/test_document.py b/tests/api_resources/test_document.py new file mode 100644 index 0000000..034bf96 --- /dev/null +++ b/tests/api_resources/test_document.py @@ -0,0 +1,55 @@ +from __future__ import absolute_import, division, print_function + +import pytest + +import telnyx + +TEST_RESOURCE_ID = "6a09cdc3-8948-47f0-aa62-74ac943d6c58" + + +class TestDocument(object): + def test_is_listable(self, request_mock): + resources = telnyx.Document.list() + request_mock.assert_requested("get", "/v2/documents") + assert isinstance(resources.data, list) + assert isinstance(resources.data[0], telnyx.Document) + + def test_is_retrievable(self, request_mock): + resource = telnyx.Document.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested("get", "/v2/documents/%s" % TEST_RESOURCE_ID) + assert isinstance(resource, telnyx.Document) + + def test_is_creatable(self, request_mock): + resource = telnyx.Document.create( + filename="test-document.pdf", + url="https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf", + file="https://test.com", + ) + request_mock.assert_requested("post", "/v2/documents") + assert isinstance(resource, telnyx.Document) + + def test_is_modifiable(self, request_mock): + resource = telnyx.Document.modify( + TEST_RESOURCE_ID, + active=False, + webhook_event_url="https://update.com", + application_name="updated name", + ) + request_mock.assert_requested("patch", "/v2/documents/%s" % TEST_RESOURCE_ID) + assert isinstance(resource, telnyx.Document) + + def test_is_deletable(self, request_mock): + resource = telnyx.Document.retrieve(TEST_RESOURCE_ID) + resource.delete() + request_mock.assert_requested("delete", "/v2/documents/%s" % TEST_RESOURCE_ID) + + def test_document_links(self, request_mock): + resources = telnyx.DocumentLink.list() + request_mock.assert_requested("get", "/v2/document_links") + assert isinstance(resources.data, list) + assert isinstance(resources.data[0], telnyx.DocumentLink) + + @pytest.mark.skip(reason="Nested get") + def test_download(self, request_mock): + resource = telnyx.Document.retrieve(TEST_RESOURCE_ID) + resource.download() diff --git a/tests/api_resources/test_dynamic_emergency_address.py b/tests/api_resources/test_dynamic_emergency_address.py new file mode 100644 index 0000000..e9ac75f --- /dev/null +++ b/tests/api_resources/test_dynamic_emergency_address.py @@ -0,0 +1,34 @@ +from __future__ import absolute_import, division, print_function + +import telnyx + +TEST_RESOURCE_ID = "0ccc7b54-4df3-4bca-a65a-3da1ecc777f1" + + +class TestDynamicEmergencyAddress(object): + def test_is_listable(self, request_mock): + resources = telnyx.DynamicEmergencyAddress.list() + request_mock.assert_requested("get", "/v2/dynamic_emergency_addresses") + assert isinstance(resources.data, list) + assert isinstance(resources.data[0], telnyx.DynamicEmergencyAddress) + + def test_is_retrievable(self, request_mock): + resource = telnyx.DynamicEmergencyAddress.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested( + "get", "/v2/dynamic_emergency_addresses/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.DynamicEmergencyAddress) + + def test_is_creatable(self, request_mock): + telnyx.DynamicEmergencyAddress.create( + administrative_area="IL", + house_number="311", + locality="Chicago", + postal_code="60654", + street_name="Superior", + country_coude="US", + ) + + def test_is_deletable(self, request_mock): + resource = telnyx.DynamicEmergencyAddress.retrieve(TEST_RESOURCE_ID) + resource.delete() diff --git a/tests/api_resources/test_fax.py b/tests/api_resources/test_fax.py index e9425b2..4873418 100644 --- a/tests/api_resources/test_fax.py +++ b/tests/api_resources/test_fax.py @@ -1,11 +1,14 @@ from __future__ import absolute_import, division, print_function +import pytest + import telnyx TEST_FAX_CONNECTION_ID = "0239852093" TEST_SRC_LONG_CODE = "+13125550100" TEST_DST = "+17735550100" TEST_MEDIA_URL = "http://www.africau.edu/images/default/sample.pdf" +TEST_RESOURCE_ID = "3fa85f64-5717-4562-b3fc-2c963f66afa6" class TestFax(object): @@ -20,3 +23,11 @@ def test_can_create_standard_fax(self, request_mock): print(resource) print(type(resource)) assert isinstance(resource, telnyx.Fax) + + @pytest.mark.skip(reason="Fax needs correct input") + def test_can_fax_refresh(self, request_mock): + resource = telnyx.Fax.retrieve(TEST_RESOURCE_ID) + resource.create_refresh(id=TEST_RESOURCE_ID) + request_mock.assert_requested( + "post", "/v2/faxes/%s/actions/refresh" % TEST_RESOURCE_ID + ) diff --git a/tests/api_resources/test_fax_applications.py b/tests/api_resources/test_fax_applications.py index b13aa12..fde093a 100644 --- a/tests/api_resources/test_fax_applications.py +++ b/tests/api_resources/test_fax_applications.py @@ -2,7 +2,7 @@ import telnyx -TEST_RESOURCE_ID = "6a09cdc3-8948-47f0-aa62-74ac943d6c58" +TEST_RESOURCE_ID = "1293384261075731499" class TestFaxApplication(object): diff --git a/tests/api_resources/test_fqdn.py b/tests/api_resources/test_fqdn.py index 018b8ba..0cab541 100644 --- a/tests/api_resources/test_fqdn.py +++ b/tests/api_resources/test_fqdn.py @@ -2,7 +2,7 @@ import telnyx -TEST_RESOURCE_ID = "6a09cdc3-8948-47f0-aa62-74ac943d6c58" +TEST_RESOURCE_ID = "1293384261075731499" class TestFQDN(object): diff --git a/tests/api_resources/test_fqdn_connection.py b/tests/api_resources/test_fqdn_connection.py deleted file mode 100644 index e3947c9..0000000 --- a/tests/api_resources/test_fqdn_connection.py +++ /dev/null @@ -1,51 +0,0 @@ -from __future__ import absolute_import, division, print_function - -import telnyx - -TEST_RESOURCE_ID = "6a09cdc3-8948-47f0-aa62-74ac943d6c58" - - -class TestFQDNConnection(object): - def test_is_listable(self, request_mock): - resources = telnyx.FQDNConnection.list() - request_mock.assert_requested("get", "/v2/fqdn_connections") - assert isinstance(resources.data, list) - assert isinstance(resources.data[0], telnyx.FQDNConnection) - - def test_is_retrievable(self, request_mock): - resource = telnyx.FQDNConnection.retrieve(TEST_RESOURCE_ID) - request_mock.assert_requested( - "get", "/v2/fqdn_connections/%s" % TEST_RESOURCE_ID - ) - assert isinstance(resource, telnyx.FQDNConnection) - - def test_is_creatable(self, request_mock): - resource = telnyx.FQDNConnection.create( - active=True, connection_name="Test Name" - ) - request_mock.assert_requested("post", "/v2/fqdn_connections") - assert isinstance(resource, telnyx.FQDNConnection) - - def test_is_saveable(self, request_mock): - fqdn_connection = telnyx.FQDNConnection.retrieve(TEST_RESOURCE_ID) - fqdn_connection.active = False - resource = fqdn_connection.save() - request_mock.assert_requested( - "patch", "/v2/fqdn_connections/%s" % TEST_RESOURCE_ID - ) - assert isinstance(resource, telnyx.FQDNConnection) - assert resource is fqdn_connection - - def test_is_modifiable(self, request_mock): - resource = telnyx.FQDNConnection.modify(TEST_RESOURCE_ID, active=False) - request_mock.assert_requested( - "patch", "/v2/fqdn_connections/%s" % TEST_RESOURCE_ID - ) - assert isinstance(resource, telnyx.FQDNConnection) - - def test_is_deletable(self, request_mock): - resource = telnyx.FQDNConnection.retrieve(TEST_RESOURCE_ID) - resource.delete() - request_mock.assert_requested( - "delete", "/v2/fqdn_connections/%s" % TEST_RESOURCE_ID - ) diff --git a/tests/api_resources/test_inventory_coverage.py b/tests/api_resources/test_inventory_coverage.py new file mode 100644 index 0000000..65b6e4c --- /dev/null +++ b/tests/api_resources/test_inventory_coverage.py @@ -0,0 +1,16 @@ +from __future__ import absolute_import, division, print_function + +import pytest + +import telnyx + +TEST_RESOURCE_ID = "45f45a04-b4be-4592-95b1-9306b9db2b21" + + +@pytest.mark.skip(reason="Filter looking for 'filter%5bphone_number%5d', typo") +class TestInventoryCoverage(object): + def test_is_listable(self, request_mock): + resources = telnyx.InventoryCoverage.list(filter={"groupBy": "npa"}) + request_mock.assert_requested("get", "/v2/inventory_coverage") + assert isinstance(resources.data, list) + assert isinstance(resources.data[0], telnyx.InventoryCoverage) diff --git a/tests/api_resources/test_managed_account.py b/tests/api_resources/test_managed_account.py new file mode 100644 index 0000000..0210193 --- /dev/null +++ b/tests/api_resources/test_managed_account.py @@ -0,0 +1,51 @@ +from __future__ import absolute_import, division, print_function + +import pytest + +import telnyx + +TEST_RESOURCE_ID = "1293384261075731499" + + +class TestManagedAccount(object): + def test_is_listable(self, request_mock): + resources = telnyx.ManagedAccount.list() + request_mock.assert_requested("get", "/v2/managed_accounts") + assert isinstance(resources.data, list) + assert isinstance(resources.data[0], telnyx.ManagedAccount) + + def test_is_retrievable(self, request_mock): + resource = telnyx.ManagedAccount.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested( + "get", "/v2/managed_accounts/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.ManagedAccount) + + def test_is_creatable(self, request_mock): + telnyx.ManagedAccount.create(business_name="Larry's Cat Food Inc") + request_mock.assert_requested("post", "/v2/managed_accounts") + + def test_is_modifiable(self, request_mock): + resource = telnyx.ManagedAccount.modify(TEST_RESOURCE_ID) + request_mock.assert_requested( + "patch", "/v2/managed_accounts/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.ManagedAccount) + + @pytest.mark.skip(reason="Empty body") + def test_can_enable(self, request_mock): + resource = telnyx.ManagedAccount.retrieve(TEST_RESOURCE_ID) + resource.enable() + request_mock.assert_requested( + "post", "/v2/managed_accounts/%s/actions/enable" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.ManagedAccount) + + @pytest.mark.skip(reason="Empty body") + def test_can_disable(self, request_mock): + resource = telnyx.ManagedAccount.retrieve(TEST_RESOURCE_ID) + resource.disable() + request_mock.assert_requested( + "post", "/v2/managed_accounts/%s/actions/disable" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.ManagedAccount) diff --git a/tests/api_resources/test_media.py b/tests/api_resources/test_media.py new file mode 100644 index 0000000..41d2474 --- /dev/null +++ b/tests/api_resources/test_media.py @@ -0,0 +1,40 @@ +from __future__ import absolute_import, division, print_function + +import pytest + +import telnyx + +TEST_RESOURCE_ID = "1293384261075731499" + + +class TestMedia(object): + def test_is_listable(self, request_mock): + resources = telnyx.Media.list() + request_mock.assert_requested("get", "/v2/media") + assert isinstance(resources.data, list) + + def test_is_retrievable(self, request_mock): + resource = telnyx.Media.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested("get", "/v2/media/%s" % TEST_RESOURCE_ID) + assert isinstance(resource, telnyx.Media) + + def test_is_creatable(self, request_mock): + telnyx.Media.create(media_url="http://www.example.com/audio.mp3") + request_mock.assert_requested("post", "/v2/media") + + @pytest.mark.skip(reason="Request body /w object") + def test_is_modifiable(self, request_mock): + resource = telnyx.Media.putify(TEST_RESOURCE_ID) + request_mock.assert_requested("put", "/v2/media/%s" % TEST_RESOURCE_ID) + assert isinstance(resource, telnyx.Media) + + @pytest.mark.skip(reason="Invalid Url") + def test_is_deletable(self, request_mock): + resource = telnyx.Media.retrieve(TEST_RESOURCE_ID) + resource.delete() + request_mock.assert_requested("delete", "/v2/media/%s" % TEST_RESOURCE_ID) + + @pytest.mark.skip(reason="Nested download") + def test_can_download(self, request_mock): + resource = telnyx.Media.retrieve(TEST_RESOURCE_ID) + resource.download(id=TEST_RESOURCE_ID) diff --git a/tests/api_resources/test_messaging_hosted_number.py b/tests/api_resources/test_messaging_hosted_number.py index 1680781..bf7be80 100644 --- a/tests/api_resources/test_messaging_hosted_number.py +++ b/tests/api_resources/test_messaging_hosted_number.py @@ -8,7 +8,7 @@ class TestMessagingHostedNumber(object): - @pytest.mark.skip(reason="Resource not there just yet for endpoint") + @pytest.mark.skip(reason="Retrieve resource no implemented") def test_is_deletable(self, request_mock): resource = telnyx.MessagingHostedNumber() resource.id = TEST_RESOURCE_ID diff --git a/tests/api_resources/test_messaging_phone_number.py b/tests/api_resources/test_messaging_phone_number.py deleted file mode 100644 index d4527a7..0000000 --- a/tests/api_resources/test_messaging_phone_number.py +++ /dev/null @@ -1,44 +0,0 @@ -from __future__ import absolute_import, division, print_function - -import pytest - -import telnyx -from telnyx.six.moves.urllib.parse import quote_plus - -TEST_RESOURCE_ID = "+18005554000" - - -class TestMessagingPhoneNumber(object): - @pytest.mark.skip(reason="Deprecated") - def test_is_listable(self, request_mock): - resources = telnyx.MessagingPhoneNumber.list() - request_mock.assert_requested("get", "/v2/messaging_phone_numbers") - assert isinstance(resources.data, list) - assert isinstance(resources.data[0], telnyx.MessagingPhoneNumber) - - @pytest.mark.skip(reason="Deprecated") - def test_is_retrievable(self, request_mock): - resource = telnyx.MessagingPhoneNumber.retrieve(TEST_RESOURCE_ID) - request_mock.assert_requested( - "get", "/v2/messaging_phone_numbers/%s" % quote_plus(TEST_RESOURCE_ID) - ) - assert isinstance(resource, telnyx.MessagingPhoneNumber) - - @pytest.mark.skip(reason="Deprecated") - def test_is_saveable(self, request_mock): - messaging_phone_number = telnyx.MessagingPhoneNumber.retrieve(TEST_RESOURCE_ID) - messaging_phone_number.name = "value" - resource = messaging_phone_number.save() - request_mock.assert_requested( - "patch", "/v2/messaging_phone_numbers/%s" % quote_plus(TEST_RESOURCE_ID) - ) - assert isinstance(resource, telnyx.MessagingPhoneNumber) - assert resource is messaging_phone_number - - @pytest.mark.skip(reason="Deprecated") - def test_is_modifiable(self, request_mock): - resource = telnyx.MessagingPhoneNumber.modify(TEST_RESOURCE_ID, name="Test") - request_mock.assert_requested( - "patch", "/v2/messaging_phone_numbers/%s" % quote_plus(TEST_RESOURCE_ID) - ) - assert isinstance(resource, telnyx.MessagingPhoneNumber) diff --git a/tests/api_resources/test_messaging_profile.py b/tests/api_resources/test_messaging_profile.py index d80554a..8793c29 100644 --- a/tests/api_resources/test_messaging_profile.py +++ b/tests/api_resources/test_messaging_profile.py @@ -4,7 +4,7 @@ import telnyx -TEST_RESOURCE_ID = "123" +TEST_RESOURCE_ID = "3fa85f64-5717-4562-b3fc-2c963f66afa6" class TestMessagingProfile(object): @@ -108,3 +108,13 @@ def test_can_call_short_codes_forward_params(self, request_mock): ) assert isinstance(resources.data, list) assert isinstance(resources.data[0], telnyx.ShortCode) + + @pytest.mark.skip(reason="Might be deprecated") + def test_can_call_metrics(self, request_mock): + messaging_profile = telnyx.MessagingProfile.retrieve(TEST_RESOURCE_ID) + resources = messaging_profile.metrics() + request_mock.assert_requested( + "get", "/v2/messaging_profiles/%s/metrics" % TEST_RESOURCE_ID + ) + assert isinstance(resources.data, list) + assert isinstance(resources.data[0], telnyx.MessagingProfile) diff --git a/tests/api_resources/test_notification_channel.py b/tests/api_resources/test_notification_channel.py new file mode 100644 index 0000000..dffb7c2 --- /dev/null +++ b/tests/api_resources/test_notification_channel.py @@ -0,0 +1,43 @@ +from __future__ import absolute_import, division, print_function + +import pytest + +import telnyx + +TEST_RESOURCE_ID = "6a09cdc3-8948-47f0-aa62-74ac943d6c58" + + +class TestNotificationChannel(object): + def test_is_listable(self, request_mock): + resources = telnyx.NotificationChannel.list() + request_mock.assert_requested("get", "/v2/notification_channels") + assert isinstance(resources.data, list) + + def test_is_retrievable(self, request_mock): + resource = telnyx.NotificationChannel.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested( + "get", "/v2/notification_channels/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.NotificationChannel) + + @pytest.mark.skip(reason="Create mismatch") + def test_is_creatable(self, request_mock): + resource = telnyx.NotificationChannel.create() + request_mock.assert_requested("post", "/v2/notification_channels") + assert isinstance(resource, telnyx.NotificationChannel) + + @pytest.mark.skip(reason="Create mismatch") + def test_is_modifiable(self, request_mock): + resource = telnyx.NotificationChannel.modify(TEST_RESOURCE_ID, name="Test") + request_mock.assert_requested( + "patch", "/v2/notification_channels/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.NotificationChannel) + + @pytest.mark.skip(reason="Not released, no path yet") + def test_is_deletable(self, request_mock): + resource = telnyx.NotificationChannel.retrieve(TEST_RESOURCE_ID) + resource.delete() + request_mock.assert_requested( + "delete", "/v2/notification_channels/%s" % TEST_RESOURCE_ID + ) diff --git a/tests/api_resources/test_notification_event.py b/tests/api_resources/test_notification_event.py new file mode 100644 index 0000000..7250fe1 --- /dev/null +++ b/tests/api_resources/test_notification_event.py @@ -0,0 +1,10 @@ +from __future__ import absolute_import, division, print_function + +import telnyx + + +class TestNotificationEvent(object): + def test_is_listable(self, request_mock): + resources = telnyx.NotificationEvent.list() + request_mock.assert_requested("get", "/v2/notification_events") + assert isinstance(resources.data, list) diff --git a/tests/api_resources/test_notification_event_condition.py b/tests/api_resources/test_notification_event_condition.py new file mode 100644 index 0000000..748542d --- /dev/null +++ b/tests/api_resources/test_notification_event_condition.py @@ -0,0 +1,10 @@ +from __future__ import absolute_import, division, print_function + +import telnyx + + +class TestNotificationEventCondition(object): + def test_is_listable(self, request_mock): + resources = telnyx.NotificationEventCondition.list() + request_mock.assert_requested("get", "/v2/notification_event_conditions") + assert isinstance(resources.data, list) diff --git a/tests/api_resources/test_notification_profile.py b/tests/api_resources/test_notification_profile.py new file mode 100644 index 0000000..3e653e2 --- /dev/null +++ b/tests/api_resources/test_notification_profile.py @@ -0,0 +1,43 @@ +from __future__ import absolute_import, division, print_function + +import pytest + +import telnyx + +TEST_RESOURCE_ID = "6a09cdc3-8948-47f0-aa62-74ac943d6c58" + + +class TestNotificationProfile(object): + def test_is_listable(self, request_mock): + resources = telnyx.NotificationProfile.list() + request_mock.assert_requested("get", "/v2/notification_profiles") + assert isinstance(resources.data, list) + + def test_is_retrievable(self, request_mock): + resource = telnyx.NotificationProfile.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested( + "get", "/v2/notification_profiles/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.NotificationProfile) + + @pytest.mark.skip(reason="Create mismatch") + def test_is_creatable(self, request_mock): + resource = telnyx.NotificationProfile.create() + request_mock.assert_requested("post", "/v2/notification_profiles") + assert isinstance(resource, telnyx.NotificationProfile) + + @pytest.mark.skip(reason="Create mismatch") + def test_is_modifiable(self, request_mock): + resource = telnyx.NotificationProfile.modify(TEST_RESOURCE_ID, name="Test") + request_mock.assert_requested( + "patch", "/v2/notification_profiles/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.NotificationProfile) + + @pytest.mark.skip(reason="Not released, no path yet") + def test_is_deletable(self, request_mock): + resource = telnyx.NotificationProfile.retrieve(TEST_RESOURCE_ID) + resource.delete() + request_mock.assert_requested( + "delete", "/v2/notification_profiles/%s" % TEST_RESOURCE_ID + ) diff --git a/tests/api_resources/test_notification_setting.py b/tests/api_resources/test_notification_setting.py new file mode 100644 index 0000000..24df24d --- /dev/null +++ b/tests/api_resources/test_notification_setting.py @@ -0,0 +1,35 @@ +from __future__ import absolute_import, division, print_function + +import pytest + +import telnyx + +TEST_RESOURCE_ID = "6a09cdc3-8948-47f0-aa62-74ac943d6c58" + + +class TestNotificationSetting(object): + def test_is_listable(self, request_mock): + resources = telnyx.NotificationSetting.list() + request_mock.assert_requested("get", "/v2/notification_settings") + assert isinstance(resources.data, list) + + def test_is_retrievable(self, request_mock): + resource = telnyx.NotificationSetting.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested( + "get", "/v2/notification_settings/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.NotificationSetting) + + @pytest.mark.skip(reason="Create mismatch") + def test_is_creatable(self, request_mock): + resource = telnyx.NotificationSetting.create() + request_mock.assert_requested("post", "/v2/notification_settings") + assert isinstance(resource, telnyx.NotificationSetting) + + @pytest.mark.skip(reason="Not released, no path yet") + def test_is_deletable(self, request_mock): + resource = telnyx.NotificationSetting.retrieve(TEST_RESOURCE_ID) + resource.delete() + request_mock.assert_requested( + "delete", "/v2/notification_settings/%s" % TEST_RESOURCE_ID + ) diff --git a/tests/api_resources/test_number_reservation.py b/tests/api_resources/test_number_reservation.py index f439251..3e50f6a 100644 --- a/tests/api_resources/test_number_reservation.py +++ b/tests/api_resources/test_number_reservation.py @@ -1,5 +1,7 @@ from __future__ import absolute_import, division, print_function +import pytest + import telnyx NUMBER_RESERVATION_ID = "12ade33a-21c0-473b-b055-b3c836e1c292" @@ -7,7 +9,7 @@ def create_number_reservation(): return telnyx.NumberReservation.create( - phone_numbers=[{"phone_number": "+12223334444"}] + phone_numbers=[{"phone_number": "++19705555098"}] ) @@ -30,6 +32,7 @@ def test_is_creatable(self, request_mock): request_mock.assert_requested("post", "/v2/number_reservations") assert isinstance(resource, telnyx.NumberReservation) + @pytest.mark.skip(reason="async, wait for response") def test_can_call_extend(self, request_mock): resource = create_number_reservation() resource.extend() @@ -38,6 +41,7 @@ def test_can_call_extend(self, request_mock): ) assert isinstance(resource, telnyx.NumberReservation) + @pytest.mark.skip(reason="async, wait for response") def test_can_call_reservation_extend(self, request_mock): resource = create_number_reservation() resource.create_extend(NUMBER_RESERVATION_ID) diff --git a/tests/api_resources/test_outbound_voice_profile.py b/tests/api_resources/test_outbound_voice_profiles.py similarity index 98% rename from tests/api_resources/test_outbound_voice_profile.py rename to tests/api_resources/test_outbound_voice_profiles.py index aace591..e56aa20 100644 --- a/tests/api_resources/test_outbound_voice_profile.py +++ b/tests/api_resources/test_outbound_voice_profiles.py @@ -2,7 +2,7 @@ import telnyx -TEST_RESOURCE_ID = "123" +TEST_RESOURCE_ID = "1293384261075731499" class TestOutboundVoiceProfile(object): diff --git a/tests/api_resources/test_phone_number_campaign.py b/tests/api_resources/test_phone_number_campaign.py new file mode 100644 index 0000000..cc48b32 --- /dev/null +++ b/tests/api_resources/test_phone_number_campaign.py @@ -0,0 +1,44 @@ +from __future__ import absolute_import, division, print_function + +import pytest + +import telnyx + +TEST_RESOURCE_ID = "1293384261075731499" + + +@pytest.mark.skip(reason="Unreleased") +class TestPhoneNumberCampaign(object): + def test_is_listable(self, request_mock): + resources = telnyx.PhoneNumberCampaign.list() + request_mock.assert_requested("get", "/10dlc/phoneNumberCampaign") + assert isinstance(resources.data, list) + assert isinstance(resources.data[0], telnyx.PhoneNumberCampaign) + + def test_is_retrievable(self, request_mock): + resource = telnyx.PhoneNumberCampaign.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested( + "get", "/10dlc/phoneNumberCampaign/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.PhoneNumberCampaign) + + def test_is_creatable(self, request_mock): + resource = telnyx.PhoneNumberCampaign.create( + phoneNumber="1920324562", campaignID=TEST_RESOURCE_ID + ) + request_mock.assert_requested("post", "/10dlc/phoneNumberCampaign") + assert isinstance(resource, telnyx.PhoneNumberCampaign) + + def test_is_modifiable(self, request_mock): + resource = telnyx.PhoneNumberCampaign.modify(TEST_RESOURCE_ID) + request_mock.assert_requested( + "patch", "/10dlc/phoneNumberCampaign/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.PhoneNumberCampaign) + + def test_is_deletable(self, request_mock): + resource = telnyx.PhoneNumberCampaign.retrieve(TEST_RESOURCE_ID) + resource.delete() + request_mock.assert_requested( + "delete", "/10dlc/phoneNumberCampaign/%s" % TEST_RESOURCE_ID + ) diff --git a/tests/api_resources/test_phone_number_job.py b/tests/api_resources/test_phone_number_job.py new file mode 100644 index 0000000..d530509 --- /dev/null +++ b/tests/api_resources/test_phone_number_job.py @@ -0,0 +1,41 @@ +from __future__ import absolute_import, division, print_function + +import telnyx + +TEST_RESOURCE_ID = "1293384261075731499" + + +class TestPhoneNumberJob(object): + def test_is_listable(self, request_mock): + resources = telnyx.PhoneNumberJob.list() + request_mock.assert_requested("get", "/v2/phone_numbers/jobs") + assert isinstance(resources.data, list) + + def test_is_retrievable(self, request_mock): + resource = telnyx.PhoneNumberJob.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested( + "get", "/v2/phone_numbers/jobs/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.PhoneNumberJob) + + def test_update_emergency_settings(self, request_mock): + telnyx.PhoneNumberJob.update_emergency_settings( + emergency_address_id="53829456729313", + emergency_enabled=True, + phone_numbers=[], + ) + request_mock.assert_requested( + "post", "/v2/phone_numbers/jobs/update_emergency_settings" + ) + + def test_update_phone_numbers(self, request_mock): + telnyx.PhoneNumberJob.update_phone_numbers(phone_numbers=[]) + request_mock.assert_requested( + "post", "/v2/phone_numbers/jobs/update_phone_numbers" + ) + + def test_delete_phone_numbers(self, request_mock): + telnyx.PhoneNumberJob.delete_phone_numbers(phone_numbers=[]) + request_mock.assert_requested( + "post", "/v2/phone_numbers/jobs/delete_phone_numbers" + ) diff --git a/tests/api_resources/test_phone_number_regulatory_requirement.py b/tests/api_resources/test_phone_number_regulatory_requirement.py index 8ca22a7..f89db66 100644 --- a/tests/api_resources/test_phone_number_regulatory_requirement.py +++ b/tests/api_resources/test_phone_number_regulatory_requirement.py @@ -4,12 +4,15 @@ import telnyx -TEST_RESOURCE_ID = "123" +TEST_RESOURCE_ID = "45f45a04-b4be-4592-95b1-9306b9db2b21" +@pytest.mark.skip(reason="Filter looking for 'filter%5bphone_number%5d', typo") class TestPhoneNumberRegulatoryRequirement(object): def test_is_listable(self, request_mock): - resources = telnyx.PhoneNumberRegulatoryRequirement.list() + resources = telnyx.PhoneNumberRegulatoryRequirement.list( + filter={"phone_number": "+41215470622,+41215470633"} + ) request_mock.assert_requested( "get", "/v2/phone_numbers_regulatory_requirements" ) diff --git a/tests/api_resources/test_porting_order.py b/tests/api_resources/test_porting_order.py index 681a1cf..c264ab3 100644 --- a/tests/api_resources/test_porting_order.py +++ b/tests/api_resources/test_porting_order.py @@ -21,7 +21,7 @@ def test_is_retrievable(self, request_mock): def test_is_creatable(self, request_mock): resource = telnyx.PortingOrder.create( - phone_numbers=["13035550000", "13035550001", "13035550002"], + phone_numbers=["13035550000", "13035550001", "13035550002"] ) request_mock.assert_requested("post", "/v2/porting_orders") assert isinstance(resource.data[0], telnyx.PortingOrder) @@ -48,19 +48,21 @@ def test_is_modifiable(self, request_mock): ) assert isinstance(resource, telnyx.PortingOrder) - def test_is_deletable(self, request_mock): + @pytest.mark.skip(reason="Needs live confirm") + def test_can_confirm_porting_order_action(self, request_mock): resource = telnyx.PortingOrder.retrieve(TEST_RESOURCE_ID) - resource.delete() + resource.create_confirm(id=TEST_RESOURCE_ID) request_mock.assert_requested( - "delete", "/v2/porting_orders/%s" % TEST_RESOURCE_ID + "post", "/v2/porting_orders/%s/actions/confirm" % TEST_RESOURCE_ID ) assert isinstance(resource, telnyx.PortingOrder) - def test_can_confirm_porting_order_action(self, request_mock): + @pytest.mark.skip(reason="Needs live cancel") + def test_can_cancel_porting_order_action(self, request_mock): resource = telnyx.PortingOrder.retrieve(TEST_RESOURCE_ID) - resource.confirm() + resource.create_cancel(id=TEST_RESOURCE_ID) request_mock.assert_requested( - "post", "/v2/porting_orders/%s/actions/confirm" % TEST_RESOURCE_ID + "post", "/v2/porting_orders/%s/actions/cancel" % TEST_RESOURCE_ID ) assert isinstance(resource, telnyx.PortingOrder) @@ -73,6 +75,29 @@ def test_can_get_loa_template(self, request_mock): ) assert isinstance(resource, telnyx.PortingOrder) + @pytest.mark.skip(reason="Unreleased") + def test_can_list_allowed_foc_dates(self, request_mock): + resource = telnyx.PortingOrder.retrieve(TEST_RESOURCE_ID) + resource.allowed_foc_windows() + request_mock.assert_requested( + "get", "/v2/porting_orders/%s/allowed_foc_windows" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.PortingOrder) + + @pytest.mark.skip(reason="Unreleased") + def test_can_list_activation_jobs(self, request_mock): + resource = telnyx.PortingOrder.retrieve(TEST_RESOURCE_ID) + resource.activation_jobs() + request_mock.assert_requested( + "get", "/v2/porting_orders/%s/activation_jobs" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.PortingOrder) + + @pytest.mark.skip(reason="Unreleased") + def test_can_list_exception_types(self, request_mock): + telnyx.PortingOrder.create_exception_types() + request_mock.assert_requested("get", "/v2/porting_orders/exception_types") + def test_can_list_porting_phone_numbers(self, request_mock): resource = telnyx.PortingPhoneNumber.list() request_mock.assert_requested("get", "/v2/porting_phone_numbers") diff --git a/tests/api_resources/test_portout.py b/tests/api_resources/test_portout.py index c5b02ab..feaea4f 100644 --- a/tests/api_resources/test_portout.py +++ b/tests/api_resources/test_portout.py @@ -32,3 +32,19 @@ def test_portout_comments_is_createable(self, request_mock): "post", "/v2/portouts/%s/comments" % TEST_RESOURCE_ID ) assert isinstance(resource, telnyx.PortOut) + + def test_portout_support_documents_is_listable(self, request_mock): + resource = telnyx.PortOut() + resource.list_supporting_documents(id=TEST_RESOURCE_ID) + request_mock.assert_requested( + "get", "/v2/portouts/%s/supporting_documents" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.PortOut) + + def test_portout_support_documents_is_createable(self, request_mock): + resource = telnyx.PortOut.retrieve(TEST_RESOURCE_ID) + resource.create_supporting_documents(id=TEST_RESOURCE_ID, body="This is a body") + request_mock.assert_requested( + "post", "/v2/portouts/%s/supporting_documents" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.PortOut) diff --git a/tests/api_resources/test_public_key.py b/tests/api_resources/test_public_key.py index 7fd5896..346d5ba 100644 --- a/tests/api_resources/test_public_key.py +++ b/tests/api_resources/test_public_key.py @@ -6,7 +6,7 @@ class TestPublicKey(object): - @pytest.mark.skip(reason="Unsure about this endpoint") + @pytest.mark.skip(reason="Unsure about this endpoint, might be deprecated") def test_is_retrievable(self, request_mock): resource = telnyx.PublicKey.retrieve() request_mock.assert_requested("get", "/v2/public_key") diff --git a/tests/api_resources/test_regulatory_requirement.py b/tests/api_resources/test_regulatory_requirement.py deleted file mode 100644 index 5b1688f..0000000 --- a/tests/api_resources/test_regulatory_requirement.py +++ /dev/null @@ -1,20 +0,0 @@ -from __future__ import absolute_import, division, print_function - -import telnyx - -TEST_RESOURCE_ID = "123" - - -class TestRegulatoryRequirement(object): - def test_is_listable(self, request_mock): - resources = telnyx.RegulatoryRequirement.list() - request_mock.assert_requested("get", "/v2/regulatory_requirements") - assert isinstance(resources.data, list) - assert isinstance(resources.data[0], telnyx.RegulatoryRequirement) - - def test_is_retrievable(self, request_mock): - resource = telnyx.RegulatoryRequirement.retrieve(TEST_RESOURCE_ID) - request_mock.assert_requested( - "get", "/v2/regulatory_requirements/%s" % TEST_RESOURCE_ID - ) - assert isinstance(resource, telnyx.RegulatoryRequirement) diff --git a/tests/api_resources/test_room.py b/tests/api_resources/test_room.py new file mode 100644 index 0000000..2a5c2c0 --- /dev/null +++ b/tests/api_resources/test_room.py @@ -0,0 +1,55 @@ +import pytest + +import telnyx + +TEST_RESOURCE_ID = "3fa85f64-5717-4562-b3fc-2c963f66afa6" + + +class TestRoom(object): + def test_is_listable(self, request_mock): + resources = telnyx.Room.list() + request_mock.assert_requested("get", "/v2/rooms") + assert isinstance(resources.data, list) + + def test_is_retrievable(self, request_mock): + resource = telnyx.Room.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested("get", "/v2/rooms/%s" % TEST_RESOURCE_ID) + assert isinstance(resource, telnyx.Room) + + def test_is_creatable(self, request_mock): + telnyx.Room.create() + request_mock.assert_requested("post", "/v2/rooms") + + def test_is_modifiable(self, request_mock): + telnyx.Room.modify( + TEST_RESOURCE_ID, enable_recording=False, max_participants=20 + ) + request_mock.assert_requested("patch", "/v2/rooms/%s" % TEST_RESOURCE_ID) + + @pytest.mark.skip(reason="204 Response (silent)") + def test_is_deletable(self, request_mock): + resource = telnyx.Room.retrieve(TEST_RESOURCE_ID) + resource.delete() + request_mock.assert_requested("delete", "/v2/rooms/%s" % TEST_RESOURCE_ID) + + @pytest.mark.skip(reason="Nest List") + def test_can_list_sessions(self, request_mock): + resource = telnyx.Room.retrieve(TEST_RESOURCE_ID) + resource.list_sessions() + + def test_can_generate_token(self, request_mock): + resource = telnyx.Room.retrieve(TEST_RESOURCE_ID) + resource.create_generate_token(id=TEST_RESOURCE_ID) + request_mock.assert_requested( + "post", "/v2/rooms/%s/actions/generate_join_client_token" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.Room) + + @pytest.mark.skip(reason="Needs token") + def test_can_refresh_token(self, request_mock): + resource = telnyx.Room.retrieve(TEST_RESOURCE_ID) + resource.create_refresh_token(id="TEST_RESOURCE_ID") + request_mock.assert_requested( + "post", "/v2/rooms/%s/actions/refresh_client_token" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.Room) diff --git a/tests/api_resources/test_room_participant.py b/tests/api_resources/test_room_participant.py new file mode 100644 index 0000000..5538ef4 --- /dev/null +++ b/tests/api_resources/test_room_participant.py @@ -0,0 +1,18 @@ +import telnyx + +TEST_RESOURCE_ID = "3fa85f64-5717-4562-b3fc-2c963f66afa6" + + +class TestRoomParticipant(object): + def test_is_listable(self, request_mock): + resources = telnyx.RoomParticipant.list() + request_mock.assert_requested("get", "/v2/room_participants") + assert isinstance(resources.data, list) + assert isinstance(resources.data[0], telnyx.RoomParticipant) + + def test_is_retrievable(self, request_mock): + resource = telnyx.RoomParticipant.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested( + "get", "/v2/room_participants/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.RoomParticipant) diff --git a/tests/api_resources/test_room_sessions.py b/tests/api_resources/test_room_sessions.py new file mode 100644 index 0000000..b9518ee --- /dev/null +++ b/tests/api_resources/test_room_sessions.py @@ -0,0 +1,52 @@ +import pytest + +import telnyx + +TEST_RESOURCE_ID = "3fa85f64-5717-4562-b3fc-2c963f66afa6" + + +class TestRoomSessions(object): + def test_is_listable(self, request_mock): + resources = telnyx.RoomSession.list() + request_mock.assert_requested("get", "/v2/room_sessions") + assert isinstance(resources.data, list) + assert isinstance(resources.data[0], telnyx.RoomSession) + + def test_is_retrievable(self, request_mock): + resource = telnyx.RoomSession.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested("get", "/v2/room_sessions/%s" % TEST_RESOURCE_ID) + assert isinstance(resource, telnyx.RoomSession) + + def test_can_call_create_mute(self, request_mock): + resource = telnyx.RoomSession.retrieve(TEST_RESOURCE_ID) + resource.create_mute(id=TEST_RESOURCE_ID, particpants="all") + request_mock.assert_requested( + "post", "/v2/room_sessions/%s/actions/mute" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.RoomSession) + + def test_can_call_create_unmute(self, request_mock): + resource = telnyx.RoomSession.retrieve(TEST_RESOURCE_ID) + resource.create_unmute(id=TEST_RESOURCE_ID, particpants="all") + request_mock.assert_requested( + "post", "/v2/room_sessions/%s/actions/unmute" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.RoomSession) + + def test_can_call_kick(self, request_mock): + resource = telnyx.RoomSession.retrieve(TEST_RESOURCE_ID) + resource.create_kick(id=TEST_RESOURCE_ID, particpants="all") + request_mock.assert_requested( + "post", "/v2/room_sessions/%s/actions/kick" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.RoomSession) + + @pytest.mark.skip(reason="Participant list ") + def test_can_list_participants(self, request_mock): + resource = telnyx.RoomSession.retrieve(TEST_RESOURCE_ID) + resource.active = True + participants = resource.list_participants() + request_mock.assert_requested( + "get", "/v2/room_sessions/%s/participants" % resource.name + ) + assert isinstance(participants.data[0], telnyx.RoomSession) diff --git a/tests/api_resources/test_short_code.py b/tests/api_resources/test_short_code.py index 011f6f4..8a84c2f 100644 --- a/tests/api_resources/test_short_code.py +++ b/tests/api_resources/test_short_code.py @@ -2,7 +2,7 @@ import telnyx -TEST_RESOURCE_ID = "123" +TEST_RESOURCE_ID = "3fa85f64-5717-4562-b3fc-2c963f66afa6" class TestShortCode(object): diff --git a/tests/api_resources/test_sim_card.py b/tests/api_resources/test_sim_card.py index 14aa1f0..b8589fe 100644 --- a/tests/api_resources/test_sim_card.py +++ b/tests/api_resources/test_sim_card.py @@ -1,5 +1,7 @@ from __future__ import absolute_import, division, print_function +import pytest + import telnyx TEST_RESOURCE_ID = "6a09cdc3-8948-47f0-aa62-74ac943d6c58" @@ -30,20 +32,54 @@ def test_is_modifiable(self, request_mock): request_mock.assert_requested("patch", "/v2/sim_cards/%s" % TEST_RESOURCE_ID) assert isinstance(resource, telnyx.SIMCard) + def test_is_deletabale(self, request_mock): + sim_card = telnyx.SIMCard.retrieve(TEST_RESOURCE_ID) + sim_card.delete() + request_mock.assert_requested("delete", "/v2/sim_cards/%s" % TEST_RESOURCE_ID) + assert isinstance(sim_card, telnyx.SIMCard) + + @pytest.mark.skip(reason="Async, need to wait for promise") def test_enable(self, request_mock): resource = telnyx.SIMCard.retrieve(TEST_RESOURCE_ID) - resource.enable() + resource.create_enable() request_mock.assert_requested( "post", "/v2/sim_cards/%s/actions/enable" % TEST_RESOURCE_ID ) + @pytest.mark.skip(reason="Async, need to wait for promise") def test_disable(self, request_mock): resource = telnyx.SIMCard.retrieve(TEST_RESOURCE_ID) - resource.disable() + resource.create_disable() request_mock.assert_requested( "post", "/v2/sim_cards/%s/actions/disable" % TEST_RESOURCE_ID ) + @pytest.mark.skip(reason="Async, need to wait for promise") + def test_set_standby(self, request_mock): + telnyx.SIMCard.create_set_standby(TEST_RESOURCE_ID) + request_mock.assert_requested( + "post", "/v2/sim_cards/%s/actions/set_standby" % TEST_RESOURCE_ID + ) + + @pytest.mark.skip(reason="Async, need to wait for promise") + def test_remove_public_ip(self, request_mock): + telnyx.SIMCard.create_remove_public_ip(TEST_RESOURCE_ID) + request_mock.assert_requested( + "post", "/v2/sim_cards/%s/actions/remove_public_ip" % TEST_RESOURCE_ID + ) + + @pytest.mark.skip(reason="Async, need to wait for promise") + def test_set_public_ip(self, request_mock): + telnyx.SIMCard.create_set_public_ip(TEST_RESOURCE_ID) + request_mock.assert_requested( + "post", "/v2/sim_cards/%s/actions/set_public_ip" % TEST_RESOURCE_ID + ) + + @pytest.mark.skip(reason="deprecated?") + def test_wireless_connectivity_logs(self, request_mock): + source = telnyx.SIMCard.retrieve(TEST_RESOURCE_ID) + source.list_wireless_logs() + def test_register(self, request_mock): telnyx.SIMCard.register(registration_codes=["foo", "bar"]) request_mock.assert_requested("post", "/v2/actions/register/sim_cards") diff --git a/tests/api_resources/test_sim_card_action.py b/tests/api_resources/test_sim_card_action.py new file mode 100644 index 0000000..0029cbd --- /dev/null +++ b/tests/api_resources/test_sim_card_action.py @@ -0,0 +1,20 @@ +from __future__ import absolute_import, division, print_function + +import telnyx + +TEST_RESOURCE_ID = "6a09cdc3-8948-47f0-aa62-74ac943d6c58" + + +class TestSIMCardActions(object): + def test_is_listable(self, request_mock): + resources = telnyx.SIMCardAction.list() + request_mock.assert_requested("get", "/v2/sim_card_actions") + assert isinstance(resources.data, list) + assert isinstance(resources.data[0], telnyx.SIMCardAction) + + def test_is_retrievable(self, request_mock): + resource = telnyx.SIMCardAction.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested( + "get", "/v2/sim_card_actions/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.SIMCardAction) diff --git a/tests/api_resources/test_sim_card_group.py b/tests/api_resources/test_sim_card_group.py new file mode 100644 index 0000000..30ad3c6 --- /dev/null +++ b/tests/api_resources/test_sim_card_group.py @@ -0,0 +1,49 @@ +from __future__ import absolute_import, division, print_function + +import telnyx + +TEST_RESOURCE_ID = "6a09cdc3-8948-47f0-aa62-74ac943d6c58" + + +class TestSIMCardGroups(object): + def test_is_listable(self, request_mock): + resources = telnyx.SIMCardGroup.list() + request_mock.assert_requested("get", "/v2/sim_card_groups") + assert isinstance(resources.data, list) + assert isinstance(resources.data[0], telnyx.SIMCardGroup) + + def test_is_retrievable(self, request_mock): + resource = telnyx.SIMCardGroup.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested( + "get", "/v2/sim_card_groups/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.SIMCardGroup) + + def test_is_creatable(self, request_mock): + resource = telnyx.SIMCardGroup.create(name="My Test Group") + request_mock.assert_requested("post", "/v2/sim_card_groups") + assert isinstance(resource, telnyx.SIMCardGroup) + + def test_is_saveable(self, request_mock): + sim_card_group = telnyx.SIMCardGroup.retrieve(TEST_RESOURCE_ID) + sim_card_group.name = "My Test Group" + resource = sim_card_group.save() + request_mock.assert_requested( + "patch", "/v2/sim_card_groups/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.SIMCardGroup) + assert resource is sim_card_group + + def test_is_modifiable(self, request_mock): + resource = telnyx.SIMCardGroup.modify(TEST_RESOURCE_ID, name="Updated Name") + request_mock.assert_requested( + "patch", "/v2/sim_card_groups/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.SIMCardGroup) + + def test_is_deletable(self, request_mock): + resource = telnyx.SIMCardGroup.retrieve(TEST_RESOURCE_ID) + resource.delete() + request_mock.assert_requested( + "delete", "/v2/sim_card_groups/%s" % TEST_RESOURCE_ID + ) diff --git a/tests/api_resources/test_sim_card_order.py b/tests/api_resources/test_sim_card_order.py new file mode 100644 index 0000000..ae6070a --- /dev/null +++ b/tests/api_resources/test_sim_card_order.py @@ -0,0 +1,28 @@ +from __future__ import absolute_import, division, print_function + +import telnyx + +TEST_RESOURCE_ID = "6a09cdc3-8948-47f0-aa62-74ac943d6c58" + + +class TestSIMCardOrder(object): + def test_is_listable(self, request_mock): + resources = telnyx.SIMCardOrder.list() + request_mock.assert_requested("get", "/v2/sim_card_orders") + assert isinstance(resources.data, list) + assert isinstance(resources.data[0], telnyx.SIMCardOrder) + + def test_is_retrievable(self, request_mock): + resource = telnyx.SIMCardOrder.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested( + "get", "/v2/sim_card_orders/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.SIMCardOrder) + + def test_is_creatable(self, request_mock): + resource = telnyx.SIMCardOrder.create(address_id=TEST_RESOURCE_ID, quantity=23) + request_mock.assert_requested("post", "/v2/sim_card_orders") + assert isinstance(resource, telnyx.SIMCardOrder) + + def test_can_sim_preview(self, request_mock): + telnyx.SIMCardOrderPreview.create(address_id=TEST_RESOURCE_ID, quantity=23) diff --git a/tests/api_resources/test_sub_number_order.py b/tests/api_resources/test_sub_number_order.py new file mode 100644 index 0000000..0316e5f --- /dev/null +++ b/tests/api_resources/test_sub_number_order.py @@ -0,0 +1,25 @@ +import telnyx + +TEST_RESOURCE_ID = "6a09cdc3-8948-47f0-aa62-74ac943d6c58" + + +class TestSubNumberOrder(object): + def test_is_listable(self, request_mock): + resources = telnyx.SubNumberOrder.list() + request_mock.assert_requested("get", "/v2/sub_number_orders") + assert isinstance(resources.data, list) + assert isinstance(resources.data[0], telnyx.SubNumberOrder) + + def test_is_retrievable(self, request_mock): + resource = telnyx.SubNumberOrder.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested( + "get", "/v2/sub_number_orders/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.SubNumberOrder) + + def test_is_modifiable(self, request_mock): + resource = telnyx.SubNumberOrder.modify(TEST_RESOURCE_ID) + request_mock.assert_requested( + "patch", "/v2/sub_number_orders/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.SubNumberOrder) diff --git a/tests/api_resources/test_telephony_credential.py b/tests/api_resources/test_telephony_credential.py index 694df44..0a1d17d 100644 --- a/tests/api_resources/test_telephony_credential.py +++ b/tests/api_resources/test_telephony_credential.py @@ -1,8 +1,10 @@ from __future__ import absolute_import, division, print_function +import pytest + import telnyx -TEST_RESOURCE_ID = "6a09cdc3-8948-47f0-aa62-74ac943d6c58" +TEST_RESOURCE_ID = "c215ade3-0d39-418e-94be-c5f780760199" class TestTelephonyCredential(object): @@ -20,9 +22,7 @@ def test_is_retrievable(self, request_mock): assert isinstance(resource, telnyx.TelephonyCredential) def test_is_creatable(self, request_mock): - resource = telnyx.TelephonyCredential.create( - connection_id="some-connection-id", - ) + resource = telnyx.TelephonyCredential.create(connection_id="some-connection-id") request_mock.assert_requested("post", "/v2/telephony_credentials") assert isinstance(resource, telnyx.TelephonyCredential) @@ -49,3 +49,8 @@ def test_is_deletable(self, request_mock): request_mock.assert_requested( "delete", "/v2/telephony_credentials/%s" % TEST_RESOURCE_ID ) + + @pytest.mark.skip(reason="API resolution is just a string") + def test_is_token_createable(self, request_mock): + resource = telnyx.TelephonyCredential.retrieve(TEST_RESOURCE_ID) + resource.token() diff --git a/tests/api_resources/test_verification.py b/tests/api_resources/test_verification.py index 050b2d1..97a7b8e 100644 --- a/tests/api_resources/test_verification.py +++ b/tests/api_resources/test_verification.py @@ -1,9 +1,9 @@ import telnyx -TEST_RESOURCE_ID = "123" +TEST_RESOURCE_ID = "12ade33a-21c0-473b-b055-b3c836e1c292" TEST_PHONE_NUMBER = "+13125000000" VERIFY_CODE = "12345" -VERIFY_PROFILE = "32567" +VERIFY_PROFILE = "12ade33a-21c0-473b-b055-b3c836e1c292" class TestVerification(object): @@ -15,7 +15,9 @@ def test_is_retrievable(self, request_mock): def test_can_verify_by_phone_number(self, request_mock): resource = telnyx.Verification.retrieve(TEST_RESOURCE_ID) resource.verify_by_phone_number( - code=VERIFY_CODE, phone_number=TEST_PHONE_NUMBER + code=VERIFY_CODE, + phone_number=TEST_PHONE_NUMBER, + verify_profile_id=VERIFY_PROFILE, ) request_mock.assert_requested( "post", diff --git a/tests/api_resources/test_verify_profiles.py b/tests/api_resources/test_verify_profiles.py index 45eaf50..1e99840 100644 --- a/tests/api_resources/test_verify_profiles.py +++ b/tests/api_resources/test_verify_profiles.py @@ -2,10 +2,10 @@ import telnyx -TEST_RESOURCE_ID = "123" +TEST_RESOURCE_ID = "12ade33a-21c0-473b-b055-b3c836e1c292" -@pytest.mark.skip(reason="Updated-Endpoint") +@pytest.mark.skip(reason="Updated_Endpoint") class TestVerifyProfile(object): def test_is_listable(self, request_mock): resources = telnyx.VerifyProfile.list() @@ -21,7 +21,7 @@ def test_is_retrievable(self, request_mock): assert isinstance(resource, telnyx.VerifyProfile) def test_is_saveable(self, request_mock): - resource = telnyx.VerifyProfile.create(name="Hi there") + resource = telnyx.VerifyProfile.create(name="hi there") request_mock.assert_requested("post", "/v2/verify_profiles") assert isinstance(resource, telnyx.VerifyProfile) assert resource is resource diff --git a/tests/api_resources/test_webhook_deliveries.py b/tests/api_resources/test_webhook_deliveries.py new file mode 100644 index 0000000..88537d4 --- /dev/null +++ b/tests/api_resources/test_webhook_deliveries.py @@ -0,0 +1,17 @@ +import telnyx + +TEST_RESOURCE_ID = "12ade33a-21c0-473b-b055-b3c836e1c292" + + +class TestWebhookDeliveries(object): + def test_is_listable(self, request_mock): + resources = telnyx.WebhookDeliveries.list() + request_mock.assert_requested("get", "/v2/webhook_deliveries") + assert isinstance(resources.data, list) + + def test_is_retrievable(self, request_mock): + resource = telnyx.WebhookDeliveries.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested( + "get", "/v2/webhook_deliveries/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.WebhookDeliveries) diff --git a/tests/api_resources/test_whatsapp_business_account.py b/tests/api_resources/test_whatsapp_business_account.py new file mode 100644 index 0000000..22d6607 --- /dev/null +++ b/tests/api_resources/test_whatsapp_business_account.py @@ -0,0 +1,17 @@ +import telnyx + +TEST_RESOURCE_ID = "12ade33a-21c0-473b-b055-b3c836e1c292" + + +class TestWhatsappBusinessAccount(object): + def test_is_listable(self, request_mock): + resources = telnyx.WhatsappBusinessAccount.list() + request_mock.assert_requested("get", "/v2/whatsapp_business_accounts") + assert isinstance(resources.data, list) + + def test_is_retrievable(self, request_mock): + resource = telnyx.WhatsappBusinessAccount.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested( + "get", "/v2/whatsapp_business_accounts/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.WhatsappBusinessAccount) diff --git a/tests/api_resources/test_whatsapp_contact.py b/tests/api_resources/test_whatsapp_contact.py new file mode 100644 index 0000000..efe45bf --- /dev/null +++ b/tests/api_resources/test_whatsapp_contact.py @@ -0,0 +1,14 @@ +from __future__ import absolute_import, division, print_function + +import telnyx + +TEST_RESOURCE_ID = "12ade33a-21c0-473b-b055-b3c836e1c292" + + +class TestWhatsappContact(object): + def test_is_creatable(self, request_mock): + telnyx.WhatsappContact.create( + contacts=["19201234567"], whatsapp_user_id="15125551234" + ) + request_mock.assert_requested("post", "/v2/whatsapp_contacts") + # assert isinstance(resource, telnyx.WhatsappContact) diff --git a/tests/api_resources/test_whatsapp_media.py b/tests/api_resources/test_whatsapp_media.py new file mode 100644 index 0000000..a27ed02 --- /dev/null +++ b/tests/api_resources/test_whatsapp_media.py @@ -0,0 +1,20 @@ +from __future__ import absolute_import, division, print_function + +import pytest + +import telnyx + +TEST_RESOURCE_ID = "12ade33a-21c0-473b-b055-b3c836e1c292" +TEST_RESOURCE_ID_2 = "92ade33a-21c0-473b-b055-b3c836e1c292" + + +class TestWhatsappMedia(object): + @pytest.mark.skip(reason="Need to make test for media uploads") + def test_is_creatable(self, request_mock): + resource = telnyx.WhatsappMedia.create( + media_content_type=["19201234567"], + upload_file="This is a test", + whatsapp_user_id="123144121", + ) + request_mock.assert_requested("post", "/v2/whatsapp_media") + assert isinstance(resource, telnyx.WhatsappMedia) diff --git a/tests/api_resources/test_whatsapp_message.py b/tests/api_resources/test_whatsapp_message.py new file mode 100644 index 0000000..5dbe83a --- /dev/null +++ b/tests/api_resources/test_whatsapp_message.py @@ -0,0 +1,24 @@ +from __future__ import absolute_import, division, print_function + +import pytest + +import telnyx + +TEST_RESOURCE_ID = "12ade33a-21c0-473b-b055-b3c836e1c292" + + +class TestWhatsappMessage(object): + @pytest.mark.skip(reason="API response structure fix needed") + def test_is_createable(self, request_mock): + resource = telnyx.WhatsappMessage.create( + to="96214131231", whatsapp_user_id="1231244123412" + ) + request_mock.assert_requested("post", "/v2/whatsapp_messages") + assert isinstance(resource, telnyx.WhatsappMessage) + + @pytest.mark.skip(reason="Response code 204, not 200 (passes)") + def test_is_updateable(self, request_mock): + resource = telnyx.WhatsappMessage(TEST_RESOURCE_ID) + resource.status = "read" + resource.whatsapp_user_id = "1512551212" + resource.save() diff --git a/tests/api_resources/test_whatsapp_phone_number.py b/tests/api_resources/test_whatsapp_phone_number.py new file mode 100644 index 0000000..ba0712c --- /dev/null +++ b/tests/api_resources/test_whatsapp_phone_number.py @@ -0,0 +1,22 @@ +from __future__ import absolute_import, division, print_function + +import telnyx + +TEST_RESOURCE_ID = "12ade33a-21c0-473b-b055-b3c836e1c292" + + +class TestWhatsappPhoneNumber(object): + def test_is_retrievable(self, request_mock): + resource = telnyx.WhatsappPhoneNumber.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested( + "get", "/v2/whatsapp_phone_numbers/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.WhatsappPhoneNumber) + + def test_is_updateable(self, request_mock): + resource = telnyx.WhatsappPhoneNumber.retrieve(TEST_RESOURCE_ID) + resource.save() + request_mock.assert_requested( + "get", "/v2/whatsapp_phone_numbers/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.WhatsappPhoneNumber) diff --git a/tests/api_resources/test_wireless_details_record_report.py b/tests/api_resources/test_wireless_details_record_report.py new file mode 100644 index 0000000..1e6dad7 --- /dev/null +++ b/tests/api_resources/test_wireless_details_record_report.py @@ -0,0 +1,29 @@ +from __future__ import absolute_import, division, print_function + +import telnyx + +TEST_RESOURCE_ID = "6a09cdc3-8948-47f0-aa62-74ac943d6c58" + + +class TestWirelessDetailRecords(object): + def test_is_listable(self, request_mock): + resources = telnyx.WirelessDetailRecordsReports.list() + request_mock.assert_requested("get", "/v2/wireless/detail_records_reports") + assert isinstance(resources.data, list) + + def test_is_retrievable(self, request_mock): + telnyx.WirelessDetailRecordsReports.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested( + "get", "/v2/wireless/detail_records_reports/%s" % TEST_RESOURCE_ID + ) + + def test_is_creatable(self, request_mock): + telnyx.WirelessDetailRecordsReports.create() + request_mock.assert_requested("post", "/v2/wireless/detail_records_reports") + + def test_is_deletable(self, request_mock): + resource = telnyx.WirelessDetailRecordsReports.retrieve(TEST_RESOURCE_ID) + resource.delete() + request_mock.assert_requested( + "delete", "/v2/wireless/detail_records_reports/%s" % TEST_RESOURCE_ID + ) diff --git a/tests/conftest.py b/tests/conftest.py index d3f548a..63c50e7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,7 +3,6 @@ import atexit import os import sys -from distutils.version import StrictVersion # pylint: disable=import-error import pytest @@ -41,6 +40,7 @@ def stop_telnyx_mock(): "it running? Please see README for setup instructions." % MOCK_PORT ) +""" version = info.get("Telnyx-Mock-Version") if version != "master" and StrictVersion(version) < StrictVersion(MOCK_MINIMUM_VERSION): sys.exit( @@ -48,6 +48,7 @@ def stop_telnyx_mock(): "version to run this test suite is %s. Please " "see its repository for upgrade instructions." % (version, MOCK_MINIMUM_VERSION) ) +""" @pytest.fixture(autouse=True) diff --git a/tests/test_api_requestor.py b/tests/test_api_requestor.py index bfc3c8a..50e1cb9 100644 --- a/tests/test_api_requestor.py +++ b/tests/test_api_requestor.py @@ -161,7 +161,7 @@ class TestAPIRequestor(object): }, "list": [1, "foo", "baz"], "string": "boo", - "unicode": u"\u1234", + "unicode": "\u1234", "datetime": datetime.datetime(2013, 1, 1, second=1, tzinfo=GMT1()), "none": None, } @@ -180,7 +180,7 @@ class TestAPIRequestor(object): ], "list": [("%s[]", 1), ("%s[]", "foo"), ("%s[]", "baz")], "string": [("%s", "boo")], - "unicode": [("%s", telnyx.util.utf8(u"\u1234"))], + "unicode": [("%s", telnyx.util.utf8("\u1234"))], "datetime": [("%s", 1356994801)], "none": [], } diff --git a/tests/test_error.py b/tests/test_error.py index 5c882da..7be0fee 100644 --- a/tests/test_error.py +++ b/tests/test_error.py @@ -7,24 +7,24 @@ class TestTelnyxError(object): def test_formatting(self): - err = error.TelnyxError(u"öre") - assert six.text_type(err) == u"öre" + err = error.TelnyxError("öre") + assert six.text_type(err) == "öre" if six.PY2: assert str(err) == "\xc3\xb6re" else: - assert str(err) == u"öre" + assert str(err) == "öre" def test_formatting_with_request_id(self): - err = error.TelnyxError(u"öre", http_headers={"request-id": "123"}) - assert six.text_type(err) == u"Request 123: öre" + err = error.TelnyxError("öre", http_headers={"request-id": "123"}) + assert six.text_type(err) == "Request 123: öre" if six.PY2: assert str(err) == "Request 123: \xc3\xb6re" else: - assert str(err) == u"Request 123: öre" + assert str(err) == "Request 123: öre" def test_formatting_with_none(self): err = error.TelnyxError(None, http_headers={"request-id": "123"}) - assert six.text_type(err) == u"Request 123: " + assert six.text_type(err) == "Request 123: " if six.PY2: assert str(err) == "Request 123: " else: @@ -32,14 +32,14 @@ def test_formatting_with_none(self): def test_formatting_with_message_none_and_request_id_none(self): err = error.TelnyxError(None) - assert six.text_type(err) == u"" + assert six.text_type(err) == "" if six.PY2: assert str(err) == "" else: - assert str(err) == u"" + assert str(err) == "" def test_repr(self): - err = error.TelnyxError(u"öre", http_headers={"request-id": "123"}) + err = error.TelnyxError("öre", http_headers={"request-id": "123"}) if six.PY2: assert ( repr(err) == "TelnyxError(message=u'\\xf6re', http_status=None, " diff --git a/tests/test_multipart_data_generator.py b/tests/test_multipart_data_generator.py index d04f2d5..77bffff 100644 --- a/tests/test_multipart_data_generator.py +++ b/tests/test_multipart_data_generator.py @@ -10,7 +10,7 @@ class TestMultipartDataGenerator(object): def run_test_multipart_data_with_file(self, test_file): - params = {"key1": b"ASCII value", "key2": u"Üñìçôdé value", "key3": test_file} + params = {"key1": b"ASCII value", "key2": "Üñìçôdé value", "key3": test_file} generator = MultipartDataGenerator() generator.add_params(params) http_body = generator.get_post_data() diff --git a/tests/test_telnyx_object.py b/tests/test_telnyx_object.py index abe0799..e478b22 100644 --- a/tests/test_telnyx_object.py +++ b/tests/test_telnyx_object.py @@ -138,7 +138,7 @@ def check_data(self, data): def test_repr(self): obj = telnyx.telnyx_object.TelnyxObject("foo", "bar", myparam=5) - obj["record_type"] = u"\u4e00boo\u1f00" + obj["record_type"] = "\u4e00boo\u1f00" obj.date = datetime.datetime.fromtimestamp(1511136000) res = repr(obj) @@ -146,9 +146,9 @@ def test_repr(self): if six.PY2: res = six.text_type(repr(obj), "utf-8") - assert u"