-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest_endpoints_api.py
More file actions
171 lines (137 loc) · 6.96 KB
/
test_endpoints_api.py
File metadata and controls
171 lines (137 loc) · 6.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# coding: utf-8
"""
Bandwidth
Bandwidth's Communication APIs
The version of the OpenAPI document: 1.0.0
Contact: letstalk@bandwidth.com
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
import unittest
from datetime import datetime
from hamcrest import *
from test.utils.env_variables import *
from bandwidth import ApiClient, Configuration
from bandwidth.api.endpoints_api import EndpointsApi
from bandwidth.models.create_web_rtc_connection_request import CreateWebRtcConnectionRequest
from bandwidth.models.create_endpoint_response import CreateEndpointResponse
from bandwidth.models.create_endpoint_response_data import CreateEndpointResponseData
from bandwidth.models.endpoint_response import EndpointResponse
from bandwidth.models.endpoint import Endpoint
from bandwidth.models.endpoints import Endpoints
from bandwidth.models.list_endpoints_response import ListEndpointsResponse
from bandwidth.models.link import Link
from bandwidth.models.page import Page
from bandwidth.models.endpoint_type_enum import EndpointTypeEnum
from bandwidth.models.endpoint_direction_enum import EndpointDirectionEnum
from bandwidth.models.endpoint_status_enum import EndpointStatusEnum
class TestEndpointsApi(unittest.TestCase):
"""EndpointsApi unit test stubs"""
@classmethod
def setUpClass(cls) -> None:
configuration = Configuration(
client_id=BW_CLIENT_ID,
client_secret=BW_CLIENT_SECRET,
host='http://127.0.0.1:4010',
ignore_operation_servers=True
)
api_client = ApiClient(configuration)
cls.endpoints_api_instance = EndpointsApi(api_client)
def test_create_endpoint(self) -> None:
"""Test case for create_endpoint
Create Endpoint
"""
endpoint_body = CreateWebRtcConnectionRequest(
type=EndpointTypeEnum.WEBRTC,
direction=EndpointDirectionEnum.INBOUND,
event_callback_url="https://myServer.com/bandwidth/webhooks/endpoint",
event_fallback_url="https://myFallbackServer.com/bandwidth/webhooks/endpoint",
tag="test-endpoint",
connection_metadata={
"key1": "value1",
"key2": "value2"
}
)
response = self.endpoints_api_instance.create_endpoint_with_http_info(
BW_ACCOUNT_ID,
endpoint_body
)
assert_that(response.status_code, equal_to(201))
assert_that(response.data, instance_of(CreateEndpointResponse))
assert_that(response.data.links, instance_of(list))
assert_that(response.data.links[0], instance_of(Link))
assert_that(response.data.links[0].href, starts_with('http'))
assert_that(response.data.links[0].rel, equal_to('endpoint'))
assert_that(response.data.data, instance_of(CreateEndpointResponseData))
assert_that(response.data.data.endpoint_id, equal_to('e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85'))
assert_that(response.data.data.type, is_in(EndpointTypeEnum))
assert_that(response.data.data.status, is_in(EndpointStatusEnum))
assert_that(response.data.data.creation_timestamp, instance_of(datetime))
assert_that(response.data.data.expiration_timestamp, instance_of(datetime))
assert_that(response.data.data.token, instance_of(str))
assert_that(response.data.data.tag, instance_of(str))
assert_that(response.data.data.devices, instance_of(list))
assert_that(response.data.errors, instance_of(list))
def test_delete_endpoint(self) -> None:
"""Test case for delete_endpoint
Delete Endpoint
"""
response = self.endpoints_api_instance.delete_endpoint_with_http_info(
BW_ACCOUNT_ID,
"ep-abc123"
)
assert_that(response.status_code, equal_to(204))
def test_get_endpoint(self) -> None:
"""Test case for get_endpoint
Get Endpoint
"""
response = self.endpoints_api_instance.get_endpoint_with_http_info(
BW_ACCOUNT_ID,
"ep-abc123"
)
assert_that(response.status_code, equal_to(200))
assert_that(response.data, instance_of(EndpointResponse))
assert_that(response.data.links, instance_of(list))
assert_that(response.data.links[0], instance_of(Link))
assert_that(response.data.links[0].href, starts_with('http'))
assert_that(response.data.links[0].rel, equal_to('self'))
assert_that(response.data.data, instance_of(Endpoint))
assert_that(response.data.data.endpoint_id, equal_to('e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85'))
assert_that(response.data.data.type, is_in(EndpointTypeEnum))
assert_that(response.data.data.status, is_in(EndpointStatusEnum))
assert_that(response.data.data.creation_timestamp, instance_of(datetime))
assert_that(response.data.data.expiration_timestamp, instance_of(datetime))
assert_that(response.data.data.tag, instance_of(str))
assert_that(response.data.data.devices, instance_of(list))
assert_that(response.data.errors, instance_of(list))
def test_list_endpoints(self) -> None:
"""Test case for list_endpoints
List Endpoints
"""
response = self.endpoints_api_instance.list_endpoints_with_http_info(
BW_ACCOUNT_ID
)
assert_that(response.status_code, equal_to(200))
assert_that(response.data, instance_of(ListEndpointsResponse))
assert_that(response.data.links, instance_of(list))
assert_that(response.data.links[0], instance_of(Link))
assert_that(response.data.links[0].href, starts_with('http'))
assert_that(response.data.links[0].rel, equal_to('self'))
assert_that(response.data.page, instance_of(Page))
assert_that(response.data.page.page_size, equal_to(2))
assert_that(response.data.page.total_elements, equal_to(10))
assert_that(response.data.page.total_pages, equal_to(5))
assert_that(response.data.page.page_number, equal_to(0))
assert_that(response.data.data, instance_of(list))
assert_that(response.data.data[0], instance_of(Endpoints))
assert_that(response.data.data[0].endpoint_id, equal_to('e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85'))
assert_that(response.data.data[0].type, is_in(EndpointTypeEnum))
assert_that(response.data.data[0].status, is_in(EndpointStatusEnum))
assert_that(response.data.data[0].tag, instance_of(str))
assert_that(response.data.data[0].creation_timestamp, instance_of(datetime))
assert_that(response.data.data[0].expiration_timestamp, instance_of(datetime))
assert_that(response.data.data[1].endpoint_id, equal_to('e-2cb0-4a07-b215-b22865662d85-15ac29a2-1331029c'))
assert_that(response.data.data[1].tag, instance_of(str))
assert_that(response.data.errors, instance_of(list))
if __name__ == '__main__':
unittest.main()