def test_business_auth(self): """Test Business API access. This query fails on purpose, but we inspect and verify the signed URL is correct.""" # Create the query parameters to sign. The order matters. params_to_sign = OrderedDict() params_to_sign['address'] = '1600 amphitheatre mountain view ca' params_to_sign['components'] = '' params_to_sign['bounds'] = '' params_to_sign['region'] = '' params_to_sign['language'] = '' params_to_sign['sensor'] = 'false' request_to_sign = requests.Request( 'GET', url=Geocoder.GEOCODE_QUERY_URL, params=params_to_sign, headers={ 'User-Agent': Geocoder.USER_AGENT }) client_id = 'gme-businessname' crypto_key = 'vNIXE0xscrmjlyV-12Nj_BvUPaw=' g = Geocoder(client_id=client_id, private_key=crypto_key) signed_request = g.add_signature(request_to_sign) self.assertRegexpMatches(signed_request.url, r'&signature=[a-zA-Z0-9-=]+$', 'Signature must be at end of URL.') self.assertRegexpMatches(signed_request.url, r'&client=gme-businessname', 'URL must containg client id.') # Verified against https://m4b-url-signer.appspot.com/ self.assertRegexpMatches(signed_request.url, r'&signature=7bVsUv6kyRHlG0DBAIhKHfX-96M=', 'Incorrect signature')