1717from bandwidth .model .tn_lookup_request_error import TnLookupRequestError
1818from bandwidth .exceptions import ApiException , UnauthorizedException , ForbiddenException
1919
20+ from hamcrest .core import *
21+ from hamcrest .library import *
22+
23+ from .bwmatchers .one_of_string import is_one_of_string
24+
2025
2126class TestPhoneNumberLookupIntegration (unittest .TestCase ):
2227 """Phone Number Lookup API integration test
@@ -39,19 +44,21 @@ def validateResult(self, result: LookupResult, e_164_format: str, line_provider:
3944 e_164_format (str): Phone number in e164 format ex: +19195551234
4045 line_provider (str): Line service provider ex: Verizon
4146 """
42- self .assertEqual (result .response_code , 0 )
43- self .assertIs (type (result .message ), str )
44- self .assertEqual (result .e_164_format , e_164_format )
45- self .assertIs (type (result .formatted ), str )
46- self .assertTrue (result .country == "US" or result .country == "Canada" )
47- self .assertTrue (result .line_type == "Mobile" or result .line_type == "Fixed" )
48- self .assertIn (line_provider , result .line_provider )
4947
5048 # if result has 1 of these attributes it should have the other
5149 if result .get ('mobile_country_code' ) or result .get ('mobile_network_code' ):
5250 self .assertIs (type (result .mobile_country_code ), str )
5351 self .assertIs (type (result .mobile_network_code ), str )
5452
53+ assert_that (result , has_properties (
54+ 'response_code' , 0 ,
55+ 'e_164_format' , e_164_format ,
56+ 'line_provider' , contains_string (line_provider ),
57+ 'country' , is_one_of_string (["US" , "Canada" ]),
58+ 'line_type' , is_one_of_string (["Mobile" , "Fixed" ])
59+ )
60+ )
61+
5562 def pollLookupStatus (self , request_id : str ) -> LookupStatus :
5663 """Poll LookupRequest for 'COMPLETE' status
5764
@@ -109,6 +116,7 @@ def testSuccessfulPhoneNumberLookup(self) -> None:
109116 # Create the lookup request and validate the response
110117 create_lookup_response : CreateLookupResponse = self .api_instance .create_lookup (
111118 self .account_id , lookup_request , _return_http_data_only = False )
119+
112120 self .assertEqual (create_lookup_response [1 ], 202 )
113121 self .assertIs (type (create_lookup_response [0 ].status ), LookupStatusEnum )
114122 self .assertEqual (create_lookup_response [0 ].status , LookupStatusEnum ("IN_PROGRESS" ))
@@ -135,7 +143,7 @@ def testSuccessfulPhoneNumberLookup(self) -> None:
135143
136144 # Check the information for a Bandwidth TN
137145 bw_lookup_result : LookupResult = get_lookup_status_response .result [0 ]
138- self .validateResult (bw_lookup_result , os .environ ['BW_NUMBER' ], "Bandwidth" )
146+ self .validateResult (bw_lookup_result , os .environ ['BW_NUMBER' ], os . environ [ 'BW_NUMBER_PROVIDER' ] )
139147
140148 # Check the information for a Verizon TN
141149 vzw_lookup_result = get_lookup_status_response .result [1 ]
0 commit comments