Skip to content

Commit 1edeb94

Browse files
committed
api unit and smoke tests
1 parent 33ee3e7 commit 1edeb94

File tree

2 files changed

+320
-0
lines changed

2 files changed

+320
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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+
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+
18+
from hamcrest import *
19+
from test.utils.env_variables import *
20+
from bandwidth import ApiClient, Configuration
21+
from bandwidth.api.toll_free_verification_api import TollFreeVerificationApi
22+
23+
24+
class TestTollFreeVerificationApi(unittest.TestCase):
25+
"""TollFreeVerificationApi unit test stubs"""
26+
27+
def setUp(self) -> None:
28+
configuration = Configuration(
29+
username=BW_USERNAME,
30+
password=BW_PASSWORD
31+
)
32+
self.api_client = ApiClient(configuration)
33+
self.api_instance = TollFreeVerificationApi(self.api_client)
34+
self.account_id = BW_ACCOUNT_ID
35+
36+
def test_create_webhook_subscription(self) -> None:
37+
"""Test case for create_webhook_subscription
38+
39+
Create Webhook Subscription
40+
"""
41+
pass
42+
43+
def test_delete_webhook_subscription(self) -> None:
44+
"""Test case for delete_webhook_subscription
45+
46+
Delete Webhook Subscription
47+
"""
48+
pass
49+
50+
def test_get_toll_free_verification_status(self) -> None:
51+
"""Test case for get_toll_free_verification_status
52+
53+
Get Toll-Free Verification Status
54+
"""
55+
pass
56+
57+
def test_list_toll_free_use_cases(self) -> None:
58+
"""Test case for list_toll_free_use_cases
59+
60+
List Toll-Free Use Cases
61+
"""
62+
api_response_with_http_info = self.api_instance.list_toll_free_use_cases_with_http_info()
63+
self.assertEqual(api_response_with_http_info.status_code, 200)
64+
65+
api_response = self.api_instance.list_toll_free_use_cases()
66+
self.assertIs(type(api_response), list)
67+
68+
def test_list_webhook_subscriptions(self) -> None:
69+
"""Test case for list_webhook_subscriptions
70+
71+
List Webhook Subscriptions
72+
"""
73+
pass
74+
75+
def test_request_toll_free_verification(self) -> None:
76+
"""Test case for request_toll_free_verification
77+
78+
Request Toll-Free Verification
79+
"""
80+
pass
81+
82+
def test_update_toll_free_verification_request(self) -> None:
83+
"""Test case for update_toll_free_verification_request
84+
85+
Update Toll-Free Verification Request
86+
"""
87+
pass
88+
89+
def test_update_webhook_subscription(self) -> None:
90+
"""Test case for update_webhook_subscription
91+
92+
Update Webhook Subscription
93+
"""
94+
pass
95+
96+
97+
if __name__ == '__main__':
98+
unittest.main()
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
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+
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.toll_free_verification_api import TollFreeVerificationApi
23+
from bandwidth.models.webhook_subscription_request_schema import WebhookSubscriptionRequestSchema
24+
from bandwidth.models.tfv_basic_authentication import TfvBasicAuthentication
25+
from bandwidth.models.webhook_subscription import WebhookSubscription
26+
from bandwidth.models.webhook_subscription_type_enum import WebhookSubscriptionTypeEnum
27+
from bandwidth.models.webhook_subscription_basic_authentication import WebhookSubscriptionBasicAuthentication
28+
from bandwidth.models.tfv_status import TfvStatus
29+
from bandwidth.models.tfv_status_enum import TfvStatusEnum
30+
from bandwidth.models.webhook_subscriptions_list_body import WebhookSubscriptionsListBody
31+
from bandwidth.models.links_object import LinksObject
32+
from bandwidth.models.telephone_number import TelephoneNumber
33+
from bandwidth.models.address import Address
34+
from bandwidth.models.contact import Contact
35+
from bandwidth.models.opt_in_workflow import OptInWorkflow
36+
from bandwidth.models.verification_request import VerificationRequest
37+
from bandwidth.models.tfv_submission_wrapper import TfvSubmissionWrapper
38+
39+
40+
class TestTollFreeVerificationApi(unittest.TestCase):
41+
"""TollFreeVerificationApi unit test stubs"""
42+
43+
def setUp(self) -> None:
44+
configuration = Configuration(
45+
username=BW_USERNAME,
46+
password=BW_PASSWORD,
47+
host='http://127.0.0.1:4010',
48+
ignore_operation_servers=True
49+
)
50+
api_client = ApiClient(configuration)
51+
self.tfv_api_instance = TollFreeVerificationApi(api_client)
52+
53+
self.subscription_id = 'test-id-1234'
54+
self.tf_phone_number = '+18005551234'
55+
56+
self.webhook_subscription_request_schema = WebhookSubscriptionRequestSchema(
57+
basic_authentication=TfvBasicAuthentication(
58+
username='username',
59+
password='password'
60+
),
61+
callback_url='https://example.com',
62+
shared_secret_key='shared-secret-key'
63+
)
64+
65+
self.verification = {
66+
'businessAddress': Address(
67+
name='name',
68+
addr1='addr1',
69+
addr2='addr2',
70+
city='city',
71+
state='state',
72+
zip='zip',
73+
url='https://example.com'
74+
),
75+
'businessContact': Contact(
76+
firstName='first-name',
77+
lastName='last-name',
78+
79+
phoneNumber='+19195551234'
80+
),
81+
'messageVolume': 12,
82+
'useCase': 'useCase',
83+
'useCaseSummary': 'useCaseSummary',
84+
'productionMessageContent': 'productionMessageContent',
85+
'optInWorkflow': OptInWorkflow(
86+
description='description',
87+
image_urls=['https://example.com']
88+
),
89+
'additionalInformation': 'additionalInformation',
90+
'isvReseller': 'isvReseller'
91+
}
92+
93+
def test_create_webhook_subscription(self) -> None:
94+
"""Test case for create_webhook_subscription
95+
96+
Create Webhook Subscription
97+
"""
98+
response = self.tfv_api_instance.create_webhook_subscription_with_http_info(BW_ACCOUNT_ID, self.webhook_subscription_request_schema)
99+
100+
assert_that(response.status_code, equal_to(201))
101+
assert_that(response.data, instance_of(WebhookSubscription))
102+
assert_that(response.data.id, instance_of(str))
103+
assert_that(response.data.account_id, has_length(7))
104+
assert_that(response.data.callback_url, instance_of(str))
105+
assert_that(response.data.type, is_in(WebhookSubscriptionTypeEnum))
106+
assert_that(response.data.basic_authentication, instance_of(WebhookSubscriptionBasicAuthentication))
107+
assert_that(response.data.basic_authentication.username, instance_of(str))
108+
assert_that(response.data.basic_authentication.password, instance_of(str))
109+
assert_that(response.data.created_date, instance_of(datetime))
110+
assert_that(response.data.modified_date, instance_of(datetime))
111+
112+
def test_delete_webhook_subscription(self) -> None:
113+
"""Test case for delete_webhook_subscription
114+
115+
Delete Webhook Subscription
116+
"""
117+
response = self.tfv_api_instance.delete_webhook_subscription_with_http_info(BW_ACCOUNT_ID, self.subscription_id)
118+
119+
assert_that(response.status_code, equal_to(204))
120+
121+
def test_get_toll_free_verification_status(self) -> None:
122+
"""Test case for get_toll_free_verification_status
123+
124+
Get Toll-Free Verification Status
125+
"""
126+
response = self.tfv_api_instance.get_toll_free_verification_status_with_http_info(BW_ACCOUNT_ID, self.tf_phone_number)
127+
128+
assert_that(response.status_code, equal_to(200))
129+
assert_that(response.data, instance_of(TfvStatus))
130+
assert_that(response.data.phone_number, instance_of(str))
131+
assert_that(response.data.status, is_in(TfvStatusEnum))
132+
assert_that(response.data.internal_ticket_number, instance_of(str))
133+
assert_that(response.data.decline_reason_description, instance_of(str))
134+
assert_that(response.data.resubmit_allowed, instance_of(bool))
135+
assert_that(response.data.created_date_time, instance_of(datetime))
136+
assert_that(response.data.modified_date_time, instance_of(datetime))
137+
138+
def test_list_toll_free_use_cases(self) -> None:
139+
"""Test case for list_toll_free_use_cases
140+
141+
List Toll-Free Use Cases
142+
"""
143+
response = self.tfv_api_instance.list_toll_free_use_cases_with_http_info()
144+
145+
assert_that(response.status_code, equal_to(200))
146+
assert_that(response.data, instance_of(list))
147+
assert_that(response.data[0], instance_of(str))
148+
149+
def test_list_webhook_subscriptions(self) -> None:
150+
"""Test case for list_webhook_subscriptions
151+
152+
List Webhook Subscriptions
153+
"""
154+
response = self.tfv_api_instance.list_webhook_subscriptions_with_http_info(BW_ACCOUNT_ID)
155+
156+
assert_that(response.status_code, equal_to(200))
157+
assert_that(response.data, instance_of(WebhookSubscriptionsListBody))
158+
assert_that(response.data.links, instance_of(LinksObject))
159+
assert_that(response.data.links.first, instance_of(str))
160+
assert_that(response.data.links.next, instance_of(str))
161+
assert_that(response.data.links.previous, instance_of(str))
162+
assert_that(response.data.links.last, instance_of(str))
163+
assert_that(response.data.errors, instance_of(list))
164+
assert_that(response.data.errors[0].code, instance_of(int))
165+
assert_that(response.data.errors[0].description, instance_of(str))
166+
assert_that(response.data.errors[0].telephone_numbers, instance_of(list))
167+
assert_that(response.data.errors[0].telephone_numbers[0], instance_of(TelephoneNumber))
168+
assert_that(response.data.errors[0].telephone_numbers[0].telephone_number, instance_of(str))
169+
assert_that(response.data.data, instance_of(list))
170+
assert_that(response.data.data[0], instance_of(WebhookSubscription))
171+
assert_that(response.data.data[0].id, instance_of(str))
172+
assert_that(response.data.data[0].account_id, instance_of(str))
173+
assert_that(response.data.data[0].callback_url, instance_of(str))
174+
assert_that(response.data.data[0].type, is_in(WebhookSubscriptionTypeEnum))
175+
assert_that(response.data.data[0].basic_authentication, instance_of(WebhookSubscriptionBasicAuthentication))
176+
assert_that(response.data.data[0].basic_authentication.username, instance_of(str))
177+
assert_that(response.data.data[0].basic_authentication.password, instance_of(str))
178+
assert_that(response.data.data[0].created_date, instance_of(datetime))
179+
assert_that(response.data.data[0].modified_date, instance_of(datetime))
180+
181+
def test_request_toll_free_verification(self) -> None:
182+
"""Test case for request_toll_free_verification
183+
184+
Request Toll-Free Verification
185+
"""
186+
verification_request = VerificationRequest.from_dict(self.verification | { 'phoneNumbers': [self.tf_phone_number] })
187+
response = self.tfv_api_instance.request_toll_free_verification_with_http_info(BW_ACCOUNT_ID, verification_request)
188+
189+
assert_that(response.status_code, equal_to(202))
190+
191+
def test_update_toll_free_verification_request(self) -> None:
192+
"""Test case for update_toll_free_verification_request
193+
194+
Update Toll-Free Verification Request
195+
"""
196+
tfv_submission_wrapper = TfvSubmissionWrapper.from_dict({ 'submission': self.verification })
197+
response = self.tfv_api_instance.update_toll_free_verification_request_with_http_info(BW_ACCOUNT_ID, self.tf_phone_number, tfv_submission_wrapper)
198+
199+
assert_that(response.status_code, equal_to(202))
200+
201+
def test_update_webhook_subscription(self) -> None:
202+
"""Test case for update_webhook_subscription
203+
204+
Update Webhook Subscription
205+
"""
206+
response = self.tfv_api_instance.update_webhook_subscription_with_http_info(BW_ACCOUNT_ID, self.subscription_id, self.webhook_subscription_request_schema)
207+
208+
assert_that(response.status_code, equal_to(200))
209+
assert_that(response.data, instance_of(WebhookSubscription))
210+
assert_that(response.data.id, instance_of(str))
211+
assert_that(response.data.account_id, has_length(7))
212+
assert_that(response.data.callback_url, instance_of(str))
213+
assert_that(response.data.type, is_in(WebhookSubscriptionTypeEnum))
214+
assert_that(response.data.basic_authentication, instance_of(WebhookSubscriptionBasicAuthentication))
215+
assert_that(response.data.basic_authentication.username, instance_of(str))
216+
assert_that(response.data.basic_authentication.password, instance_of(str))
217+
assert_that(response.data.created_date, instance_of(datetime))
218+
assert_that(response.data.modified_date, instance_of(datetime))
219+
220+
221+
if __name__ == '__main__':
222+
unittest.main()

0 commit comments

Comments
 (0)