Skip to content

Commit e6c4dcb

Browse files
committed
add unit and smoke tests
1 parent d1577ed commit e6c4dcb

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Unit tests for Bandwidth::MultiChannelApi
2+
describe 'MultiChannelApi' do
3+
before(:all) do
4+
Bandwidth.configure do |config|
5+
config.username = BW_USERNAME
6+
config.password = BW_PASSWORD
7+
end
8+
@multi_channel_api_instance = Bandwidth::MultiChannelApi.new
9+
10+
@expiration_time = (Time.now + 60).round.to_datetime.rfc3339
11+
end
12+
13+
# Create Multi-Channel Message
14+
describe 'create_multi_channel_message' do
15+
it 'creates a multi channel message' do
16+
message_body = Bandwidth::MultiChannelChannelListObject.new(
17+
from: BW_NUMBER,
18+
application_id: BW_MESSAGING_APPLICATION_ID,
19+
channel: Bandwidth::MultiChannelMessageChannelEnum::RBM,
20+
content: Bandwidth::MmsMessageContent.new(
21+
text: 'Hello, this is a test message.',
22+
)
23+
)
24+
multi_channel_message_request = Bandwidth::MultiChannelMessageRequest.new(
25+
to: USER_NUMBER,
26+
channel_list: [message_body],
27+
tag: 'tag',
28+
priority: 'high',
29+
expiration: @expiration_time,
30+
)
31+
32+
data, status_code = @multi_channel_api_instance.create_multi_channel_message_with_http_info(BW_ACCOUNT_ID, multi_channel_message_request)
33+
34+
expect(status_code).to eq(202)
35+
expect(data).to be_instance_of(Bandwidth::CreateMultiChannelMessageResponse)
36+
end
37+
38+
39+
end
40+
end
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Unit tests for Bandwidth::MultiChannelApi
2+
describe 'MultiChannelApi' do
3+
before(:all) do
4+
Bandwidth.configure do |config|
5+
config.debugging = true
6+
config.username = BW_USERNAME
7+
config.password = BW_PASSWORD
8+
config.ignore_operation_servers = true
9+
config.host = '127.0.0.1:4010'
10+
end
11+
@multi_channel_api_instance = Bandwidth::MultiChannelApi.new
12+
13+
@expiration_time = (Time.now + 60).round.to_datetime.rfc3339
14+
end
15+
16+
describe 'test an instance of MultiChannelApi' do
17+
it 'should create an instance of MultiChannelApi' do
18+
expect(@multi_channel_api_instance).to be_instance_of(Bandwidth::MultiChannelApi)
19+
end
20+
end
21+
22+
# Create Multi-Channel Message
23+
describe 'create_multi_channel_message' do
24+
it 'creates a multi channel message' do
25+
message_body = Bandwidth::MultiChannelChannelListObject.new(
26+
from: BW_NUMBER,
27+
application_id: BW_MESSAGING_APPLICATION_ID,
28+
channel: Bandwidth::MultiChannelMessageChannelEnum::MMS,
29+
content: Bandwidth::SmsMessageContent.new(
30+
text: 'Hello, this is a test message.',
31+
)
32+
# content: Bandwidth::MultiChannelChannelListObjectContent.build(
33+
# text: 'Hello, this is a test message.',
34+
# )
35+
)
36+
multi_channel_message_request = Bandwidth::MultiChannelMessageRequest.new(
37+
to: USER_NUMBER,
38+
channel_list: [message_body],
39+
tag: 'tag',
40+
priority: 'high',
41+
expiration: @expiration_time,
42+
)
43+
44+
data, status_code = @multi_channel_api_instance.create_multi_channel_message_with_http_info(BW_ACCOUNT_ID, multi_channel_message_request)
45+
46+
expect(status_code).to eq(202)
47+
expect(data).to be_instance_of(Bandwidth::CreateMultiChannelMessageResponse)
48+
end if false # skip because prism can't handle a oneOf with differing required fields
49+
50+
it 'causes an ArgumentError for a missing account_id' do
51+
expect {
52+
@multi_channel_api_instance.create_multi_channel_message(nil, {})
53+
}.to raise_error(ArgumentError)
54+
end
55+
56+
it 'causes an ArgumentError for a missing message_request' do
57+
expect {
58+
@multi_channel_api_instance.create_multi_channel_message(BW_ACCOUNT_ID, nil)
59+
}.to raise_error(ArgumentError)
60+
end
61+
end
62+
end

0 commit comments

Comments
 (0)