diff --git a/official/docs/responses/addresses/addresses-create-and-verify.json b/official/docs/responses/addresses/addresses-create-and-verify.json index 1af68c2e..161a90c5 100644 --- a/official/docs/responses/addresses/addresses-create-and-verify.json +++ b/official/docs/responses/addresses/addresses-create-and-verify.json @@ -1,39 +1,14 @@ { - "address": { - "id": "adr_0afc56d0ba4c11ee9036ac1f6bc539aa", - "object": "Address", - "created_at": "2024-01-24T00:03:45+00:00", - "updated_at": "2024-01-24T00:03:45+00:00", - "name": null, - "company": "EASYPOST", - "street1": "417 MONTGOMERY ST FL 5", - "street2": "", - "city": "SAN FRANCISCO", - "state": "CA", - "zip": "94104-1129", - "country": "US", - "phone": "4151234567", - "email": null, - "mode": "test", - "carrier_facility": null, - "residential": false, - "federal_tax_id": null, - "state_tax_id": null, - "verifications": { - "zip4": { - "success": true, - "errors": [], - "details": null - }, - "delivery": { - "success": true, - "errors": [], - "details": { - "latitude": 37.79342, - "longitude": -122.40288, - "time_zone": "America/Los_Angeles" - } + "error": { + "code": "ADDRESS.VERIFY.FAILURE", + "message": "Unable to verify address.", + "errors": [ + { + "code": "E.ADDRESS.NOT_FOUND", + "field": "address", + "message": "Address not found", + "suggestion": null } - } + ] } } diff --git a/official/docs/responses/addresses/addresses-create.json b/official/docs/responses/addresses/addresses-create.json index 72f7bb46..215aadea 100644 --- a/official/docs/responses/addresses/addresses-create.json +++ b/official/docs/responses/addresses/addresses-create.json @@ -1,8 +1,8 @@ { - "id": "adr_0a997f6aba4c11eeb63bac1f6bc539ae", + "id": "adr_3a2086e3bafa11eeb8d4ac1f6bc539ae", "object": "Address", - "created_at": "2024-01-24T00:03:45+00:00", - "updated_at": "2024-01-24T00:03:45+00:00", + "created_at": "2024-01-24T20:50:37+00:00", + "updated_at": "2024-01-24T20:50:37+00:00", "name": null, "company": "EasyPost", "street1": "417 MONTGOMERY ST", diff --git a/official/docs/responses/addresses/addresses-list.json b/official/docs/responses/addresses/addresses-list.json index 3b8a7942..2d07e5a5 100644 --- a/official/docs/responses/addresses/addresses-list.json +++ b/official/docs/responses/addresses/addresses-list.json @@ -1,10 +1,10 @@ { "addresses": [ { - "id": "adr_0c286dcbba4c11eea460ac1f6bc53342", + "id": "adr_3b7de31bbafa11eeb947ac1f6bc539ae", "object": "Address", - "created_at": "2024-01-24T00:03:47+00:00", - "updated_at": "2024-01-24T00:03:47+00:00", + "created_at": "2024-01-24T20:50:39+00:00", + "updated_at": "2024-01-24T20:50:39+00:00", "name": null, "company": "EasyPost", "street1": "417 MONTGOMERY ST", diff --git a/official/docs/responses/addresses/addresses-retrieve.json b/official/docs/responses/addresses/addresses-retrieve.json index bae17e38..a3ddfd81 100644 --- a/official/docs/responses/addresses/addresses-retrieve.json +++ b/official/docs/responses/addresses/addresses-retrieve.json @@ -1,8 +1,8 @@ { - "id": "adr_0c286dcbba4c11eea460ac1f6bc53342", + "id": "adr_3b7de31bbafa11eeb947ac1f6bc539ae", "object": "Address", - "created_at": "2024-01-24T00:03:47+00:00", - "updated_at": "2024-01-24T00:03:47+00:00", + "created_at": "2024-01-24T20:50:39+00:00", + "updated_at": "2024-01-24T20:50:39+00:00", "name": null, "company": "EasyPost", "street1": "417 MONTGOMERY ST", diff --git a/official/docs/responses/addresses/addresses-verify-failure.json b/official/docs/responses/addresses/addresses-verify-failure.json index 271fcdb2..161a90c5 100644 --- a/official/docs/responses/addresses/addresses-verify-failure.json +++ b/official/docs/responses/addresses/addresses-verify-failure.json @@ -1,59 +1,14 @@ { - "id": "adr_0bfc91b4ba4c11ee80c73cecef1b359e", - "object": "Address", - "created_at": "2024-01-24T00:03:47+00:00", - "updated_at": "2024-01-24T00:03:47+00:00", - "name": null, - "company": "EasyPost", - "street1": "UNDELIVERABLE ST", - "street2": null, - "city": "SAN FRANCISCO", - "state": "CA", - "zip": "94104", - "country": "US", - "phone": "4151234567", - "email": null, - "mode": "test", - "carrier_facility": null, - "residential": null, - "federal_tax_id": null, - "state_tax_id": null, - "verifications": { - "zip4": { - "success": false, - "errors": [ - { - "code": "E.ADDRESS.NOT_FOUND", - "field": "address", - "message": "Address not found", - "suggestion": null - }, - { - "code": "E.HOUSE_NUMBER.MISSING", - "field": "street1", - "message": "House number is missing", - "suggestion": null - } - ], - "details": null - }, - "delivery": { - "success": false, - "errors": [ - { - "code": "E.ADDRESS.NOT_FOUND", - "field": "address", - "message": "Address not found", - "suggestion": null - }, - { - "code": "E.HOUSE_NUMBER.MISSING", - "field": "street1", - "message": "House number is missing", - "suggestion": null - } - ], - "details": {} - } + "error": { + "code": "ADDRESS.VERIFY.FAILURE", + "message": "Unable to verify address.", + "errors": [ + { + "code": "E.ADDRESS.NOT_FOUND", + "field": "address", + "message": "Address not found", + "suggestion": null + } + ] } } diff --git a/official/docs/responses/addresses/addresses-verify-param.json b/official/docs/responses/addresses/addresses-verify-param.json index 24669759..353c2105 100644 --- a/official/docs/responses/addresses/addresses-verify-param.json +++ b/official/docs/responses/addresses/addresses-verify-param.json @@ -1,51 +1,47 @@ { - "id": "adr_0b28f550ba4c11eea409ac1f6bc53342", + "id": "adr_3a98ffc7bafa11eeb8fcac1f6bc539ae", "object": "Address", - "created_at": "2024-01-24T00:03:46+00:00", - "updated_at": "2024-01-24T00:03:46+00:00", + "created_at": "2024-01-24T20:50:38+00:00", + "updated_at": "2024-01-24T20:50:38+00:00", "name": null, - "company": "EASYPOST", - "street1": "417 MONTGOMERY ST FL 5", - "street2": "", - "city": "SAN FRANCISCO", - "state": "CA", - "zip": "94104-1129", + "company": "EasyPost", + "street1": "000 unknown street", + "street2": null, + "city": "Not A City", + "state": "ZZ", + "zip": "00001", "country": "US", - "phone": "4151234567", - "email": null, + "phone": "5555555555", + "email": "test@example.com", "mode": "test", "carrier_facility": null, - "residential": false, + "residential": null, "federal_tax_id": null, "state_tax_id": null, "verifications": { "zip4": { - "success": true, + "success": false, "errors": [ { - "code": "E.SECONDARY_INFORMATION.INVALID", - "field": "street2", - "message": "Invalid secondary information(Apt/Suite#)", + "code": "E.ADDRESS.NOT_FOUND", + "field": "address", + "message": "Address not found", "suggestion": null } ], "details": null }, "delivery": { - "success": true, + "success": false, "errors": [ { - "code": "E.SECONDARY_INFORMATION.INVALID", - "field": "street2", - "message": "Invalid secondary information(Apt/Suite#)", + "code": "E.ADDRESS.NOT_FOUND", + "field": "address", + "message": "Address not found", "suggestion": null } ], - "details": { - "latitude": 37.79342, - "longitude": -122.40288, - "time_zone": "America/Los_Angeles" - } + "details": {} } } } diff --git a/official/docs/responses/addresses/addresses-verify-strict-param.json b/official/docs/responses/addresses/addresses-verify-strict-param.json index 713219c4..161a90c5 100644 --- a/official/docs/responses/addresses/addresses-verify-strict-param.json +++ b/official/docs/responses/addresses/addresses-verify-strict-param.json @@ -1,51 +1,14 @@ { - "id": "adr_0b5772d2ba4c11ee9064ac1f6bc539aa", - "object": "Address", - "created_at": "2024-01-24T00:03:46+00:00", - "updated_at": "2024-01-24T00:03:46+00:00", - "name": null, - "company": "EASYPOST", - "street1": "417 MONTGOMERY ST FL 5", - "street2": "", - "city": "SAN FRANCISCO", - "state": "CA", - "zip": "94104-1129", - "country": "US", - "phone": "4151234567", - "email": null, - "mode": "test", - "carrier_facility": null, - "residential": false, - "federal_tax_id": null, - "state_tax_id": null, - "verifications": { - "zip4": { - "success": true, - "errors": [ - { - "code": "E.SECONDARY_INFORMATION.INVALID", - "field": "street2", - "message": "Invalid secondary information(Apt/Suite#)", - "suggestion": null - } - ], - "details": null - }, - "delivery": { - "success": true, - "errors": [ - { - "code": "E.SECONDARY_INFORMATION.INVALID", - "field": "street2", - "message": "Invalid secondary information(Apt/Suite#)", - "suggestion": null - } - ], - "details": { - "latitude": 37.79342, - "longitude": -122.40288, - "time_zone": "America/Los_Angeles" + "error": { + "code": "ADDRESS.VERIFY.FAILURE", + "message": "Unable to verify address.", + "errors": [ + { + "code": "E.ADDRESS.NOT_FOUND", + "field": "address", + "message": "Address not found", + "suggestion": null } - } + ] } } diff --git a/official/docs/responses/addresses/addresses-verify.json b/official/docs/responses/addresses/addresses-verify.json index 95fbb45d..b7bab2ea 100644 --- a/official/docs/responses/addresses/addresses-verify.json +++ b/official/docs/responses/addresses/addresses-verify.json @@ -1,9 +1,9 @@ { "address": { - "id": "adr_0bcd3987ba4c11ee80bf3cecef1b359e", + "id": "adr_3b15ed39bafa11ee83ed3cecef1b359e", "object": "Address", - "created_at": "2024-01-24T00:03:47+00:00", - "updated_at": "2024-01-24T00:03:47+00:00", + "created_at": "2024-01-24T20:50:39+00:00", + "updated_at": "2024-01-24T20:50:39+00:00", "name": null, "company": "EASYPOST", "street1": "417 MONTGOMERY ST FL 5", diff --git a/official/fixtures/example-snippet-fixtures.json b/official/fixtures/example-snippet-fixtures.json index a37f9f83..05e5dd68 100644 --- a/official/fixtures/example-snippet-fixtures.json +++ b/official/fixtures/example-snippet-fixtures.json @@ -10,15 +10,15 @@ "company": "EasyPost", "phone": "415-123-4567" }, - "create_and_verify": { - "street1": "417 Montgomery Street", - "street2": "FL 5", - "city": "San Francisco", - "state": "CA", - "zip": "94104", - "country": "US", + "incorrect": { "company": "EasyPost", - "phone": "415-123-4567" + "street1": "000 unknown street", + "city": "Not A City", + "state": "ZZ", + "zip": "00001", + "country": "US", + "email": "test@example.com", + "phone": "5555555555" } }, "carrier_account": { diff --git a/official/tools/build_doc_json_responses/README.md b/official/tools/build_doc_json_responses/README.md index 04ec7f33..9acd31f2 100644 --- a/official/tools/build_doc_json_responses/README.md +++ b/official/tools/build_doc_json_responses/README.md @@ -16,7 +16,7 @@ make install First, if you are regenerating response snippets, you will first need to delete the related cassette file(s) in `tests/cassettes`. If a cassette file already exists for a given snippet, it will not be overwritten and the generated response snippet will not be updated. -Next, you will need to run the `make generate` command twice - it will fail the first time through. The first time will record the cassette, the second time it will save the snippet files. This is necessary because `vcrpy` doesn't save a cassette until the test function closes, though we call the standalone function inside the test function to capture the test name. +Next, you will need to run the `make generate` command twice - it will fail the first time through; this is expected. ```bash # Run the following to save HTTP recordings @@ -28,7 +28,7 @@ EASYPOST_TEST_API_KEY=putrealkeyhere EASYPOST_PROD_API_KEY=putrealkeyhere PARTNE **NOTE**: Some static data used by this tool, such as the USPS carrier account ID, is associated with the EasyPost Docs Tooling User. You must use that user's API keys to generate these snippets. -Generate response snippets are stored in the `responses` directory. Copy this entire directory to `official/docs/responses` once complete. +Generated response snippets are stored in the `responses` directory. Copy this entire directory to `official/docs/responses` once complete. **NOTE**: The `responses` directory structure is exactly as expected by the docs website and other downstream projects -- do not alter it. diff --git a/official/tools/build_doc_json_responses/builder/snippets.py b/official/tools/build_doc_json_responses/builder/snippets.py index e062c692..f8675ede 100644 --- a/official/tools/build_doc_json_responses/builder/snippets.py +++ b/official/tools/build_doc_json_responses/builder/snippets.py @@ -76,7 +76,7 @@ def extract_response_from_cassette(cassette_filename: str, interaction_index: Op """Opens a single cassette file and extracts the response content.""" cassette_file = os.path.join("tests", "cassettes", cassette_filename) if not os.path.exists(cassette_file): - raise FileNotFoundError(f"{cassette_filename} not found in time, run the tests again.") + raise FileNotFoundError(f"{cassette_filename} not found, run the tests again.") with open(cassette_file, "r") as cassette: try: diff --git a/official/tools/build_doc_json_responses/tests/conftest.py b/official/tools/build_doc_json_responses/tests/conftest.py index 2feb318c..e9be8041 100644 --- a/official/tools/build_doc_json_responses/tests/conftest.py +++ b/official/tools/build_doc_json_responses/tests/conftest.py @@ -182,13 +182,8 @@ def address_create(): @pytest.fixture -def address_create_and_verify(): - return read_fixture_data()["address"]["create_and_verify"] - - -@pytest.fixture -def address_create_strictly_verified(): - return read_fixture_data()["address"]["create_strictly_verified"] +def address_incorrect(): + return read_fixture_data()["address"]["incorrect"] @pytest.fixture diff --git a/official/tools/build_doc_json_responses/tests/test_address.py b/official/tools/build_doc_json_responses/tests/test_address.py index f197ac19..05beb4f0 100644 --- a/official/tools/build_doc_json_responses/tests/test_address.py +++ b/official/tools/build_doc_json_responses/tests/test_address.py @@ -10,24 +10,33 @@ def test_addresses_create(test_client, address_create): @pytest.mark.vcr() -def test_addresses_create_and_verify(test_client, address_create_and_verify): - test_client.address.create_and_verify(**address_create_and_verify) +def test_addresses_create_and_verify(test_client, address_incorrect): + try: + test_client.address.create_and_verify(**address_incorrect) + except: + # This will fail because the address is incorrect; this is expected. + pass build_response_snippet() @pytest.mark.vcr() -def test_addresses_verify_param(test_client, address_create): - address_create["verify"] = True - test_client.address.create(**address_create) +def test_addresses_verify_param(test_client, address_incorrect): + address_incorrect["verify"] = True + test_client.address.create(**address_incorrect) build_response_snippet() @pytest.mark.vcr() -def test_addresses_verify_strict_param(test_client, address_create): - address_create["verify_strict"] = True - test_client.address.create(**address_create) +def test_addresses_verify_strict_param(test_client, address_incorrect): + address_incorrect["verify_strict"] = True + + try: + test_client.address.create(**address_incorrect) + except: + # This will fail because the address is incorrect; this is expected. + pass build_response_snippet() @@ -42,14 +51,17 @@ def test_addresses_verify(test_client, address_create): @pytest.mark.vcr() -def test_addresses_verify_failure(test_client, address_create): +def test_addresses_verify_failure(test_client, address_incorrect): """Verify and already created address.""" - address_create["street1"] = "UNDELIVERABLE ST" - address_create["street2"] = None - address_create["verify"] = True - test_client.address.create(**address_create) + address = test_client.address.create(**address_incorrect) - build_response_snippet() + try: + test_client.address.verify(id=address.id) + except: + # This will fail because the address is incorrect; this is expected. + pass + + build_response_snippet(interaction_index=1) @pytest.mark.vcr()