diff --git a/easypost/__init__.py b/easypost/__init__.py index 4ad82e0b..f821362e 100644 --- a/easypost/__init__.py +++ b/easypost/__init__.py @@ -2,7 +2,6 @@ import json import platform import re -import ssl import time import six @@ -65,9 +64,6 @@ timeout = min(60, _max_timeout) -USER_AGENT = "EasyPost/v2 PythonClient/{0}".format(VERSION) - - class Error(Exception): def __init__(self, message=None, http_status=None, http_body=None, original_exception=None): super(Error, self).__init__(message) @@ -223,31 +219,49 @@ def request_raw(self, method, url, params=None, apiKeyRequired=True): abs_url = "%s%s" % (api_base, url or "") params = self._objects_to_ids(params) - ua = { + # Fallback values for the user-agent header + user_agent = { "client_version": VERSION, - "lang": "python", - "publisher": "easypost", - "request_lib": request_lib, + "implementation": "NA", + "os_arch": "NA", + "os_version": "NA", + "os": "NA", + "python_version": "NA", } + + # Attempt to populate the user-agent header for attr, func in ( - ("lang_version", platform.python_version), - ("platform", platform.platform), - ("uname", lambda: " ".join(platform.uname())), + ("implementation", platform.python_implementation), + ("os_details", platform.uname), + ("python_version", platform.python_version), ): try: val = func() - except Exception as e: - val = "!! %s" % e - ua[attr] = val - - if hasattr(ssl, "OPENSSL_VERSION"): - ua["openssl_version"] = ssl.OPENSSL_VERSION + if attr == "os_details": + user_agent["os"] = val[0] + user_agent["os_version"] = val[2] + user_agent["os_arch"] = val[4] + else: + user_agent[attr] = val + except Exception: + # If we fail to get OS info, do nothing as we already set fallbacks for these values + pass + + user_agent = ( + "EasyPost/v2 PythonClient/{0} Python/{1} OS/{2} OSVersion/{3} OSArch/{4} Implementation/{5}".format( + VERSION, + user_agent["python_version"], + user_agent["os"], + user_agent["os_version"], + user_agent["os_arch"], + user_agent["implementation"], + ) + ) headers = { - "X-Client-User-Agent": json.dumps(ua), - "User-Agent": USER_AGENT, "Authorization": "Bearer %s" % my_api_key, "Content-type": "application/json", + "User-Agent": user_agent, } if timeout > _max_timeout: diff --git a/examples/unicode.py b/examples/unicode.py index b1078596..31141fac 100644 --- a/examples/unicode.py +++ b/examples/unicode.py @@ -3,7 +3,9 @@ easypost.api_key = "API_KEY" # unicode +# fmt: off state = u"DELEGACI\xf3N BENITO JU\xe1REZ" +# fmt: on address = easypost.Address.create(state=state) diff --git a/tests/cassettes/test_address_bytestring.yaml b/tests/cassettes/test_address_bytestring.yaml index f268ed3e..7dfa4a4a 100644 --- a/tests/cassettes/test_address_bytestring.yaml +++ b/tests/cassettes/test_address_bytestring.yaml @@ -14,8 +14,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/addresses response: diff --git a/tests/cassettes/test_address_creation_verification.yaml b/tests/cassettes/test_address_creation_verification.yaml index 310027bc..7d19ccfe 100644 --- a/tests/cassettes/test_address_creation_verification.yaml +++ b/tests/cassettes/test_address_creation_verification.yaml @@ -16,8 +16,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/addresses response: @@ -92,8 +90,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/addresses/adr_e18d7993d8494cff94be285e1fbc6a41/verify response: @@ -170,8 +166,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/addresses/adr_e18d7993d8494cff94be285e1fbc6a41 response: diff --git a/tests/cassettes/test_address_creation_with_verify.yaml b/tests/cassettes/test_address_creation_with_verify.yaml index ae7e715f..9301359a 100644 --- a/tests/cassettes/test_address_creation_with_verify.yaml +++ b/tests/cassettes/test_address_creation_with_verify.yaml @@ -16,8 +16,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/addresses response: diff --git a/tests/cassettes/test_address_creation_with_verify_bool.yaml b/tests/cassettes/test_address_creation_with_verify_bool.yaml index 52ca48bd..f1ce9188 100644 --- a/tests/cassettes/test_address_creation_with_verify_bool.yaml +++ b/tests/cassettes/test_address_creation_with_verify_bool.yaml @@ -16,8 +16,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/addresses response: diff --git a/tests/cassettes/test_address_creation_with_verify_failure.yaml b/tests/cassettes/test_address_creation_with_verify_failure.yaml index 0ba4333c..66137a59 100644 --- a/tests/cassettes/test_address_creation_with_verify_failure.yaml +++ b/tests/cassettes/test_address_creation_with_verify_failure.yaml @@ -16,8 +16,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/addresses response: diff --git a/tests/cassettes/test_address_creation_with_verify_strict_failure.yaml b/tests/cassettes/test_address_creation_with_verify_strict_failure.yaml index c50a71c1..a9429ab0 100644 --- a/tests/cassettes/test_address_creation_with_verify_strict_failure.yaml +++ b/tests/cassettes/test_address_creation_with_verify_strict_failure.yaml @@ -16,8 +16,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/addresses response: diff --git a/tests/cassettes/test_address_unicode.yaml b/tests/cassettes/test_address_unicode.yaml index 411d4afb..3e660782 100644 --- a/tests/cassettes/test_address_unicode.yaml +++ b/tests/cassettes/test_address_unicode.yaml @@ -14,8 +14,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/addresses response: diff --git a/tests/cassettes/test_batch_create_and_buy.yaml b/tests/cassettes/test_batch_create_and_buy.yaml index 507583e6..3e932234 100644 --- a/tests/cassettes/test_batch_create_and_buy.yaml +++ b/tests/cassettes/test_batch_create_and_buy.yaml @@ -16,8 +16,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/addresses response: @@ -95,8 +93,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/parcels response: @@ -175,8 +171,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/batches/create_and_buy response: @@ -250,8 +244,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/batches/batch_e018ee73541a430dbd5b7ab19377543b response: @@ -326,8 +318,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/shipments/shp_d1db138265b8426283c4580b60618aad/insure response: diff --git a/tests/cassettes/test_carrier_types.yaml b/tests/cassettes/test_carrier_types.yaml index 10f5a608..972a14bf 100644 --- a/tests/cassettes/test_carrier_types.yaml +++ b/tests/cassettes/test_carrier_types.yaml @@ -12,8 +12,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/carrier_types response: diff --git a/tests/cassettes/test_child_user_create.yaml b/tests/cassettes/test_child_user_create.yaml index 52a51647..3485fd65 100644 --- a/tests/cassettes/test_child_user_create.yaml +++ b/tests/cassettes/test_child_user_create.yaml @@ -14,8 +14,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/users response: @@ -91,8 +89,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/users response: @@ -159,8 +155,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/users/user_99a72f96c77c4a9fa1d7c268b663ea4b response: @@ -232,8 +226,7 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed + method: PUT uri: https://api.easypost.com/v2/users/user_99a72f96c77c4a9fa1d7c268b663ea4b response: @@ -303,8 +296,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/users/user_99a72f96c77c4a9fa1d7c268b663ea4b response: diff --git a/tests/cassettes/test_insurance_creation.yaml b/tests/cassettes/test_insurance_creation.yaml index 387620d9..b3597412 100644 --- a/tests/cassettes/test_insurance_creation.yaml +++ b/tests/cassettes/test_insurance_creation.yaml @@ -21,8 +21,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/insurances response: @@ -99,8 +97,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/insurances/ins_2a5732bf515349e59c883da5eb1a8e14 response: @@ -183,8 +179,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/insurances?page_size=5 response: diff --git a/tests/cassettes/test_order_create_then_buy.yaml b/tests/cassettes/test_order_create_then_buy.yaml index f4a23e28..d64326fe 100644 --- a/tests/cassettes/test_order_create_then_buy.yaml +++ b/tests/cassettes/test_order_create_then_buy.yaml @@ -21,8 +21,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/orders response: @@ -115,8 +113,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/orders/order_4a7076406aa8477bb66e619f354c99ce/rates response: @@ -211,8 +207,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/orders/order_4a7076406aa8477bb66e619f354c99ce/buy response: @@ -318,8 +312,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/shipments/shp_53f2547d3c0f409ab51a48d97295b898/insure response: @@ -421,8 +413,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/shipments/shp_843facf0843a4a04ad9cb1449cc5b5c5/insure response: diff --git a/tests/cassettes/test_parcel_creation.yaml b/tests/cassettes/test_parcel_creation.yaml index 9d355a87..01d078d1 100644 --- a/tests/cassettes/test_parcel_creation.yaml +++ b/tests/cassettes/test_parcel_creation.yaml @@ -15,8 +15,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/parcels response: diff --git a/tests/cassettes/test_pickup_batch.yaml b/tests/cassettes/test_pickup_batch.yaml index 60dce2cd..2812c7ff 100644 --- a/tests/cassettes/test_pickup_batch.yaml +++ b/tests/cassettes/test_pickup_batch.yaml @@ -17,8 +17,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/addresses response: @@ -105,8 +103,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/batches/create_and_buy response: @@ -178,8 +174,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/batches/batch_dba9083bb08c46bab71c0bd276409472 response: @@ -252,8 +246,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/batches/batch_dba9083bb08c46bab71c0bd276409472 response: @@ -326,8 +318,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/batches/batch_dba9083bb08c46bab71c0bd276409472 response: @@ -400,8 +390,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/batches/batch_dba9083bb08c46bab71c0bd276409472 response: @@ -474,8 +462,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/batches/batch_dba9083bb08c46bab71c0bd276409472 response: @@ -548,8 +534,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/batches/batch_dba9083bb08c46bab71c0bd276409472 response: @@ -623,8 +607,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/batches/batch_dba9083bb08c46bab71c0bd276409472 response: @@ -698,8 +680,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/batches/batch_dba9083bb08c46bab71c0bd276409472 response: @@ -773,8 +753,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/batches/batch_dba9083bb08c46bab71c0bd276409472 response: @@ -850,8 +828,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/shipments/shp_41760aa3e8f64ba5abdbea81d5b88694/insure response: @@ -956,8 +932,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/shipments/shp_3953709c56d344e3946b6bafefcdf8b8/insure response: @@ -1065,8 +1039,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/pickups response: @@ -1147,8 +1119,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/pickups/pickup_394b75ba69d843b6ab40951be0c28733/buy response: diff --git a/tests/cassettes/test_rerate.yaml b/tests/cassettes/test_rerate.yaml index 669d7249..24d8da0b 100644 --- a/tests/cassettes/test_rerate.yaml +++ b/tests/cassettes/test_rerate.yaml @@ -16,8 +16,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/addresses response: @@ -94,8 +92,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/addresses response: @@ -171,8 +167,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/parcels response: @@ -247,8 +241,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/customs_items response: @@ -326,8 +318,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/customs_infos response: @@ -406,8 +396,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/shipments response: @@ -503,8 +491,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/shipments/shp_874a25cccd084c149db3b2cc6b6565d9/rerate response: diff --git a/tests/cassettes/test_scan_form_create_and_retrieve.yaml b/tests/cassettes/test_scan_form_create_and_retrieve.yaml index 7c10e652..0ea43f5d 100644 --- a/tests/cassettes/test_scan_form_create_and_retrieve.yaml +++ b/tests/cassettes/test_scan_form_create_and_retrieve.yaml @@ -24,8 +24,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/shipments response: @@ -126,8 +124,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/shipments/shp_c0f8663cd8634156a9695e59fd401076/buy response: @@ -233,8 +229,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/scan_forms response: @@ -313,8 +307,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/scan_forms/sf_422127889bb048f5bca4677723763bde response: @@ -391,8 +383,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/scan_forms?page_size=2 response: diff --git a/tests/cassettes/test_shipment_creation.yaml b/tests/cassettes/test_shipment_creation.yaml index 480fe88c..67ffbc9e 100644 --- a/tests/cassettes/test_shipment_creation.yaml +++ b/tests/cassettes/test_shipment_creation.yaml @@ -16,8 +16,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/addresses response: @@ -96,8 +94,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/addresses response: @@ -175,8 +171,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/parcels response: @@ -253,8 +247,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/customs_items response: @@ -334,8 +326,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/customs_infos response: @@ -416,8 +406,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/shipments response: @@ -513,8 +501,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/shipments/shp_4b0cc9fe86384a028d75061a9a6d6e90/rates response: @@ -595,8 +581,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/shipments/shp_4b0cc9fe86384a028d75061a9a6d6e90/buy response: diff --git a/tests/cassettes/test_shipment_report.yaml b/tests/cassettes/test_shipment_report.yaml index 214fd68d..6cd95a8b 100644 --- a/tests/cassettes/test_shipment_report.yaml +++ b/tests/cassettes/test_shipment_report.yaml @@ -15,8 +15,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/reports/shipment response: @@ -87,8 +85,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/reports/shprep_b88bd3498f174cc081c19cb43ca9afa6?type=shipment response: @@ -159,8 +155,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/reports/shipment?type=shipment response: diff --git a/tests/cassettes/test_single_pickup.yaml b/tests/cassettes/test_single_pickup.yaml index ee5fbef6..fb72afbf 100644 --- a/tests/cassettes/test_single_pickup.yaml +++ b/tests/cassettes/test_single_pickup.yaml @@ -17,8 +17,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/addresses response: @@ -100,8 +98,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/shipments response: @@ -193,8 +189,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/shipments/shp_47f86de53aab4fb2bceedf934b79d189/buy response: @@ -295,8 +289,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/pickups response: @@ -377,8 +369,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/pickups/pickup_46dfc4f11dd14929b8fb3aeb54ea5de6/buy response: diff --git a/tests/cassettes/test_smartrate.yaml b/tests/cassettes/test_smartrate.yaml index 4f092043..6bf0563b 100644 --- a/tests/cassettes/test_smartrate.yaml +++ b/tests/cassettes/test_smartrate.yaml @@ -20,8 +20,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/shipments response: @@ -109,8 +107,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/shipments/shp_25cd978a471e4982abd27b58ae806b9b/smartrate response: diff --git a/tests/cassettes/test_tracker_interactions.yaml b/tests/cassettes/test_tracker_interactions.yaml index b1727530..e273aba5 100644 --- a/tests/cassettes/test_tracker_interactions.yaml +++ b/tests/cassettes/test_tracker_interactions.yaml @@ -15,8 +15,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/trackers response: @@ -97,8 +95,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/trackers/trk_4344b5dfc06a439d99e7be656c25ffc2 response: @@ -176,8 +172,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/trackers?tracking_code=EP20200511150500100 response: @@ -259,8 +253,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/trackers response: @@ -341,8 +333,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/trackers?after_id=trk_4344b5dfc06a439d99e7be656c25ffc2&tracking_code=EP20200511150500100 response: diff --git a/tests/cassettes/test_tracker_values.yaml b/tests/cassettes/test_tracker_values.yaml index 8ce80df2..41e416c1 100644 --- a/tests/cassettes/test_tracker_values.yaml +++ b/tests/cassettes/test_tracker_values.yaml @@ -14,8 +14,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/trackers response: @@ -96,8 +94,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/trackers response: @@ -181,8 +177,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/trackers response: @@ -268,8 +262,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/trackers response: @@ -355,8 +347,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/trackers response: @@ -443,8 +433,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/trackers response: @@ -527,8 +515,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/trackers response: diff --git a/tests/cassettes/test_webhooks.yaml b/tests/cassettes/test_webhooks.yaml index 70e89c6a..59308b8d 100644 --- a/tests/cassettes/test_webhooks.yaml +++ b/tests/cassettes/test_webhooks.yaml @@ -14,8 +14,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: POST uri: https://api.easypost.com/v2/webhooks response: @@ -85,8 +83,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/webhooks/hook_e8f039da247311ecb4a52dfd1fc8a05a response: @@ -158,8 +154,7 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed + method: PUT uri: https://api.easypost.com/v2/webhooks/hook_e8f039da247311ecb4a52dfd1fc8a05a response: @@ -229,8 +224,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/webhooks?url=http%3A%2F%2Fexample.com%2F20200511150500100 response: @@ -302,8 +295,7 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed + method: DELETE uri: https://api.easypost.com/v2/webhooks/hook_e8f039da247311ecb4a52dfd1fc8a05a response: @@ -371,8 +363,6 @@ interactions: - EZTK-NONE user-agent: - easypost/v2 pythonclient/suppressed - x-client-user-agent: - - suppressed method: GET uri: https://api.easypost.com/v2/webhooks/hook_e8f039da247311ecb4a52dfd1fc8a05a response: diff --git a/tests/test_address.py b/tests/test_address.py index 79aacd47..1075ccb0 100644 --- a/tests/test_address.py +++ b/tests/test_address.py @@ -122,7 +122,9 @@ def test_address_creation_with_verify_strict_failure(): @pytest.mark.vcr() def test_address_unicode(): # Create an address with unicode field and assert if it was created correctly. + # fmt: off state = u"DELEGACI\xf3N BENITO JU\xe1REZ" + # fmt: on address = easypost.Address.create(state=state) assert address.state == state @@ -131,7 +133,9 @@ def test_address_unicode(): @pytest.mark.vcr() def test_address_bytestring(): # Create an address with a bytestring field and assert if it was created correctly. + # fmt: off state = u"DELEGACI\xf3N BENITO JU\xe1REZ" + # fmt: on address = easypost.Address.create(state=state.encode("utf-8")) assert address.state == state