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(data-warehouse): add 4 missing tables to the Gusto source (#124500)

Tom Owers5b28a7d26322
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 d6fbb0756bc8..4e043cbcd8d4 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
@@ -5676,17 +5676,17 @@ Note: developer.getguru.com is a ReadMe site with no downloadable OpenAPI (opena
## Gusto — gaps
-Today (14): `ach_transactions`, `companies`, `company_benefits`, `contractor_payments`, `contractors`, `departments`, `employees`, `jobs`, `locations`, `pay_periods`, `pay_schedules`, `payrolls`, `recurring_reimbursements`, `tax_payments`
+Today (18): `ach_transactions`, `companies`, `company_benefits`, `contractor_payments`, `contractors`, `departments`, `earning_types`, `employee_benefits`, `employees`, `employment_history`, `jobs`, `locations`, `pay_periods`, `pay_schedules`, `payrolls`, `recurring_reimbursements`, `tax_payments`, `time_off_requests`
Diffed against: <https://docs.gusto.com/embedded-payroll/llms.txt>
- [x] `Departments (GET /v1/companies/{company_uuid}/departments)` — resolve department_uuid values on employees and analyze workforce composition by department (high)
- [x] `ACH transactions (GET /v1/companies/{company_uuid}/ach_transactions)` — reconcile payroll funding and payment movements with bank transaction status and failures (high)
- [x] `Company benefits (GET /v1/companies/{company_id}/company_benefits)` — explain employee deductions and employer contributions using named benefit plans (high)
-- [ ] `Earning types (GET /v1/companies/{company_id}/earning_types)` — separate standard earnings from custom pay categories in payroll analysis (medium)
-- [ ] `Employee benefits (GET /v1/company_benefits/{company_benefit_id}/employee_benefits)` — measure benefit enrollment, employee deductions, and employer contribution arrangements (medium)
-- [ ] `Employment history (GET /v1/employees/{employee_id}/employment_history)` — analyze terminations, rehires, tenure, and workforce changes beyond current employment status (medium)
-- [ ] `Time off requests (GET /v1/companies/{company_uuid}/time_off/requests)` — track requested and approved leave, absence patterns, and approval delays (medium)
+- [x] `Earning types (GET /v1/companies/{company_id}/earning_types)` — separate standard earnings from custom pay categories in payroll analysis (medium)
+- [x] `Employee benefits (GET /v1/company_benefits/{company_benefit_id}/employee_benefits)` — measure benefit enrollment, employee deductions, and employer contribution arrangements (medium)
+- [x] `Employment history (GET /v1/employees/{employee_id}/employment_history)` — analyze terminations, rehires, tenure, and workforce changes beyond current employment status (medium)
+- [x] `Time off requests (GET /v1/companies/{company_uuid}/time_off/requests)` — track requested and approved leave, absence patterns, and approval delays (medium)
- [ ] `Employee time off activities (GET /v1/employees/{employee_uuid}/time_off_activities)` — explain leave balance changes through accrual, usage, and adjustment activity (medium)
- [x] `Recurring reimbursements (GET /v1/employees/{employee_id}/recurring_reimbursements)` — forecast recurring employee reimbursements separately from amounts already paid through payroll (medium)
- [ ] `Events (GET /v1/events)` — track payroll and employee changes as events instead of inferring them from repeated snapshots (medium)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gusto/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gusto/canonical_descriptions.py
index 3ff0eaf3e1bf..767ae0300c61 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gusto/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gusto/canonical_descriptions.py
@@ -266,4 +266,76 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"_employee_uuid": "The employee this reimbursement belongs to.",
},
},
+ "earning_types": {
+ "description": "A type of earning a company can pay through payroll, such as a bonus or commission. Default types carry tax rules and are mostly the same for every company; custom types are added by the company.",
+ "docs_url": "https://docs.gusto.com/embedded-payroll/reference/get-v1-companies-company_id-earning_types",
+ "columns": {
+ "uuid": "The unique identifier of the earning type.",
+ "name": "The name of the earning type.",
+ "active": "Whether the earning type is active.",
+ "category": "The earning type category. Only present when the company has access to categorized custom bonus earning types.",
+ "included_in_overtime_pay": "Whether earnings of this type count toward the regular rate of pay for overtime.",
+ "is_default": "Whether this is one of Gusto's default earning types (true) or a custom earning type of the company (false).",
+ "_company_uuid": "The company this earning type belongs to.",
+ },
+ },
+ "employee_benefits": {
+ "description": "An employee's enrollment in a company benefit, with the employee deduction and company contribution for each pay period.",
+ "docs_url": "https://docs.gusto.com/embedded-payroll/reference/get-v1-company_benefits-company_benefit_id-employee_benefits",
+ "columns": {
+ "uuid": "The unique identifier of the employee benefit.",
+ "employee_uuid": "The employee enrolled in the benefit.",
+ "company_benefit_uuid": "The company benefit the employee is enrolled in.",
+ "active": "Whether the employee benefit is active.",
+ "employee_deduction": "The amount deducted from the employee's pay each pay period.",
+ "deduct_as_percentage": "Whether employee_deduction is a percentage of each payroll instead of a fixed amount.",
+ "employee_deduction_annual_maximum": "The maximum employee deduction per year. Null means no limit.",
+ "company_contribution": "The amount the company pays each pay period. Not present for tiered contributions.",
+ "contribute_as_percentage": "Whether company_contribution is a percentage of each payroll instead of a fixed amount.",
+ "company_contribution_annual_maximum": "The maximum company contribution per year. Null means no limit.",
+ "contribution": "The type and value of the company contribution.",
+ "elective": "Whether the company contribution is elective (matching). Always true for tiered contributions.",
+ "catch_up": "Whether the employee uses the benefit's catch-up rate (401(k) and Roth 401(k) only).",
+ "limit_option": "Extra information some benefits need to set their limit, such as Family or Individual for an HSA.",
+ "retirement_loan_identifier": "The identifier the 401(k) provider assigned to a 401(k) loan.",
+ "coverage_amount": "The amount the employee is insured for.",
+ "coverage_salary_multiplier": "The coverage amount as a multiple of the employee's salary (Group Term Life only).",
+ "deduction_reduces_taxable_income": "Whether the employee deduction reduces taxable income (Group Term Life only).",
+ "effective_date": "The date the employee benefit starts.",
+ "expiration_date": "The date the employee benefit expires. Null means it does not expire.",
+ "version": "The current version of the employee benefit object, used for optimistic concurrency.",
+ "_company_uuid": "The company that offers the benefit.",
+ "_company_benefit_uuid": "The company benefit this enrollment was read from.",
+ },
+ },
+ "employment_history": {
+ "description": "One period of employment for an employee, from hire to termination. Rehired employees have one row for each employment.",
+ "docs_url": "https://docs.gusto.com/embedded-payroll/reference/get-v1-employees-employee_id-employment_history",
+ "columns": {
+ "hire_date": "The employee's first day of work for this employment.",
+ "termination_date": "The employee's last day of work for this employment. Null while the employment continues.",
+ "employment_status": "The employment status, such as full_time, part_time, or seasonal.",
+ "file_new_hire_report": "Whether Gusto files a new hire report for the employee.",
+ "two_percent_shareholder": "Whether the employee is a two percent shareholder of the company (S-Corp only).",
+ "_company_uuid": "The company that employs the employee.",
+ "_employee_uuid": "The employee this employment belongs to.",
+ },
+ },
+ "time_off_requests": {
+ "description": "An employee's request for time off under a time off policy, with its approval status and the hours requested for each day.",
+ "docs_url": "https://docs.gusto.com/embedded-payroll/reference/get-v1-companies-company_uuid-time_off-requests",
+ "columns": {
+ "uuid": "The unique identifier of the time off request.",
+ "status": "The request status: pending, approved, declined, or consumed (processed in a completed payroll).",
+ "employee_note": "A note about the request from the employee to the employer.",
+ "employer_note": "A note about the request from the employer to the employee.",
+ "policy_type": "The type of the time off policy, such as vacation or sick.",
+ "policy_uuid": "The time off policy the request is made under.",
+ "days": "The requested days, as an object that maps each date (YYYY-MM-DD) to the hours requested.",
+ "employee": "The employee who takes the time off.",
+ "initiator": "The person who created the request.",
+ "approver": "The person who approved the request. Null when the request is not approved.",
+ "_company_uuid": "The company the request belongs to.",
+ },
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gusto/gusto.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gusto/gusto.py
index 916c2f760d94..76a0e644716a 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gusto/gusto.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gusto/gusto.py
@@ -12,6 +12,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.res
from products.warehouse_sources.backend.temporal.data_imports.sources.common.sync_window import SyncWindow
from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponse
from products.warehouse_sources.backend.temporal.data_imports.sources.gusto.settings import (
+ FAN_OUT_PARENT_KEYS,
GUSTO_ENDPOINTS,
GustoEndpointConfig,
)
@@ -43,13 +44,15 @@ FUTURE_WINDOW_DAYS = 365
WINDOW_CHUNK_SIZE = 1000
[email protected](frozen=True)
class GustoResumeConfig:
# Index into the ordered company list to restart at.
company_index: int = 0
- # Next 1-indexed page to fetch within that company.
+ # Next 1-indexed page to fetch within that company, or within the current parent of a
+ # paginated fan-out endpoint.
next_page: int = 1
- # For endpoints fanned out over employees: index into that company's ordered employee list.
+ # For fan-out endpoints: index into that company's ordered parent list (employees, or company
+ # benefits). The name predates fan-out over other parents and is kept so saved state still loads.
employee_index: int = 0
@@ -225,6 +228,15 @@ def extract_rows(config: GustoEndpointConfig, body: Any) -> list[dict[str, Any]]
if not isinstance(body, dict):
return []
+ if config.name == "earning_types":
+ # Default and custom earning types arrive as two lists; keep which list each one came from.
+ return [
+ {**row, "is_default": kind == "default"}
+ for kind in ("default", "custom")
+ for row in body.get(kind) or []
+ if isinstance(row, dict)
+ ]
+
if config.data_key is None:
return _normalize_rows(config, [body])
@@ -275,14 +287,18 @@ def _paginate(
client.logger.warning(f"Gusto page cap reached, stopping early. endpoint={config.name}, path={path}")
-def _company_employees(client: GustoClient, company_uuid: str) -> list[dict[str, Any]]:
- """Every employee of a company, ordered by uuid so fan-out resumes deterministically."""
- config = GUSTO_ENDPOINTS["employees"]
+def _company_parents(client: GustoClient, parent_endpoint: str, company_uuid: str) -> list[dict[str, Any]]:
+ """Every fan-out parent row of a company, ordered by uuid so fan-out resumes deterministically."""
+ config = GUSTO_ENDPOINTS[parent_endpoint]
path = config.path.format(company_uuid=company_uuid)
- employees: list[dict[str, Any]] = []
- for batch in _paginate(client, config, path, {}, first_page=1):
- employees.extend(batch)
- return sorted(employees, key=lambda employee: str(employee.get("uuid") or ""))
+ parents: list[dict[str, Any]] = []
+ if config.paginated:
+ for batch in _paginate(client, config, path, {}, first_page=1):
+ parents.extend(batch)
+ else:
+ body, _ = client.get_json(path)
+ parents.extend(extract_rows(config, body))
+ return sorted(parents, key=lambda parent: str(parent.get("uuid") or ""))
def _windowed_rows(
@@ -343,6 +359,14 @@ def get_rows(
return save
+ def checkpoint_parent_page(company_index: int, parent_index: int) -> Callable[[int], None]:
+ def save(page: int) -> None:
+ resumable_source_manager.save_state(
+ GustoResumeConfig(company_index=company_index, employee_index=parent_index, next_page=page)
+ )
+
+ return save
+
resume = resumable_source_manager.load_state() if resumable_source_manager.can_resume() else None
if resume is not None:
logger.debug(
@@ -363,19 +387,35 @@ def get_rows(
rows = extract_rows(config, body)
if rows:
yield rows
- elif config.fans_out_over_employees:
- employees = _company_employees(client, company_uuid)
- first_employee = resume.employee_index if (resuming_here and resume is not None) else 0
- for employee_index, employee in enumerate(employees):
- if employee_index < first_employee:
+ elif config.fan_out_parent is not None:
+ parent_key = FAN_OUT_PARENT_KEYS[config.fan_out_parent]
+ fan_out_parents = _company_parents(client, config.fan_out_parent, company_uuid)
+ first_parent = resume.employee_index if (resuming_here and resume is not None) else 0
+ for parent_index, parent in enumerate(fan_out_parents):
+ if parent_index < first_parent:
continue
- employee_uuid = str(employee.get("uuid") or "")
- body, _ = client.get_json(config.path.format(employee_uuid=employee_uuid))
- rows = _stamp_parents(extract_rows(config, body), {**parents, "_employee_uuid": employee_uuid})
- if rows:
- yield rows
+ parent_uuid = str(parent.get("uuid") or "")
+ path = config.path.format(**{parent_key: parent_uuid})
+ child_parents = {**parents, f"_{parent_key}": parent_uuid}
+ if config.paginated:
+ yield from _paginate(
+ client,
+ config,
+ path,
+ child_parents,
+ first_page=resume.next_page
+ if (resuming_here and resume is not None and parent_index == first_parent)
+ else 1,
+ extra_params=config.extra_params,
+ on_page=checkpoint_parent_page(company_index, parent_index),
+ )
+ else:
+ body, _ = client.get_json(path)
+ rows = _stamp_parents(extract_rows(config, body), child_parents)
+ if rows:
+ yield rows
resumable_source_manager.save_state(
- GustoResumeConfig(company_index=company_index, employee_index=employee_index + 1)
+ GustoResumeConfig(company_index=company_index, employee_index=parent_index + 1)
)
elif not config.paginated:
# These lists document no `page`/`per` and return everything at once, so one request covers them.
@@ -391,6 +431,7 @@ def get_rows(
config.path.format(company_uuid=company_uuid),
parents,
first_page=first_page,
+ extra_params=config.extra_params,
on_page=checkpoint_page(company_index),
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gusto/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gusto/settings.py
index bb6dc207406e..4bfd927ab2df 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gusto/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gusto/settings.py
@@ -16,12 +16,23 @@ class GustoEndpointConfig:
# walked in full. The value is the row field the window filters on, which is also the only
# incremental cursor Gusto offers.
date_window_field: str | None = None
- # Fan-out endpoints are fetched once per employee of each company.
- fans_out_over_employees: bool = False
+ # Fan-out endpoints are fetched once per row of this parent endpoint (see FAN_OUT_PARENT_KEYS)
+ # in each company.
+ fan_out_parent: str | None = None
+ # Static query parameters sent on every page of a paginated endpoint.
+ extra_params: dict[str, str] | None = None
# Rows nested under this key in the response body (None = the body is the array itself).
data_key: str | None = None
+# Fan-out parent endpoint -> the path placeholder its uuid fills. The child rows carry the parent
+# uuid as the same name with a leading `_`.
+FAN_OUT_PARENT_KEYS: dict[str, str] = {
+ "employees": "employee_uuid",
+ "company_benefits": "company_benefit_uuid",
+}
+
+
# Gusto REST API (https://docs.gusto.com/embedded-payroll/reference). Every data endpoint is
# company-scoped, so each stream fans out over the companies the access token can reach
# (`GET /v1/me`). Only the money-movement endpoints accept a server-side date filter — the people
@@ -49,7 +60,7 @@ GUSTO_ENDPOINTS: dict[str, GustoEndpointConfig] = {
# Job uuids are not documented as globally unique, so the parent employee is part of the key.
primary_keys=["_employee_uuid", "uuid"],
paginated=False,
- fans_out_over_employees=True,
+ fan_out_parent="employees",
),
"contractors": GustoEndpointConfig(
name="contractors",
@@ -118,7 +129,41 @@ GUSTO_ENDPOINTS: dict[str, GustoEndpointConfig] = {
path="/v1/employees/{employee_uuid}/recurring_reimbursements",
primary_keys=["_employee_uuid", "uuid"],
paginated=False,
- fans_out_over_employees=True,
+ fan_out_parent="employees",
+ ),
+ "earning_types": GustoEndpointConfig(
+ name="earning_types",
+ path="/v1/companies/{company_uuid}/earning_types",
+ # Default earning types are mostly the same for every company, and Gusto doesn't document
+ # earning type uuids as unique across companies.
+ primary_keys=["_company_uuid", "uuid"],
+ paginated=False,
+ ),
+ "employee_benefits": GustoEndpointConfig(
+ name="employee_benefits",
+ path="/v1/company_benefits/{company_benefit_uuid}/employee_benefits",
+ primary_keys=["_company_benefit_uuid", "uuid"],
+ fan_out_parent="company_benefits",
+ # By default Gusto returns only the benefits active today, not past or future effective-dated ones.
+ extra_params={"include": "all_benefits"},
+ ),
+ "employment_history": GustoEndpointConfig(
+ name="employment_history",
+ path="/v1/employees/{employee_uuid}/employment_history",
+ # Employments carry no identifier; a rehire starts a new employment with a new hire date.
+ primary_keys=["_employee_uuid", "hire_date"],
+ paginated=False,
+ fan_out_parent="employees",
+ ),
+ # The date filters here match requests whose days overlap the window, not requests that changed,
+ # and `status` moves from pending to approved or consumed later, so full refresh keeps it current.
+ "time_off_requests": GustoEndpointConfig(
+ name="time_off_requests",
+ path="/v1/companies/{company_uuid}/time_off/requests",
+ primary_keys=["_company_uuid", "uuid"],
+ # The default is newest start date first; ascending puts new (mostly future) requests on
+ # the last page instead of shifting every page mid-walk.
+ extra_params={"sort_order": "asc"},
),
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gusto/tests/test_gusto.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gusto/tests/test_gusto.py
index 395cf1699b4e..3133dd8a34c5 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gusto/tests/test_gusto.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gusto/tests/test_gusto.py
@@ -134,6 +134,24 @@ class TestExtractRows:
# still merge instead of seeding null-keyed duplicates.
assert extract_rows(GUSTO_ENDPOINTS["payrolls"], [row])[0]["payroll_uuid"] == expected
+ @parameterized.expand(
+ [
+ (
+ "default_and_custom",
+ {"default": [{"uuid": "et-1", "name": "Bonus"}], "custom": [{"uuid": "et-2", "name": "Stipend"}]},
+ [("et-1", True), ("et-2", False)],
+ ),
+ ("no_custom_list", {"default": [{"uuid": "et-1"}]}, [("et-1", True)]),
+ ("null_lists", {"default": None, "custom": None}, []),
+ ("non_mapping_entries_dropped", {"default": ["Bonus", {"uuid": "et-1"}], "custom": [7]}, [("et-1", True)]),
+ ]
+ )
+ def test_earning_types_flatten_both_lists(
+ self, _name: str, body: dict[str, Any], expected: list[tuple[str, bool]]
+ ) -> None:
+ rows = extract_rows(GUSTO_ENDPOINTS["earning_types"], body)
+ assert [(row["uuid"], row["is_default"]) for row in rows] == expected
+
def test_non_mapping_body_yields_nothing(self) -> None:
assert extract_rows(GUSTO_ENDPOINTS["employees"], "oops") == []
@@ -234,6 +252,21 @@ class TestGetRowsPaginated:
assert [row["uuid"] for row in result.rows] == ["e-1"]
assert result.params("page") == [None, None, "1", "2"]
+ def test_static_params_are_sent_on_every_page(self) -> None:
+ result = _driver().run(
+ "time_off_requests",
+ [
+ _token(),
+ ScriptedResponse(json=_me_body(["c-1"])),
+ ScriptedResponse(json=[{"uuid": "t-1"}], headers={"X-Total-Pages": "2"}),
+ ScriptedResponse(json=[{"uuid": "t-2"}], headers={"X-Total-Pages": "2"}),
+ ],
+ )
+ assert result.raised is None
+ assert [row["uuid"] for row in result.rows] == ["t-1", "t-2"]
+ assert result.params("page")[2:] == ["1", "2"]
+ assert result.params("sort_order")[2:] == ["asc", "asc"]
+
class TestGetRowsCompanies:
def test_yields_the_full_company_detail_per_company(self) -> None:
@@ -281,6 +314,66 @@ class TestGetRowsFanOut:
assert [row["_employee_uuid"] for row in result.rows] == ["e-2"]
assert result.paths[-1] == "/v1/employees/e-2/jobs"
+ @parameterized.expand(
+ [
+ (
+ "full_walk",
+ None,
+ [
+ "/v1/company_benefits/cb-1/employee_benefits",
+ "/v1/company_benefits/cb-1/employee_benefits",
+ "/v1/company_benefits/cb-2/employee_benefits",
+ ],
+ [("cb-1", "eb-1"), ("cb-1", "eb-2"), ("cb-2", "eb-3")],
+ ),
+ (
+ "resume_after_first_benefit",
+ GustoResumeConfig(company_index=0, employee_index=1),
+ ["/v1/company_benefits/cb-2/employee_benefits"],
+ [("cb-2", "eb-3")],
+ ),
+ (
+ "resume_partway_through_a_benefit",
+ GustoResumeConfig(company_index=0, employee_index=0, next_page=2),
+ [
+ "/v1/company_benefits/cb-1/employee_benefits",
+ "/v1/company_benefits/cb-2/employee_benefits",
+ ],
+ [("cb-1", "eb-2"), ("cb-2", "eb-3")],
+ ),
+ ]
+ )
+ def test_walks_every_page_of_each_company_benefit(
+ self,
+ _name: str,
+ resume_state: Optional[GustoResumeConfig],
+ expected_child_paths: list[str],
+ expected_rows: list[tuple[str, str]],
+ ) -> None:
+ pages = {
+ ("cb-1", "1"): ScriptedResponse(json=[{"uuid": "eb-1"}], headers={"X-Total-Pages": "2"}),
+ ("cb-1", "2"): ScriptedResponse(json=[{"uuid": "eb-2"}], headers={"X-Total-Pages": "2"}),
+ ("cb-2", "1"): ScriptedResponse(json=[{"uuid": "eb-3"}], headers={"X-Total-Pages": "1"}),
+ }
+
+ def respond(request: RecordedRequest) -> ScriptedResponse:
+ if request.path == "/oauth/token":
+ return _token()
+ if request.path == "/v1/me":
+ return ScriptedResponse(json=_me_body(["c-1"]))
+ if request.path == "/v1/companies/c-1/company_benefits":
+ # Out of order on purpose: resume indexes into the uuid-sorted list.
+ return ScriptedResponse(json=[{"uuid": "cb-2"}, {"uuid": "cb-1"}])
+ benefit_uuid = request.path.split("/")[3]
+ return pages[(benefit_uuid, request.param("page") or "")]
+
+ result = _driver().run("employee_benefits", respond, resume_state=resume_state)
+ assert result.raised is None
+ assert result.paths[3:] == expected_child_paths
+ assert [(row["_company_benefit_uuid"], row["uuid"]) for row in result.rows] == expected_rows
+ assert {row["_company_uuid"] for row in result.rows} == {"c-1"}
+ assert set(result.params("include")[3:]) == {"all_benefits"}
+
class TestGetRowsWindowed:
def _payroll_script(self) -> list[ScriptedResponse]:
@@ -338,7 +431,17 @@ class TestGustoSourceResponse:
assert result.response.primary_keys == GUSTO_ENDPOINTS[endpoint].primary_keys
assert result.response.sort_mode == "asc"
- @parameterized.expand([("jobs",), ("recurring_reimbursements",), ("contractor_payments",), ("pay_periods",)])
+ @parameterized.expand(
+ [
+ ("jobs",),
+ ("recurring_reimbursements",),
+ ("contractor_payments",),
+ ("pay_periods",),
+ ("earning_types",),
+ ("employee_benefits",),
+ ("employment_history",),
+ ]
+ )
def test_fan_out_and_keyless_tables_include_their_parent_in_the_key(self, endpoint: str) -> None:
# Child rows from every parent land in one table, so a per-parent identifier alone would
# collide and make each merge multi-match.