|
| 1 | +# coding: utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | + Bandwidth |
| 5 | +
|
| 6 | + Bandwidth's Communication APIs |
| 7 | +
|
| 8 | + The version of the OpenAPI document: 1.0.0 |
| 9 | + Contact: letstalk@bandwidth.com |
| 10 | + Generated by OpenAPI Generator (https://openapi-generator.tech) |
| 11 | +
|
| 12 | + Do not edit the class manually. |
| 13 | +""" # noqa: E501 |
| 14 | + |
| 15 | + |
| 16 | +import unittest |
| 17 | +from datetime import datetime |
| 18 | + |
| 19 | +from hamcrest import * |
| 20 | +from test.utils.env_variables import * |
| 21 | +from bandwidth import ApiClient, Configuration |
| 22 | +from bandwidth.api.endpoints_api import EndpointsApi |
| 23 | +from bandwidth.models.create_web_rtc_connection_request import CreateWebRtcConnectionRequest |
| 24 | +from bandwidth.models.create_endpoint_response import CreateEndpointResponse |
| 25 | +from bandwidth.models.endpoint_response import EndpointResponse |
| 26 | +from bandwidth.models.list_endpoints_response import ListEndpointsResponse |
| 27 | +from bandwidth.models.endpoint_type_enum import EndpointTypeEnum |
| 28 | +from bandwidth.models.endpoint_direction_enum import EndpointDirectionEnum |
| 29 | +from bandwidth.models.endpoint_status_enum import EndpointStatusEnum |
| 30 | + |
| 31 | + |
| 32 | +class TestEndpointsApi(unittest.TestCase): |
| 33 | + """EndpointsApi unit test stubs""" |
| 34 | + |
| 35 | + @classmethod |
| 36 | + def setUpClass(cls) -> None: |
| 37 | + configuration = Configuration( |
| 38 | + client_id=BW_CLIENT_ID, |
| 39 | + client_secret=BW_CLIENT_SECRET, |
| 40 | + host='http://127.0.0.1:4010', |
| 41 | + ignore_operation_servers=True |
| 42 | + ) |
| 43 | + api_client = ApiClient(configuration) |
| 44 | + cls.endpoints_api_instance = EndpointsApi(api_client) |
| 45 | + |
| 46 | + def test_create_endpoint(self) -> None: |
| 47 | + """Test case for create_endpoint |
| 48 | +
|
| 49 | + Create Endpoint |
| 50 | + """ |
| 51 | + endpoint_body = CreateWebRtcConnectionRequest( |
| 52 | + type=EndpointTypeEnum("webrtc"), |
| 53 | + direction=EndpointDirectionEnum("inbound"), |
| 54 | + event_callback_url="https://myServer.com/bandwidth/webhooks/endpoint", |
| 55 | + event_fallback_url="https://myFallbackServer.com/bandwidth/webhooks/endpoint", |
| 56 | + tag="test-endpoint", |
| 57 | + connection_metadata={ |
| 58 | + "key1": "value1", |
| 59 | + "key2": "value2" |
| 60 | + } |
| 61 | + ) |
| 62 | + response = self.endpoints_api_instance.create_endpoint_with_http_info( |
| 63 | + BW_ACCOUNT_ID, |
| 64 | + endpoint_body |
| 65 | + ) |
| 66 | + |
| 67 | + assert_that(response.status_code, equal_to(201)) |
| 68 | + assert_that(response.data, instance_of(CreateEndpointResponse)) |
| 69 | + assert_that(response.data.links, instance_of(list)) |
| 70 | + assert_that(response.data.data, instance_of(object)) |
| 71 | + assert_that(response.data.errors, instance_of(list)) |
| 72 | + |
| 73 | + def test_delete_endpoint(self) -> None: |
| 74 | + """Test case for delete_endpoint |
| 75 | +
|
| 76 | + Delete Endpoint |
| 77 | + """ |
| 78 | + response = self.endpoints_api_instance.delete_endpoint_with_http_info( |
| 79 | + BW_ACCOUNT_ID, |
| 80 | + "ep-abc123" |
| 81 | + ) |
| 82 | + |
| 83 | + assert_that(response.status_code, equal_to(204)) |
| 84 | + |
| 85 | + def test_get_endpoint(self) -> None: |
| 86 | + """Test case for get_endpoint |
| 87 | +
|
| 88 | + Get Endpoint |
| 89 | + """ |
| 90 | + response = self.endpoints_api_instance.get_endpoint_with_http_info( |
| 91 | + BW_ACCOUNT_ID, |
| 92 | + "ep-abc123" |
| 93 | + ) |
| 94 | + |
| 95 | + assert_that(response.status_code, equal_to(200)) |
| 96 | + assert_that(response.data, instance_of(EndpointResponse)) |
| 97 | + assert_that(response.data.links, instance_of(list)) |
| 98 | + assert_that(response.data.data, instance_of(object)) |
| 99 | + assert_that(response.data.errors, instance_of(list)) |
| 100 | + |
| 101 | + def test_list_endpoints(self) -> None: |
| 102 | + """Test case for list_endpoints |
| 103 | +
|
| 104 | + List Endpoints |
| 105 | + """ |
| 106 | + response = self.endpoints_api_instance.list_endpoints_with_http_info( |
| 107 | + BW_ACCOUNT_ID |
| 108 | + ) |
| 109 | + |
| 110 | + assert_that(response.status_code, equal_to(200)) |
| 111 | + assert_that(response.data, instance_of(ListEndpointsResponse)) |
| 112 | + assert_that(response.data.links, instance_of(list)) |
| 113 | + assert_that(response.data.data, instance_of(list)) |
| 114 | + assert_that(response.data.errors, instance_of(list)) |
| 115 | + |
| 116 | + def test_list_endpoints_with_filters(self) -> None: |
| 117 | + """Test case for list_endpoints with filters |
| 118 | +
|
| 119 | + List Endpoints with Type and Status Filters |
| 120 | + """ |
| 121 | + response = self.endpoints_api_instance.list_endpoints_with_http_info( |
| 122 | + BW_ACCOUNT_ID, |
| 123 | + type=EndpointTypeEnum("webrtc"), |
| 124 | + status=EndpointStatusEnum("active"), |
| 125 | + limit=100 |
| 126 | + ) |
| 127 | + |
| 128 | + assert_that(response.status_code, equal_to(200)) |
| 129 | + assert_that(response.data, instance_of(ListEndpointsResponse)) |
| 130 | + assert_that(response.data.links, instance_of(list)) |
| 131 | + assert_that(response.data.data, instance_of(list)) |
| 132 | + assert_that(response.data.errors, instance_of(list)) |
| 133 | + if response.data.page: |
| 134 | + assert_that(response.data.page, instance_of(object)) |
| 135 | + |
| 136 | + def test_list_endpoints_with_pagination(self) -> None: |
| 137 | + """Test case for list_endpoints with pagination |
| 138 | +
|
| 139 | + List Endpoints with Pagination |
| 140 | + """ |
| 141 | + response = self.endpoints_api_instance.list_endpoints_with_http_info( |
| 142 | + BW_ACCOUNT_ID, |
| 143 | + after_cursor="cursor-abc123", |
| 144 | + limit=50 |
| 145 | + ) |
| 146 | + |
| 147 | + assert_that(response.status_code, equal_to(200)) |
| 148 | + assert_that(response.data, instance_of(ListEndpointsResponse)) |
| 149 | + assert_that(response.data.links, instance_of(list)) |
| 150 | + assert_that(response.data.data, instance_of(list)) |
| 151 | + assert_that(response.data.errors, instance_of(list)) |
| 152 | + |
| 153 | + def test_update_endpoint_bxml(self) -> None: |
| 154 | + """Test case for update_endpoint_bxml |
| 155 | +
|
| 156 | + Update Endpoint BXML |
| 157 | + """ |
| 158 | + update_bxml = '<?xml version="1.0" encoding="UTF-8"?><Bxml><SpeakSentence locale="en_US" gender="female" voice="susan">This is a test bxml response for endpoint</SpeakSentence><Pause duration="3"/></Bxml>' |
| 159 | + |
| 160 | + response = self.endpoints_api_instance.update_endpoint_bxml_with_http_info( |
| 161 | + BW_ACCOUNT_ID, |
| 162 | + "ep-abc123", |
| 163 | + update_bxml |
| 164 | + ) |
| 165 | + |
| 166 | + assert_that(response.status_code, equal_to(204)) |
| 167 | + |
| 168 | + def test_create_endpoint_minimal(self) -> None: |
| 169 | + """Test case for create_endpoint with minimal required fields |
| 170 | +
|
| 171 | + Create Endpoint with Minimal Fields |
| 172 | + """ |
| 173 | + endpoint_body = CreateWebRtcConnectionRequest( |
| 174 | + type=EndpointTypeEnum("webrtc"), |
| 175 | + direction=EndpointDirectionEnum("outbound") |
| 176 | + ) |
| 177 | + response = self.endpoints_api_instance.create_endpoint_with_http_info( |
| 178 | + BW_ACCOUNT_ID, |
| 179 | + endpoint_body |
| 180 | + ) |
| 181 | + |
| 182 | + assert_that(response.status_code, equal_to(201)) |
| 183 | + assert_that(response.data, instance_of(CreateEndpointResponse)) |
| 184 | + |
| 185 | + def test_create_endpoint_sip(self) -> None: |
| 186 | + """Test case for create_endpoint with SIP type |
| 187 | +
|
| 188 | + Create SIP Endpoint |
| 189 | + """ |
| 190 | + endpoint_body = CreateWebRtcConnectionRequest( |
| 191 | + type=EndpointTypeEnum("sip"), |
| 192 | + direction=EndpointDirectionEnum("bidirectional"), |
| 193 | + event_callback_url="https://myServer.com/bandwidth/webhooks/sip-endpoint", |
| 194 | + tag="sip-test-endpoint" |
| 195 | + ) |
| 196 | + response = self.endpoints_api_instance.create_endpoint_with_http_info( |
| 197 | + BW_ACCOUNT_ID, |
| 198 | + endpoint_body |
| 199 | + ) |
| 200 | + |
| 201 | + assert_that(response.status_code, equal_to(201)) |
| 202 | + assert_that(response.data, instance_of(CreateEndpointResponse)) |
| 203 | + |
| 204 | + |
| 205 | +if __name__ == '__main__': |
| 206 | + unittest.main() |
0 commit comments