@@ -95,58 +95,58 @@ def test_create_message(self):
9595 )
9696 assert_that (api_response .time , instance_of (datetime ))
9797
98- # def test_create_message_bad_request(self):
99- # assert_that(calling(self.api_instance.create_message).with_args(
100- # self.account_id, self.invalid_message_request)), raises(ApiException)
101-
102- # def test_create_message_unauthorized(self):
103- # assert_that(calling(self.unauthorized_api_instance.create_message).with_args(
104- # self.account_id, self.invalid_message_request)), raises(UnauthorizedException)
105-
106- # @unittest.skip('The SDK catches incorrect content-type before making the request and attempts to create an ApiException,\
107- # but the creation of the exception fails since there is no response body. This should probably create some\
108- # kind of Client Exception instead, since this is not an actual API Exception.')
109- # def test_create_message_invalid_media(self):
110- # assert_that(calling(self.api_instance.create_message).with_args(
111- # self.account_id, self.message_request, _content_type='application/xml')), raises(ApiException)
112-
113- # def test_list_messages(self):
114- # message_direction = ListMessageDirectionEnum("OUTBOUND")
115-
116- # response = self.api_instance.list_messages_with_http_info(self.account_id, message_direction=message_direction)
117-
118- # assert_that(response.status_code, equal_to(200))
119-
120- # api_response = response.data
121- # assert_that(api_response, instance_of(MessagesList))
122- # assert_that(api_response, has_properties(
123- # 'total_count', greater_than(0),
124- # 'messages', instance_of(list)
125- # ))
126-
127- # assert_that(api_response.messages[0], instance_of(ListMessageItem))
128-
129- # message = api_response.messages[0]
130- # assert_that(message, has_properties(
131- # 'account_id', self.account_id,
132- # 'destination_tn', matches_regexp('^\\+[1-9]\\d{1,14}$'),
133- # 'message_direction', ListMessageDirectionEnum("OUTBOUND"),
134- # 'message_id', matches_regexp('^.+$'),
135- # 'message_status', instance_of(MessageStatusEnum),
136- # 'message_type', instance_of(MessageTypeEnum),
137- # 'segment_count', greater_than(0),
138- # 'source_tn', matches_regexp('^\\+[1-9]\\d{1,14}$'),
139- # 'calling_number_country_a3', equal_to('USA')
140- # ))
141- # assert_that(message.receive_time, instance_of(datetime))
142-
143- # def test_list_messages_bad_request(self):
144- # assert_that(calling(self.api_instance.list_messages).with_args(
145- # self.account_id), raises(ApiException))
146-
147- # def test_list_messages_unauthorized(self):
148- # assert_that(calling(self.unauthorized_api_instance.list_messages).with_args(
149- # self.account_id), raises(UnauthorizedException))
98+ def test_create_message_bad_request (self ):
99+ assert_that (calling (self .api_instance .create_message ).with_args (
100+ self .account_id , self .invalid_message_request )), raises (ApiException )
101+
102+ def test_create_message_unauthorized (self ):
103+ assert_that (calling (self .unauthorized_api_instance .create_message ).with_args (
104+ self .account_id , self .invalid_message_request )), raises (UnauthorizedException )
105+
106+ @unittest .skip ('The SDK catches incorrect content-type before making the request and attempts to create an ApiException,\
107+ but the creation of the exception fails since there is no response body. This should probably create some\
108+ kind of Client Exception instead, since this is not an actual API Exception.' )
109+ def test_create_message_invalid_media (self ):
110+ assert_that (calling (self .api_instance .create_message ).with_args (
111+ self .account_id , self .message_request , _content_type = 'application/xml' )), raises (ApiException )
112+
113+ def test_list_messages (self ):
114+ message_direction = ListMessageDirectionEnum ("OUTBOUND" )
115+
116+ response = self .api_instance .list_messages_with_http_info (self .account_id , message_direction = message_direction )
117+
118+ assert_that (response .status_code , equal_to (200 ))
119+
120+ api_response = response .data
121+ assert_that (api_response , instance_of (MessagesList ))
122+ assert_that (api_response , has_properties (
123+ 'total_count' , greater_than (0 ),
124+ 'messages' , instance_of (list )
125+ ))
126+
127+ assert_that (api_response .messages [0 ], instance_of (ListMessageItem ))
128+
129+ message = api_response .messages [0 ]
130+ assert_that (message , has_properties (
131+ 'account_id' , self .account_id ,
132+ 'destination_tn' , matches_regexp ('^\\ +[1-9]\\ d{1,14}$' ),
133+ 'message_direction' , ListMessageDirectionEnum ("OUTBOUND" ),
134+ 'message_id' , matches_regexp ('^.+$' ),
135+ 'message_status' , instance_of (MessageStatusEnum ),
136+ 'message_type' , instance_of (MessageTypeEnum ),
137+ 'segment_count' , greater_than (0 ),
138+ 'source_tn' , matches_regexp ('^\\ +[1-9]\\ d{1,14}$' ),
139+ 'calling_number_country_a3' , equal_to ('USA' )
140+ ))
141+ assert_that (message .receive_time , instance_of (datetime ))
142+
143+ def test_list_messages_bad_request (self ):
144+ assert_that (calling (self .api_instance .list_messages ).with_args (
145+ self .account_id ), raises (ApiException ))
146+
147+ def test_list_messages_unauthorized (self ):
148+ assert_that (calling (self .unauthorized_api_instance .list_messages ).with_args (
149+ self .account_id ), raises (UnauthorizedException ))
150150
151151
152152if __name__ == '__main__' :
0 commit comments