Skip to content

Commit 3128fa3

Browse files
committed
tfv unit and smoke tests
1 parent 3e7b713 commit 3128fa3

File tree

2 files changed

+347
-0
lines changed

2 files changed

+347
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Integration tests for Bandwidth::TollFreeVerificationApi
2+
describe 'TollFreeVerificationApi' do
3+
before(:all) do
4+
Bandwidth.configure do |config|
5+
config.username = BW_USERNAME
6+
config.password = BW_PASSWORD
7+
end
8+
@tfv_api_instance = Bandwidth::TollFreeVerificationApi.new
9+
end
10+
11+
# Create Webhook Subscription
12+
describe 'create_webhook_subscription test' do
13+
it 'creates webhook subscription' do
14+
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
15+
end
16+
end
17+
18+
# Delete Webhook Subscription
19+
describe 'delete_webhook_subscription test' do
20+
it 'deletes webhook subscription' do
21+
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
22+
end
23+
end
24+
25+
# Get Toll-Free Verification Status
26+
describe 'get_toll_free_verification_status test' do
27+
it 'gets toll free verification status' do
28+
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
29+
end
30+
end
31+
32+
# List Toll-Free Use Cases
33+
describe 'list_toll_free_use_cases test' do
34+
it 'lists toll free use cases' do
35+
data, status_code = @tfv_api_instance.list_toll_free_use_cases_with_http_info
36+
37+
expect(status_code).to eq(200)
38+
expect(data).to be_instance_of(Array)
39+
end
40+
end
41+
42+
# List Webhook Subscriptions
43+
describe 'list_webhook_subscriptions test' do
44+
it 'lists webhook subscriptions' do
45+
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
46+
end
47+
end
48+
49+
# Request Toll-Free Verification
50+
describe 'request_toll_free_verification test' do
51+
it 'requests toll free verification' do
52+
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
53+
end
54+
end
55+
56+
# Update Toll-Free Verification Request
57+
describe 'update_toll_free_verification_request test' do
58+
it 'updates toll free verification request' do
59+
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
60+
end
61+
end
62+
63+
# Update Webhook Subscription
64+
describe 'update_webhook_subscription test' do
65+
it 'updates webhook subscription' do
66+
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
67+
end
68+
end
69+
end
Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,278 @@
1+
# Unit tests for Bandwidth::TollFreeVerificationApi
2+
describe 'TollFreeVerificationApi' do
3+
let (:webhook_subscription_request_schema) { Bandwidth::WebhookSubscriptionRequestSchema.new(
4+
basic_authentication: {
5+
username: 'username',
6+
password: 'password'
7+
},
8+
callback_url: 'https://example.com',
9+
shared_secret_key: 'shared-secret-key'
10+
) }
11+
let (:verification) { {
12+
business_address: Bandwidth::Address.new(
13+
name: 'name',
14+
addr1: 'addr1',
15+
addr2: 'addr2',
16+
city: 'city',
17+
state: 'state',
18+
zip: 'zip',
19+
url: 'https://example.com'
20+
),
21+
business_contact: Bandwidth::Contact.new(
22+
first_name: 'first-name',
23+
last_name: 'last-name',
24+
25+
phone_number: '+19195551234'
26+
),
27+
message_volume: 12,
28+
use_case: 'useCase',
29+
use_case_summary: 'useCaseSummary',
30+
production_message_content: 'productionMessageContent',
31+
opt_in_workflow: Bandwidth::OptInWorkflow.new(
32+
description: 'description',
33+
image_urls: ['https://example.com']
34+
),
35+
additional_information: 'additionalInformation',
36+
isv_reseller: 'isvReseller'
37+
} }
38+
let (:subscription_id) { 'test-id-1234' }
39+
let (:tf_phone_number) { '+18005551234' }
40+
41+
before(:all) do
42+
Bandwidth.configure do |config|
43+
config.debugging = true
44+
config.username = BW_USERNAME
45+
config.password = BW_PASSWORD
46+
config.ignore_operation_servers = true
47+
config.host = '127.0.0.1:4010'
48+
end
49+
@tfv_api_instance = Bandwidth::TollFreeVerificationApi.new
50+
end
51+
52+
describe 'test an instance of TollFreeVerificationApi' do
53+
it 'should create an instance of TollFreeVerificationApi' do
54+
expect(@tfv_api_instance).to be_instance_of(Bandwidth::TollFreeVerificationApi)
55+
end
56+
end
57+
58+
# Create Webhook Subscription
59+
describe 'create_webhook_subscription test' do
60+
it 'creates webhook subscription' do
61+
data, status_code = @tfv_api_instance.create_webhook_subscription_with_http_info(BW_ACCOUNT_ID, webhook_subscription_request_schema)
62+
63+
expect(status_code).to eq(201)
64+
expect(data).to be_instance_of(Bandwidth::WebhookSubscription)
65+
expect(data.id).to be_instance_of(String)
66+
expect(data.account_id.length).to eq(7)
67+
expect(data.callback_url).to be_instance_of(String)
68+
expect(data.type).to be_one_of(Bandwidth::WebhookSubscriptionTypeEnum.all_vars)
69+
expect(data.basic_authentication).to be_instance_of(Bandwidth::WebhookSubscriptionBasicAuthentication)
70+
expect(data.basic_authentication.username).to be_instance_of(String)
71+
expect(data.basic_authentication.password).to be_instance_of(String)
72+
expect(data.created_date).to be_instance_of(Time)
73+
expect(data.modified_date).to be_instance_of(Time)
74+
end
75+
76+
it 'causes an ArgumentError for a missing account_id' do
77+
expect {
78+
@tfv_api_instance.create_webhook_subscription(nil, {})
79+
}.to raise_error(ArgumentError)
80+
end
81+
82+
it 'causes an ArgumentError for a missing webhook_subscription_request_schema' do
83+
expect {
84+
@tfv_api_instance.create_webhook_subscription(BW_ACCOUNT_ID, nil)
85+
}.to raise_error(ArgumentError)
86+
end
87+
end
88+
89+
# Delete Webhook Subscription
90+
describe 'delete_webhook_subscription test' do
91+
it 'deletes webhook subscription' do
92+
_data, status_code = @tfv_api_instance.delete_webhook_subscription_with_http_info(BW_ACCOUNT_ID, subscription_id)
93+
94+
expect(status_code).to eq(204)
95+
end
96+
97+
it 'causes an ArgumentError for a missing account_id' do
98+
expect {
99+
@tfv_api_instance.delete_webhook_subscription(nil, subscription_id)
100+
}.to raise_error(ArgumentError)
101+
end
102+
103+
it 'causes an ArgumentError for a missing subscription_id' do
104+
expect {
105+
@tfv_api_instance.delete_webhook_subscription(BW_ACCOUNT_ID, nil)
106+
}.to raise_error(ArgumentError)
107+
end
108+
end
109+
110+
# Get Toll-Free Verification Status
111+
describe 'get_toll_free_verification_status test' do
112+
it 'gets toll free verification status' do
113+
data, status_code = @tfv_api_instance.get_toll_free_verification_status_with_http_info(BW_ACCOUNT_ID, tf_phone_number)
114+
115+
expect(status_code).to eq(200)
116+
expect(data).to be_instance_of(Bandwidth::TfvStatus)
117+
expect(data.phone_number).to be_instance_of(String)
118+
expect(data.status).to be_one_of(Bandwidth::TfvStatusEnum.all_vars)
119+
expect(data.internal_ticket_number).to be_instance_of(String)
120+
expect(data.decline_reason_description).to be_instance_of(String)
121+
expect(data.resubmit_allowed).to be_one_of([true, false])
122+
expect(data.created_date_time).to be_instance_of(Time)
123+
expect(data.modified_date_time).to be_instance_of(Time)
124+
end
125+
126+
it 'causes an ArgumentError for a missing account_id' do
127+
expect {
128+
@tfv_api_instance.get_toll_free_verification_status(nil, tf_phone_number)
129+
}.to raise_error(ArgumentError)
130+
end
131+
132+
it 'causes an ArgumentError for a missing phone_number' do
133+
expect {
134+
@tfv_api_instance.get_toll_free_verification_status(BW_ACCOUNT_ID, nil)
135+
}.to raise_error(ArgumentError)
136+
end
137+
end
138+
139+
# List Toll-Free Use Cases
140+
describe 'list_toll_free_use_cases test' do
141+
it 'lists toll free use cases' do
142+
data, status_code = @tfv_api_instance.list_toll_free_use_cases_with_http_info
143+
144+
expect(status_code).to eq(200)
145+
expect(data).to be_instance_of(Array)
146+
expect(data.length).to be > 0
147+
expect(data[0]).to be_instance_of(String)
148+
end
149+
end
150+
151+
# List Webhook Subscriptions
152+
describe 'list_webhook_subscriptions test' do
153+
it 'lists webhook subscriptions' do
154+
data, status_code = @tfv_api_instance.list_webhook_subscriptions_with_http_info(BW_ACCOUNT_ID)
155+
156+
expect(status_code).to eq(200)
157+
expect(data).to be_instance_of(Bandwidth::WebhookSubscriptionsListBody)
158+
expect(data.links).to be_instance_of(Bandwidth::LinksObject)
159+
expect(data.links.first).to be_instance_of(String)
160+
expect(data.links._next).to be_instance_of(String)
161+
expect(data.links.previous).to be_instance_of(String)
162+
expect(data.links.last).to be_instance_of(String)
163+
expect(data.errors).to be_instance_of(Array)
164+
expect(data.errors[0].code).to be_instance_of(Integer)
165+
expect(data.errors[0].description).to be_instance_of(String)
166+
expect(data.errors[0].telephone_numbers).to be_instance_of(Array)
167+
expect(data.errors[0].telephone_numbers[0]).to be_instance_of(Bandwidth::TelephoneNumber)
168+
expect(data.errors[0].telephone_numbers[0].telephone_number).to be_instance_of(String)
169+
expect(data.data).to be_instance_of(Array)
170+
expect(data.data[0]).to be_instance_of(Bandwidth::WebhookSubscription)
171+
expect(data.data[0].id).to be_instance_of(String)
172+
expect(data.data[0].account_id).to be_instance_of(String)
173+
expect(data.data[0].callback_url).to be_instance_of(String)
174+
expect(data.data[0].type).to be_one_of(Bandwidth::WebhookSubscriptionTypeEnum.all_vars)
175+
expect(data.data[0].basic_authentication).to be_instance_of(Bandwidth::WebhookSubscriptionBasicAuthentication)
176+
expect(data.data[0].basic_authentication.username).to be_instance_of(String)
177+
expect(data.data[0].basic_authentication.password).to be_instance_of(String)
178+
expect(data.data[0].created_date).to be_instance_of(Time)
179+
expect(data.data[0].modified_date).to be_instance_of(Time)
180+
end
181+
182+
it 'causes an ArgumentError for a missing account_id' do
183+
expect {
184+
@tfv_api_instance.list_webhook_subscriptions(nil)
185+
}.to raise_error(ArgumentError)
186+
end
187+
end
188+
189+
# Request Toll-Free Verification
190+
describe 'request_toll_free_verification test' do
191+
it 'requests toll free verification' do
192+
verification_request = Bandwidth::VerificationRequest.new(verification.merge(phone_numbers: [tf_phone_number]))
193+
_data, status_code = @tfv_api_instance.request_toll_free_verification_with_http_info(BW_ACCOUNT_ID, verification_request)
194+
195+
expect(status_code).to eq(202)
196+
end
197+
198+
it 'causes an ArgumentError for a missing account_id' do
199+
expect {
200+
@tfv_api_instance.request_toll_free_verification(nil, {})
201+
}.to raise_error(ArgumentError)
202+
end
203+
204+
it 'causes an ArgumentError for a missing verification_request' do
205+
expect {
206+
@tfv_api_instance.request_toll_free_verification(BW_ACCOUNT_ID, nil)
207+
}.to raise_error(ArgumentError)
208+
end
209+
end
210+
211+
# Update Toll-Free Verification Request
212+
describe 'update_toll_free_verification_request test' do
213+
it 'updates toll free verification request' do
214+
tfv_submission_wrapper = Bandwidth::TfvSubmissionWrapper.new(
215+
submission: Bandwidth::VerificationUpdateRequest.new(verification)
216+
)
217+
218+
_data, status_code = @tfv_api_instance.update_toll_free_verification_request_with_http_info(BW_ACCOUNT_ID, tf_phone_number, tfv_submission_wrapper)
219+
220+
expect(status_code).to eq(202)
221+
end
222+
223+
it 'causes an ArgumentError for a missing account_id' do
224+
expect {
225+
@tfv_api_instance.update_toll_free_verification_request(nil, tf_phone_number, {})
226+
}.to raise_error(ArgumentError)
227+
end
228+
229+
it 'causes an ArgumentError for a missing phone_number' do
230+
expect {
231+
@tfv_api_instance.update_toll_free_verification_request(BW_ACCOUNT_ID, nil, {})
232+
}.to raise_error(ArgumentError)
233+
end
234+
235+
it 'causes an ArgumentError for a missing tfv_submission_wrapper' do
236+
expect {
237+
@tfv_api_instance.update_toll_free_verification_request(BW_ACCOUNT_ID, tf_phone_number, nil)
238+
}.to raise_error(ArgumentError)
239+
end
240+
end
241+
242+
# Update Webhook Subscription
243+
describe 'update_webhook_subscription test' do
244+
it 'updates webhook subscription' do
245+
data, status_code = @tfv_api_instance.update_webhook_subscription_with_http_info(BW_ACCOUNT_ID, subscription_id, webhook_subscription_request_schema)
246+
247+
expect(status_code).to eq(200)
248+
expect(data).to be_instance_of(Bandwidth::WebhookSubscription)
249+
expect(data.id).to be_instance_of(String)
250+
expect(data.account_id.length).to eq(7)
251+
expect(data.callback_url).to be_instance_of(String)
252+
expect(data.type).to be_one_of(Bandwidth::WebhookSubscriptionTypeEnum.all_vars)
253+
expect(data.basic_authentication).to be_instance_of(Bandwidth::WebhookSubscriptionBasicAuthentication)
254+
expect(data.basic_authentication.username).to be_instance_of(String)
255+
expect(data.basic_authentication.password).to be_instance_of(String)
256+
expect(data.created_date).to be_instance_of(Time)
257+
expect(data.modified_date).to be_instance_of(Time)
258+
end
259+
260+
it 'causes an ArgumentError for a missing account_id' do
261+
expect {
262+
@tfv_api_instance.update_webhook_subscription(nil, subscription_id, {})
263+
}.to raise_error(ArgumentError)
264+
end
265+
266+
it 'causes an ArgumentError for a missing subscription_id' do
267+
expect {
268+
@tfv_api_instance.update_webhook_subscription(BW_ACCOUNT_ID, nil, {})
269+
}.to raise_error(ArgumentError)
270+
end
271+
272+
it 'causes an ArgumentError for a missing webhook_subscription_request_schema' do
273+
expect {
274+
@tfv_api_instance.update_webhook_subscription(BW_ACCOUNT_ID, subscription_id, nil)
275+
}.to raise_error(ArgumentError)
276+
end
277+
end
278+
end

0 commit comments

Comments
 (0)