Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(warehouse-sources): add easypost claim, carrier account, carrier metadata and end shipper tables (#106629)

Tom Owers314055781cf6
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
index 16c135e930f5..7310434026d7 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
@@ -2754,14 +2754,14 @@ Note: `/incoming-documents` is read-only and its only list filter is `created_at
## Easypost — gaps
-Today (9): `addresses`, `batches`, `events`, `insurances`, `pickups`, `refunds`, `scan_forms`, `shipments`, `trackers`
+Today (13): `addresses`, `batches`, `carrier_accounts`, `carriers`, `claims`, `end_shippers`, `events`, `insurances`, `pickups`, `refunds`, `scan_forms`, `shipments`, `trackers`
Diffed against: <https://docs.easypost.com/docs/carrier-accounts>
-- [ ] `GET /v2/carrier_accounts` — lookup that resolves the carrier_account_id stamped on every shipment and rate already synced (high)
-- [ ] `GET /v2/claims` — insurance claims with amount, status and resolution - transactional and completely absent (only insurances are synced) (high)
-- [ ] `GET /v2/metadata/carriers` — carrier service levels, predefined packages and supported options - resolves the service/carrier codes on shipments and rates (medium)
-- [ ] `GET /v2/end_shippers` — end shipper records referenced by international shipments (medium)
+- [x] `GET /v2/carrier_accounts` — lookup that resolves the carrier_account_id stamped on every shipment and rate already synced (high)
+- [x] `GET /v2/claims` — insurance claims with amount, status and resolution - transactional and completely absent (only insurances are synced) (high)
+- [x] `GET /v2/metadata/carriers` — carrier service levels, predefined packages and supported options - resolves the service/carrier codes on shipments and rates (medium)
+- [x] `GET /v2/end_shippers` — end shipper records referenced by international shipments (medium)
- [ ] `GET /v2/users/children` — child user roster for platforms that break spend and volume down by sub-account (medium)
- [ ] `GET /v2/reports/{type}` — generated shipment/payment_log/tracker/refund report objects, useful for reconciling billing (low)
- [ ] `GET /v2/carrier_types` — lookup of available carrier types and their credential fields (low)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/easypost/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/easypost/canonical_descriptions.py
index 1c6aa86edd85..0d205b10ceb9 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/easypost/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/easypost/canonical_descriptions.py
@@ -89,6 +89,76 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"updated_at": "When the insurance was last updated.",
},
},
+ "claims": {
+ "description": "An insurance claim filed against a shipment for loss, theft or damage, with its review status and reimbursement amounts.",
+ "docs_url": "https://docs.easypost.com/docs/insurance/claims",
+ "columns": {
+ "id": 'Unique identifier for the claim, begins with "clm_".',
+ "mode": 'Whether the claim is in "test" or "production" mode.',
+ "insurance_id": "Identifier of the insurance the claim was filed against.",
+ "shipment_id": "Identifier of the shipment the claim was filed against.",
+ "tracking_code": "Tracking code of the claimed shipment.",
+ "type": "Type of claim being filed: loss, theft or damage.",
+ "status": "Current status of the claim (submitted, in_review, approved, approved_partial, rejected, cancelled, needs_action).",
+ "status_detail": "Reason for the current status.",
+ "status_timestamp": "When the status last changed, which can differ from updated_at.",
+ "history": "Ordered history of status changes for the claim.",
+ "insurance_amount": "Amount of insurance coverage.",
+ "requested_amount": "Amount of the claim, capped at the purchased coverage amount.",
+ "approved_amount": "Amount approved for reimbursement.",
+ "salvage_value": "Salvage value of the damaged item.",
+ "payment_method": "How the reimbursement is paid: mailed_check or easypost_wallet.",
+ "created_at": "When the claim was created.",
+ "updated_at": "When the claim was last updated.",
+ },
+ },
+ "carrier_accounts": {
+ "description": "A carrier account holding your credentials with a carrier. The carrier_account_id on shipments and rates resolves to a row here.",
+ "docs_url": "https://docs.easypost.com/docs/carrier-accounts",
+ "columns": {
+ "id": 'Unique identifier for the carrier account, begins with "ca_".',
+ "type": "Name of the CarrierType this account is for (e.g. UspsAccount).",
+ "readable": "Display name for the type of the account.",
+ "description": "Optional user-readable label distinguishing accounts of the same type.",
+ "reference": "Optional field usable in place of carrier_account_id elsewhere in the API.",
+ "clone": "Whether only the reference and description can be updated.",
+ "billing_type": "Billing type of the carrier account.",
+ "created_at": "When the carrier account was created.",
+ "updated_at": "When the carrier account was last updated.",
+ },
+ },
+ "carriers": {
+ "description": "Platform-wide metadata for every carrier EasyPost supports: service levels, predefined packages, supported features and shipment options. Resolves the carrier and service codes carried on shipments and rates.",
+ "docs_url": "https://docs.easypost.com/docs/carrier-metadata",
+ "columns": {
+ "name": 'The single-word name of the carrier, such as "royalmail".',
+ "human_readable": "The human-readable name of the carrier.",
+ "service_levels": "Service level objects available for this carrier.",
+ "predefined_packages": "Predefined package objects available for this carrier.",
+ "supported_features": "Supported feature objects for this carrier.",
+ "shipment_options": "Shipment option objects for this carrier.",
+ },
+ },
+ "end_shippers": {
+ "description": "The person or business responsible for a shipment, asserted by platforms that buy postage on behalf of their users. Referenced by shipments bought with an end_shipper_id.",
+ "docs_url": "https://docs.easypost.com/docs/endshippers",
+ "columns": {
+ "id": 'Unique identifier for the end shipper, begins with "es_".',
+ "mode": 'Whether the end shipper was created in "test" or "production" mode.',
+ "name": "Name of the responsible person.",
+ "company": "Name of the responsible company.",
+ "street1": "First line of the address.",
+ "street2": "Second line of the address.",
+ "city": "City.",
+ "state": "State or province.",
+ "zip": "ZIP or postal code.",
+ "country": "ISO 3166 country code. Must be US for end shippers.",
+ "phone": "Phone number to reach the person or organization.",
+ "email": "Email to reach the person or organization.",
+ "created_at": "When the end shipper was created.",
+ "updated_at": "When the end shipper was last updated.",
+ },
+ },
"refunds": {
"description": "A request to refund the postage cost of a purchased label.",
"docs_url": "https://docs.easypost.com/docs/refunds",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/easypost/easypost.py b/products/warehouse_sources/backend/temporal/data_imports/sources/easypost/easypost.py
index f2d6901f3e4c..fb89be0b2b59 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/easypost/easypost.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/easypost/easypost.py
@@ -58,9 +58,7 @@ def _format_datetime(value: datetime) -> str:
wait=wait_exponential_jitter(initial=1, max=30),
reraise=True,
)
-def _fetch_page(
- session: requests.Session, url: str, params: dict[str, Any], logger: FilteringBoundLogger
-) -> dict[str, Any]:
+def _fetch_page(session: requests.Session, url: str, params: dict[str, Any], logger: FilteringBoundLogger) -> Any:
response = session.get(url, params=params, timeout=REQUEST_TIMEOUT_SECONDS)
if response.status_code == 429 or response.status_code >= 500:
@@ -88,6 +86,12 @@ def validate_credentials(api_key: str) -> bool:
return False
+def _redact(items: list[dict[str, Any]], redacted_fields: tuple[str, ...]) -> list[dict[str, Any]]:
+ if not redacted_fields:
+ return items
+ return [{k: v for k, v in item.items() if k not in redacted_fields} for item in items]
+
+
def get_rows(
api_key: str,
endpoint: str,
@@ -102,6 +106,16 @@ def get_rows(
session = make_tracked_session(redact_values=(api_key,))
session.auth = (api_key, "")
+ url = f"{EASYPOST_BASE_URL}{config.path}"
+
+ if not config.paginated:
+ # Lookup endpoints answer with the whole collection in one response — no cursor and no
+ # `has_more`, so there is nothing to resume from or to watermark against.
+ data = _fetch_page(session, url, {}, logger)
+ collection = data if config.returns_bare_list else data.get(config.name, [])
+ if collection:
+ yield _redact(collection, config.redacted_fields)
+ return
# Incremental cursor: EasyPost returns newest-first, so we walk backwards (via `before_id`) and
# stop once a page reaches the watermark. `start_datetime` filters server-side on `created_at`
@@ -111,7 +125,7 @@ def get_rows(
start_datetime: str | None = None
if should_use_incremental_field and db_incremental_field_last_value is not None:
last_value_dt = _parse_datetime(db_incremental_field_last_value)
- if last_value_dt is not None:
+ if last_value_dt is not None and config.supports_start_datetime:
start_datetime = _format_datetime(last_value_dt)
resume = resumable_source_manager.load_state() if resumable_source_manager.can_resume() else None
@@ -126,7 +140,7 @@ def get_rows(
if start_datetime:
params["start_datetime"] = start_datetime
- data = _fetch_page(session, f"{EASYPOST_BASE_URL}{config.path}", params, logger)
+ data = _fetch_page(session, url, params, logger)
items = data.get(config.name, [])
if not items:
break
@@ -144,7 +158,7 @@ def get_rows(
rows.append(item)
if rows:
- yield rows
+ yield _redact(rows, config.redacted_fields)
# Save the cursor for the page we just yielded (not the next one) so a crash re-fetches
# and re-yields this page — merge dedupes on the `id` primary key — rather than skipping it.
resumable_source_manager.save_state(EasypostResumeConfig(before_id=before_id))
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/easypost/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/easypost/settings.py
index b3bac4d374d2..292eea540d05 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/easypost/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/easypost/settings.py
@@ -4,7 +4,7 @@ from typing import Optional
from products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldType
-@dataclass
+@dataclass(frozen=True)
class EasypostEndpointConfig:
name: str
# Path segment under https://api.easypost.com/v2/. EasyPost list responses wrap the array
@@ -22,6 +22,15 @@ class EasypostEndpointConfig:
# later mutations to an existing row are only picked up by a full refresh.
append_only: bool = False
should_sync_default: bool = True
+ # Cursor pagination (before_id + has_more). The lookup endpoints answer with the whole
+ # collection in one response and carry no cursor.
+ paginated: bool = True
+ # Server-side `created_at` filter. Absent from /end_shippers and the lookup endpoints.
+ supports_start_datetime: bool = True
+ # /carrier_accounts answers with a bare JSON array instead of the usual {"<name>": [...]}.
+ returns_bare_list: bool = False
+ # Top-level keys dropped from every row before it reaches the warehouse.
+ redacted_fields: tuple[str, ...] = ()
def _created_at_fields() -> list[IncrementalField]:
@@ -37,8 +46,9 @@ def _created_at_fields() -> list[IncrementalField]:
# Cursor-paginated list endpoints (before_id/after_id + has_more) that all share the EasyPost
# object shape: a globally-unique prefixed `id`, plus `created_at` / `updated_at` ISO-8601
-# timestamps. `start_datetime` filters server-side on `created_at`. `/parcels` has no list
-# endpoint and `/webhooks` is unpaginated, so neither is exposed as a sync table here.
+# timestamps. `start_datetime` filters server-side on `created_at`. `/carrier_accounts` and
+# `/metadata/carriers` are lookups answered in a single unpaginated response. `/parcels` has no
+# list endpoint and `/webhooks` is unpaginated, so neither is exposed as a sync table here.
EASYPOST_ENDPOINTS: dict[str, EasypostEndpointConfig] = {
"addresses": EasypostEndpointConfig(
name="addresses",
@@ -50,6 +60,49 @@ EASYPOST_ENDPOINTS: dict[str, EasypostEndpointConfig] = {
path="/batches",
incremental_fields=_created_at_fields(),
),
+ "carrier_accounts": EasypostEndpointConfig(
+ name="carrier_accounts",
+ path="/carrier_accounts",
+ # No cursor and no time filter, so full refresh only. EasyPost serves this endpoint to
+ # production API keys only, so a source connected with a test key cannot sync it — leave
+ # it unselected rather than failing a table the user never asked for.
+ incremental_fields=[],
+ partition_key=None,
+ should_sync_default=False,
+ paginated=False,
+ supports_start_datetime=False,
+ returns_bare_list=True,
+ # Carrier credentials. EasyPost masks password-type values but returns the rest in
+ # plaintext, and anyone who can query the warehouse can read the synced row.
+ redacted_fields=("fields", "credentials", "test_credentials"),
+ ),
+ "carriers": EasypostEndpointConfig(
+ name="carriers",
+ path="/metadata/carriers",
+ # Platform-wide carrier metadata (service levels, predefined packages, supported
+ # options), keyed by the single-word carrier name. It carries no id and no timestamps,
+ # so full refresh only.
+ incremental_fields=[],
+ partition_key=None,
+ primary_keys=["name"],
+ paginated=False,
+ supports_start_datetime=False,
+ ),
+ "claims": EasypostEndpointConfig(
+ name="claims",
+ path="/claims",
+ incremental_fields=_created_at_fields(),
+ ),
+ "end_shippers": EasypostEndpointConfig(
+ name="end_shippers",
+ path="/end_shippers",
+ # /end_shippers paginates by cursor but takes no start_datetime, so the descending
+ # client-side watermark stop is what bounds an incremental run. EasyPost opens this API
+ # to enabled accounts only, so it stays unselected by default.
+ incremental_fields=_created_at_fields(),
+ should_sync_default=False,
+ supports_start_datetime=False,
+ ),
"events": EasypostEndpointConfig(
name="events",
path="/events",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/easypost/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/easypost/source.py
index f3c8b5f7a132..ed046a4a386a 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/easypost/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/easypost/source.py
@@ -95,13 +95,15 @@ You can find your API keys in your [EasyPost account settings](https://www.easyp
) -> list[SourceSchema]:
def _build_schema(endpoint: str) -> SourceSchema:
endpoint_config = EASYPOST_ENDPOINTS[endpoint]
+ fields = INCREMENTAL_FIELDS.get(endpoint, [])
return SourceSchema(
name=endpoint,
# `created_at` incremental sync appends newly created rows; immutable resources
- # (events) are append-only, mutable ones additionally allow incremental.
- supports_incremental=not endpoint_config.append_only,
- supports_append=True,
- incremental_fields=INCREMENTAL_FIELDS.get(endpoint, []),
+ # (events) are append-only, mutable ones additionally allow incremental. The
+ # lookup endpoints advertise no cursor field, so they are full refresh only.
+ supports_incremental=bool(fields) and not endpoint_config.append_only,
+ supports_append=bool(fields),
+ incremental_fields=fields,
should_sync_default=endpoint_config.should_sync_default,
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/easypost/tests/test_easypost.py b/products/warehouse_sources/backend/temporal/data_imports/sources/easypost/tests/test_easypost.py
index a01b4a4efd0b..f65391c341ee 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/easypost/tests/test_easypost.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/easypost/tests/test_easypost.py
@@ -39,6 +39,18 @@ def _patch_pages(monkeypatch: Any, pages_by_before_id: dict[Any, dict[str, Any]]
monkeypatch.setattr(easypost, "_fetch_page", fake_fetch)
+def _patch_response(monkeypatch: Any, payload: Any) -> list[dict[str, Any]]:
+ # Answers every request with `payload`; the returned list records what each request sent.
+ requests: list[dict[str, Any]] = []
+
+ def fake_fetch(session: Any, url: str, params: dict[str, Any], logger: Any) -> Any:
+ requests.append({"url": url, **params})
+ return payload
+
+ monkeypatch.setattr(easypost, "_fetch_page", fake_fetch)
+ return requests
+
+
def _collect(manager: _FakeResumableManager, endpoint: str = "shipments", **kwargs: Any) -> list[dict[str, Any]]:
rows: list[dict[str, Any]] = []
for batch in get_rows("k", endpoint, MagicMock(), manager, **kwargs): # type: ignore[arg-type]
@@ -156,6 +168,80 @@ class TestGetRows:
assert "before_id" not in captured
+class TestUnpaginatedEndpoints:
+ def test_bare_list_response_is_yielded_whole(self, monkeypatch: Any) -> None:
+ # /carrier_accounts answers with a bare JSON array, not the {"<name>": [...]} wrapper every
+ # other endpoint uses, so extraction has to branch on the endpoint rather than the payload.
+ requests = _patch_response(monkeypatch, [{"id": "ca_1"}, {"id": "ca_2"}])
+ rows = _collect(_FakeResumableManager(), endpoint="carrier_accounts")
+ assert [r["id"] for r in rows] == ["ca_1", "ca_2"]
+ assert requests == [{"url": "https://api.easypost.com/v2/carrier_accounts"}]
+
+ def test_wrapped_response_is_unwrapped(self, monkeypatch: Any) -> None:
+ requests = _patch_response(monkeypatch, {"carriers": [{"name": "usps"}]})
+ rows = _collect(_FakeResumableManager(), endpoint="carriers")
+ assert [r["name"] for r in rows] == ["usps"]
+ assert requests == [{"url": "https://api.easypost.com/v2/metadata/carriers"}]
+
+ def test_does_not_paginate_or_save_resume_state(self, monkeypatch: Any) -> None:
+ # There is no cursor in the response, so looping on a truthy `has_more` — or resuming from
+ # a stale saved cursor — would re-request the same page forever.
+ manager = _FakeResumableManager(EasypostResumeConfig(before_id="ca_9"))
+ requests = _patch_response(monkeypatch, {"carriers": [{"name": "usps"}], "has_more": True})
+ _collect(manager, endpoint="carriers")
+ assert len(requests) == 1
+ assert "before_id" not in requests[0]
+ assert manager.saved == []
+
+ def test_carrier_credentials_never_reach_the_warehouse(self, monkeypatch: Any) -> None:
+ # EasyPost masks password-type credential values but returns the rest in plaintext, and
+ # anyone who can query the warehouse can read a synced row.
+ _patch_response(
+ monkeypatch,
+ [
+ {
+ "id": "ca_1",
+ "type": "UspsAccount",
+ "fields": {"credentials": {"client_id": {"value": "123456"}}},
+ "credentials": {"client_id": "123456"},
+ "test_credentials": {"client_id": "123456"},
+ }
+ ],
+ )
+ rows = _collect(_FakeResumableManager(), endpoint="carrier_accounts")
+ assert rows == [{"id": "ca_1", "type": "UspsAccount"}]
+
+ def test_empty_response_yields_nothing(self, monkeypatch: Any) -> None:
+ _patch_response(monkeypatch, [])
+ assert _collect(_FakeResumableManager(), endpoint="carrier_accounts") == []
+
+
+class TestEndpointsWithoutServerSideTimeFilter:
+ def test_incremental_omits_start_datetime_but_still_stops_at_watermark(self, monkeypatch: Any) -> None:
+ # /end_shippers paginates by cursor but documents no start_datetime, so the descending
+ # client-side stop is the only thing bounding an incremental run.
+ requests = _patch_response(
+ monkeypatch,
+ {
+ "end_shippers": [
+ {"id": "es_2", "created_at": "2024-01-03T00:00:00Z"},
+ {"id": "es_1", "created_at": "2024-01-01T00:00:00Z"},
+ ],
+ "has_more": True,
+ },
+ )
+ rows = _collect(
+ _FakeResumableManager(),
+ endpoint="end_shippers",
+ should_use_incremental_field=True,
+ db_incremental_field_last_value=datetime(2024, 1, 2, tzinfo=UTC),
+ incremental_field="created_at",
+ )
+ assert [r["id"] for r in rows] == ["es_2"]
+ assert len(requests) == 1
+ assert "start_datetime" not in requests[0]
+
+
class TestValidateCredentials:
@parameterized.expand(
[("ok", 200, True), ("unauthorized", 401, False), ("inactive", 403, False), ("server", 500, False)]
@@ -198,8 +284,19 @@ class TestEasypostSource:
def test_source_response_shape(self, endpoint: str) -> None:
response = easypost_source("k", endpoint, MagicMock(), _FakeResumableManager()) # type: ignore[arg-type]
assert response.name == endpoint
- assert response.primary_keys == ["id"]
+ assert response.primary_keys
# EasyPost returns newest-first; the watermark logic depends on this being declared.
assert response.sort_mode == "desc"
- assert response.partition_mode == "datetime"
- assert response.partition_keys == ["created_at"]
+
+ def test_partition_settings_follow_the_partition_key(self) -> None:
+ # The lookup tables carry no stable creation timestamp, so an unset partition key has to
+ # switch every partition_* field off together — a stray mode or format would partition on
+ # a column that isn't there.
+ shipments = easypost_source("k", "shipments", MagicMock(), _FakeResumableManager()) # type: ignore[arg-type]
+ assert shipments.partition_mode == "datetime"
+ assert shipments.partition_keys == ["created_at"]
+
+ carriers = easypost_source("k", "carriers", MagicMock(), _FakeResumableManager()) # type: ignore[arg-type]
+ assert carriers.partition_mode is None
+ assert carriers.partition_format is None
+ assert carriers.partition_keys is None
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/easypost/tests/test_easypost_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/easypost/tests/test_easypost_source.py
index 8e3c9048aa5b..034f06da8bf1 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/easypost/tests/test_easypost_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/easypost/tests/test_easypost_source.py
@@ -4,7 +4,10 @@ from unittest.mock import MagicMock
from parameterized import parameterized
-from products.warehouse_sources.backend.temporal.data_imports.sources.easypost.settings import ENDPOINTS
+from products.warehouse_sources.backend.temporal.data_imports.sources.easypost.settings import (
+ EASYPOST_ENDPOINTS,
+ ENDPOINTS,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.easypost.source import EasypostSource
@@ -23,13 +26,31 @@ class TestGetSchemas:
schemas = EasypostSource().get_schemas(_config(), team_id=1, names=["shipments", "events"])
assert {s.name for s in schemas} == {"shipments", "events"}
- @parameterized.expand([(name,) for name in ENDPOINTS])
- def test_every_schema_advertises_created_at(self, endpoint: str) -> None:
+ @parameterized.expand([(name,) for name, c in EASYPOST_ENDPOINTS.items() if c.incremental_fields])
+ def test_every_syncable_schema_advertises_created_at(self, endpoint: str) -> None:
schemas = {s.name: s for s in EasypostSource().get_schemas(_config(), team_id=1)}
schema = schemas[endpoint]
assert [f["field"] for f in schema.incremental_fields] == ["created_at"]
assert schema.supports_append is True
+ @parameterized.expand([("carrier_accounts",), ("carriers",)])
+ def test_lookup_schemas_are_full_refresh_only(self, endpoint: str) -> None:
+ # These endpoints expose no cursor at all, so offering incremental or append would let a
+ # user pick a sync type that silently re-reads the whole collection every run.
+ schemas = {s.name: s for s in EasypostSource().get_schemas(_config(), team_id=1)}
+ schema = schemas[endpoint]
+ assert schema.incremental_fields == []
+ assert schema.supports_incremental is False
+ assert schema.supports_append is False
+
+ @parameterized.expand([("carrier_accounts",), ("end_shippers",)])
+ def test_restricted_endpoints_are_not_selected_by_default(self, endpoint: str) -> None:
+ # EasyPost gates both endpoints: /carrier_accounts rejects test keys, and the EndShipper
+ # API is opened per account. Selecting either by default fails a table nobody asked for.
+ schemas = {s.name: s for s in EasypostSource().get_schemas(_config(), team_id=1)}
+ assert schemas[endpoint].should_sync_default is False
+ assert schemas["shipments"].should_sync_default is True
+
def test_events_are_append_only(self) -> None:
# Events are immutable, so they're append-only (no incremental updates to existing rows).
schemas = {s.name: s for s in EasypostSource().get_schemas(_config(), team_id=1)}