This talk is primarily for web developers. It's about understanding how to write an API client that is testable and sensible without being more opinionated than necessary.
A Python-centric talk given at PyTennessee 2015 in Nashville, TN.
we're announcing a new feature soon -- additional fields. This will allow people to get congressional districts, state legislative districts, timezones, and school districts with a forward or reverse lookup. We are looking to add more additional fields in the future (namely Census data).
class SmartyStreetsInputError(SmartyStreetsError): """HTTP 400 Bad input. Required fields missing from input or are malformed.""" class SmartyStreetsAuthError(SmartyStreetsError): """HTTP 401 Unauthorized. Authentication failure; invalid credentials""" class SmartyStreetsPaymentError(SmartyStreetsError): """HTTP 402 Payment required. No active subscription found.""" class SmartyStreetsServerError(SmartyStreetsError): """HTTP 500 Internal server error. General service failure; retry request."""
httpretty.register_uri(httpretty.GET, “http://api.geocod.io/v1/parse", body="This does not matter", status=403) self.assertRaises(GeocodioAuthError, self.client.parse, "")
futures = [ session.post(url, data=json.dumps(data_chunk)) for data_chunk in chunker(data, 100) ] while not all([f.done() for f in futures]): continue status_codes = {} responses = [f.result() for f in futures] addresses = AddressCollection([]) for response in responses: if response.status_code not in status_codes.keys(): status_codes[response.status_code] = 1 else: status_codes[response.status_code] += 1 if response.status_code == 200: addresses[0:0] = AddressCollection(response.json())