Skip to content

Commit

Permalink
- Update invalid (error-triggering) address structure for JSON snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
nwithan8 committed Jan 24, 2024
1 parent 2845b66 commit 35a56db
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 207 deletions.
45 changes: 10 additions & 35 deletions official/docs/responses/addresses/addresses-create-and-verify.json
Original file line number Diff line number Diff line change
@@ -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
}
}
]
}
}
6 changes: 3 additions & 3 deletions official/docs/responses/addresses/addresses-create.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 3 additions & 3 deletions official/docs/responses/addresses/addresses-list.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 3 additions & 3 deletions official/docs/responses/addresses/addresses-retrieve.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
67 changes: 11 additions & 56 deletions official/docs/responses/addresses/addresses-verify-failure.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
}
46 changes: 21 additions & 25 deletions official/docs/responses/addresses/addresses-verify-param.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]",
"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": {}
}
}
}
Original file line number Diff line number Diff line change
@@ -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
}
}
]
}
}
6 changes: 3 additions & 3 deletions official/docs/responses/addresses/addresses-verify.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
16 changes: 8 additions & 8 deletions official/fixtures/example-snippet-fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "[email protected]",
"phone": "5555555555"
}
},
"carrier_account": {
Expand Down
4 changes: 2 additions & 2 deletions official/tools/build_doc_json_responses/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 2 additions & 7 deletions official/tools/build_doc_json_responses/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 35a56db

Please sign in to comment.