: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(data-warehouse): add 4 missing tables to the Plain source (#119086)
Tom Owersa0b824003bfc
diff --git a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt b/posthog/test/repo_invariants/dataclass_frozen_baseline.txtindex 28ff6c34ea7e..b5ea92c10710 100644--- a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt+++ b/posthog/test/repo_invariants/dataclass_frozen_baseline.txt@@ -913,7 +913,6 @@1 products/warehouse_sources/backend/temporal/data_imports/sources/pipeliner/settings.py1 products/warehouse_sources/backend/temporal/data_imports/sources/plaid/plaid.py1 products/warehouse_sources/backend/temporal/data_imports/sources/plaid/settings.py-1 products/warehouse_sources/backend/temporal/data_imports/sources/plain/settings.py1 products/warehouse_sources/backend/temporal/data_imports/sources/planhat/planhat.py1 products/warehouse_sources/backend/temporal/data_imports/sources/planhat/settings.py1 products/warehouse_sources/backend/temporal/data_imports/sources/platform_sh/platform_sh.pydiff --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.mdindex 516f79ae9fbd..48fd3a8fe237 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@@ -9445,10 +9445,10 @@ Today (3): `customers`, `threads`, `timeline_entries`Diffed against: <https://core-api.uk.plain.com/graphql/v1/schema.graphql>-- [ ] `companies` — account-level entity that customers hang off; lookup for the company IDs already on synced customers (high)-- [ ] `users` — lookup resolving assignee and actor IDs carried on threads and timeline entries (high)-- [ ] `labelTypes` — lookup resolving the label IDs attached to synced threads (high)-- [ ] `tenants` — multi-tenant grouping dimension for customers and threads (high)+- [x] `companies` — account-level entity that customers hang off; lookup for the company IDs already on synced customers (high)+- [x] `users` — lookup resolving assignee and actor IDs carried on threads and timeline entries (high)+- [x] `labelTypes` — lookup resolving the label IDs attached to synced threads (high)+- [x] `tenants` — multi-tenant grouping dimension for customers and threads (high)- [ ] `customerSurveys` — CSAT responses, the headline support-quality metric (high)- [ ] `tiers` — SLA tier per company/tenant, needed to segment thread response times (medium)- [ ] `tasks` — work items attached to threads, needed for workload analysis (medium)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/plain/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/plain/canonical_descriptions.pyindex bd72a0f0f2e6..e42062c257f8 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/plain/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/plain/canonical_descriptions.py@@ -68,4 +68,74 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"entry": "The entry's content, varying by type (chat, email, note, or custom).",},},+ "companies": {+ "description": "A company in Plain. Customers are linked to a company, usually by their email domain.",+ "docs_url": "https://core-api.uk.plain.com/graphql/v1/schema.graphql",+ "columns": {+ "id": "Unique identifier for the company.",+ "name": "The company's name.",+ "domainName": "The primary domain name of the company. Plain uses it to link customers by email address.",+ "logoUrl": "URL of the company's logo image, if set.",+ "contractValue": "The annual contract value of the company in cents, if set.",+ "accountOwnerId": "ID of the Plain user who owns the company's account, if assigned.",+ "isDeleted": "Whether the company has been deleted.",+ "deletedAt": "Time at which the company was deleted, if applicable.",+ "deletedById": "ID of the actor that deleted the company, if applicable.",+ "createdAt": "Time at which the company was created.",+ "updatedAt": "Time at which the company was last updated.",+ },+ },+ "tenants": {+ "description": "A tenant in Plain: a group of customers, such as an account or workspace in your own product.",+ "docs_url": "https://www.plain.com/docs/graphql/tenants",+ "columns": {+ "id": "Unique identifier for the tenant.",+ "name": "The tenant's name.",+ "externalId": "Your own identifier for the tenant.",+ "url": "URL of the tenant in your own product or admin panel, if set.",+ "source": "How the tenant was created: through the API, an integration such as Salesforce or HubSpot, or an email domain.",+ "primaryDomain": "The primary domain name of the tenant, if set.",+ "alternateDomains": "Alternate domain names of the tenant.",+ "logoUrl": "URL of the tenant's logo image, if set.",+ "isDomainAutoJoinEnabled": "Whether customers with a matching email domain are added to the tenant automatically.",+ "createdAt": "Time at which the tenant was created.",+ "updatedAt": "Time at which the tenant was last updated.",+ },+ },+ "users": {+ "description": "A member of your Plain workspace. Users are the assignees and actors on threads and timeline entries.",+ "docs_url": "https://core-api.uk.plain.com/graphql/v1/schema.graphql",+ "columns": {+ "id": "Unique identifier for the user.",+ "fullName": "The user's full name.",+ "publicName": "The user's short name, as shown in the UI.",+ "email": "The user's email address.",+ "avatarUrl": "URL of the user's avatar, if set.",+ "status": "The user's current availability status.",+ "statusChangedAt": "Time at which the user's status last changed.",+ "isDeleted": "Whether the user has been removed from the workspace.",+ "deletedAt": "Time at which the user was removed, if applicable.",+ "isManagedByDirectory": "Whether the user is managed by directory sync.",+ "createdAt": "Time at which the user was created.",+ "updatedAt": "Time at which the user was last updated.",+ },+ },+ "label_types": {+ "description": "A label type in Plain. Labels on threads are instances of a label type.",+ "docs_url": "https://www.plain.com/docs/graphql/labels",+ "columns": {+ "id": "Unique identifier for the label type.",+ "name": "The label type's name.",+ "type": "Whether the label type is workspace-wide (DEFAULT) or belongs to one team (TEAM).",+ "description": "The label type's description, if set.",+ "position": "The position of the label type, relative to its parent.",+ "externalId": "Your own identifier for the label type, if set.",+ "parentLabelTypeId": "ID of the parent label type, if this label type is nested.",+ "isArchived": "Whether the label type is archived. Archived label types stay on threads but cannot be applied to new threads.",+ "archivedAt": "Time at which the label type was archived, if applicable.",+ "isExcludedFromAi": "Whether Plain's AI features skip this label type.",+ "createdAt": "Time at which the label type was created.",+ "updatedAt": "Time at which the label type was last updated.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/plain/plain.py b/products/warehouse_sources/backend/temporal/data_imports/sources/plain/plain.pyindex e864ea6334ef..8ce266ecea82 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/plain/plain.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/plain/plain.py@@ -31,6 +31,15 @@ _MESSAGE_INFO_FIELDS: list[tuple[str, str]] = [("lastOutboundMessageInfo", "lastOutboundMessageAt"),]+_ACTOR_FIELDS = ("createdBy", "updatedBy", "statusChangedBy", "markedAsSpamBy", "actor")+# Null on most rows, so always split them into Type/Id columns rather than keep a null struct column.+_NULLABLE_ACTOR_FIELDS = ("deletedBy", "archivedBy")++_REFERENCE_ID_FIELDS: list[tuple[str, str]] = [+ ("accountOwner", "accountOwnerId"),+ ("parentLabelType", "parentLabelTypeId"),+]+def _datetime_to_plain_iso8601(value: datetime) -> str:"""Serialize a datetime to an ISO-8601 format Plain accepts.@@ -122,13 +131,21 @@ def _flatten_node(node: dict[str, Any]) -> dict[str, Any]:label.get("labelType", {}).get("name") for label in labels if label and label.get("labelType")]- for actor_field in ["createdBy", "updatedBy", "statusChangedBy", "markedAsSpamBy", "actor"]:- if actor_field in flattened and isinstance(flattened[actor_field], dict):- actor = flattened.pop(actor_field)- flattened[f"{actor_field}Type"] = actor.get("actorType")- flattened[f"{actor_field}Id"] = (- actor.get("userId") or actor.get("machineUserId") or actor.get("customerId") or actor.get("systemId")- )+ for actor_field in (*_ACTOR_FIELDS, *_NULLABLE_ACTOR_FIELDS):+ if actor_field not in flattened:+ continue+ if not isinstance(flattened[actor_field], dict) and actor_field not in _NULLABLE_ACTOR_FIELDS:+ continue+ actor = flattened.pop(actor_field) or {}+ flattened[f"{actor_field}Type"] = actor.get("actorType")+ flattened[f"{actor_field}Id"] = (+ actor.get("userId") or actor.get("machineUserId") or actor.get("customerId") or actor.get("systemId")+ )++ for src_field, dst_field in _REFERENCE_ID_FIELDS:+ if src_field in flattened:+ reference = flattened.pop(src_field)+ flattened[dst_field] = reference.get("id") if isinstance(reference, dict) else Nonefor src_field, dst_field in _MESSAGE_INFO_FIELDS:if src_field in flattened:@@ -378,6 +395,7 @@ def plain_source(partition_mode=endpoint_config.partition_mode,partition_format=endpoint_config.partition_format,partition_keys=endpoint_config.partition_keys,+ sort_mode=endpoint_config.sort_mode,)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/plain/queries.py b/products/warehouse_sources/backend/temporal/data_imports/sources/plain/queries.pyindex 1ce865061c74..7bed3e1194fd 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/plain/queries.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/plain/queries.py@@ -227,10 +227,211 @@ query ThreadIdsList($first: Int!, $after: String, $filter: ThreadsFilter) {}}"""+COMPANIES_QUERY = """+query PaginatedCompanies($first: Int!, $after: String, $filter: CompaniesFilter) {+ companies(first: $first, after: $after, filters: $filter) {+ edges {+ node {+ id+ name+ domainName+ logoUrl+ contractValue+ accountOwner {+ id+ }+ isDeleted+ deletedAt {+ iso8601+ }+ deletedBy {+ actorType: __typename+ ... on UserActor { userId }+ ... on MachineUserActor { machineUserId }+ ... on SystemActor { systemId }+ }+ createdAt {+ iso8601+ }+ createdBy {+ actorType: __typename+ ... on UserActor { userId }+ ... on MachineUserActor { machineUserId }+ ... on SystemActor { systemId }+ }+ updatedAt {+ iso8601+ }+ updatedBy {+ actorType: __typename+ ... on UserActor { userId }+ ... on MachineUserActor { machineUserId }+ ... on SystemActor { systemId }+ }+ }+ }+ pageInfo {+ hasNextPage+ endCursor+ }+ }+}"""++USERS_QUERY = """+query PaginatedUsers($first: Int!, $after: String) {+ users(first: $first, after: $after) {+ edges {+ node {+ id+ fullName+ publicName+ avatarUrl+ status+ statusChangedAt {+ iso8601+ }+ isDeleted+ deletedAt {+ iso8601+ }+ deletedBy {+ actorType: __typename+ ... on UserActor { userId }+ ... on MachineUserActor { machineUserId }+ ... on SystemActor { systemId }+ }+ isManagedByDirectory+ createdAt {+ iso8601+ }+ createdBy {+ actorType: __typename+ ... on UserActor { userId }+ ... on MachineUserActor { machineUserId }+ ... on SystemActor { systemId }+ }+ updatedAt {+ iso8601+ }+ updatedBy {+ actorType: __typename+ ... on UserActor { userId }+ ... on MachineUserActor { machineUserId }+ ... on SystemActor { systemId }+ }+ }+ }+ pageInfo {+ hasNextPage+ endCursor+ }+ }+}"""++LABEL_TYPES_QUERY = """+query PaginatedLabelTypes($first: Int!, $after: String) {+ label_types: labelTypes(first: $first, after: $after) {+ edges {+ node {+ id+ name+ type+ description+ icon+ color+ position+ externalId+ parentLabelType {+ id+ }+ isArchived+ archivedAt {+ iso8601+ }+ archivedBy {+ actorType: __typename+ ... on UserActor { userId }+ ... on MachineUserActor { machineUserId }+ ... on SystemActor { systemId }+ }+ isExcludedFromAi+ createdAt {+ iso8601+ }+ createdBy {+ actorType: __typename+ ... on UserActor { userId }+ ... on MachineUserActor { machineUserId }+ ... on SystemActor { systemId }+ }+ updatedAt {+ iso8601+ }+ updatedBy {+ actorType: __typename+ ... on UserActor { userId }+ ... on MachineUserActor { machineUserId }+ ... on SystemActor { systemId }+ }+ }+ }+ pageInfo {+ hasNextPage+ endCursor+ }+ }+}"""++TENANTS_QUERY = """+query PaginatedTenants($first: Int!, $after: String, $filter: TenantsFilter) {+ tenants(first: $first, after: $after, filters: $filter) {+ edges {+ node {+ id+ name+ externalId+ url+ source+ primaryDomain+ alternateDomains+ logoUrl+ isDomainAutoJoinEnabled+ createdAt {+ iso8601+ }+ createdBy {+ actorType: __typename+ ... on UserActor { userId }+ ... on MachineUserActor { machineUserId }+ ... on SystemActor { systemId }+ }+ updatedAt {+ iso8601+ }+ updatedBy {+ actorType: __typename+ ... on UserActor { userId }+ ... on MachineUserActor { machineUserId }+ ... on SystemActor { systemId }+ }+ }+ }+ pageInfo {+ hasNextPage+ endCursor+ }+ }+}"""+VIEWER_QUERY = "{ myWorkspace { id name } }"QUERIES: dict[str, str] = {"customers": CUSTOMERS_QUERY,"threads": THREADS_QUERY,"timeline_entries": TIMELINE_ENTRIES_QUERY,+ "companies": COMPANIES_QUERY,+ "tenants": TENANTS_QUERY,+ "users": USERS_QUERY,+ "label_types": LABEL_TYPES_QUERY,}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/plain/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/plain/settings.pyindex c0bf57bbc950..3141d1a88146 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/plain/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/plain/settings.py@@ -1,8 +1,11 @@-from dataclasses import dataclass, field+from dataclasses import field++from posthog.dataclasses import frozenfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import (PartitionFormat,PartitionMode,+ SortMode,)from products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldType@@ -32,7 +35,7 @@ CREATED_AT_INCREMENTAL_FIELD: list[IncrementalField] = []-@dataclass+@frozenclass PlainEndpointConfig:incremental_fields: list[IncrementalField]primary_key: str = ID@@ -41,6 +44,7 @@ class PlainEndpointConfig:partition_mode: PartitionMode | None = "datetime"partition_format: PartitionFormat | None = "week"partition_keys: list[str] | None = field(default_factory=lambda: [CREATED_AT])+ sort_mode: SortMode = "asc"PLAIN_ENDPOINTS: dict[str, PlainEndpointConfig] = {@@ -54,6 +58,23 @@ PLAIN_ENDPOINTS: dict[str, PlainEndpointConfig] = {incremental_fields=CREATED_AT_INCREMENTAL_FIELD,partition_keys=[CREATED_AT],),+ # Plain documents no updatedAt order for companies and sorts tenants by name, so `desc` makes+ # the pipeline persist the watermark only when a sync completes.+ "companies": PlainEndpointConfig(+ incremental_fields=INCREMENTAL_DATETIME_FIELDS,+ sort_mode="desc",+ ),+ "tenants": PlainEndpointConfig(+ incremental_fields=INCREMENTAL_DATETIME_FIELDS,+ sort_mode="desc",+ ),+ # Neither list query accepts an updatedAt filter, so these are full refresh only.+ "users": PlainEndpointConfig(+ incremental_fields=[],+ ),+ "label_types": PlainEndpointConfig(+ incremental_fields=[],+ ),}ENDPOINTS = tuple(PLAIN_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/plain/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/plain/source.pyindex 37479122938b..fb352f22af28 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/plain/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/plain/source.py@@ -70,6 +70,8 @@ Make sure to grant the following read permissions:- label:read- company:read- machineUser:read+- labelType:read+- tenant:read""",iconPath="/static/services/plain.png",fields=cast(@@ -98,10 +100,10 @@ Make sure to grant the following read permissions:return {"401 Client Error": "Invalid Plain credentials. Please check your API key.",# Plain fails the whole GraphQL request when the key lacks a scope any requested field needs.- # Our customers/threads/timeline_entries queries read assignee (user:read), label (label:read),- # company (company:read), and machine-user actor (machineUser:read) data on top of the basics,- # so name every required scope — retrying a key missing one never succeeds.- "403 Client Error": "Access forbidden. Grant your Plain API key these read permissions, then reconnect: customer:read, thread:read, timeline:read, user:read, label:read, company:read, machineUser:read.",+ # Our queries read assignee (user:read), label (label:read, labelType:read), company+ # (company:read), tenant (tenant:read), and machine-user actor (machineUser:read) data on top+ # of the basics, so name every required scope — retrying a key missing one never succeeds.+ "403 Client Error": "Access forbidden. Grant your Plain API key these read permissions, then reconnect: customer:read, thread:read, timeline:read, user:read, label:read, labelType:read, company:read, tenant:read, machineUser:read.",}def get_retryable_errors(self) -> set[str]:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/plain/tests/test_plain.py b/products/warehouse_sources/backend/temporal/data_imports/sources/plain/tests/test_plain.pyindex ee459684a1f2..fc9fe24284d5 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/plain/tests/test_plain.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/plain/tests/test_plain.py@@ -1,4 +1,5 @@from datetime import UTC, datetime+from typing import Anyimport pytestfrom unittest import mock@@ -7,9 +8,11 @@ import requestsfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.testing import (ScriptedResponse,+ SourceDriver,always,scripted_network,)+from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.plain import PlainSourceConfigfrom products.warehouse_sources.backend.temporal.data_imports.sources.plain.plain import (_datetime_to_plain_iso8601,_fetch_paginated_endpoint,@@ -22,6 +25,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.plain.plaivalidate_credentials,)from products.warehouse_sources.backend.temporal.data_imports.sources.plain.queries import VIEWER_QUERY+from products.warehouse_sources.backend.temporal.data_imports.sources.plain.source import PlainSourceclass TestFlattenNode:@@ -80,6 +84,41 @@ class TestFlattenNode:assert result["firstInboundMessageAt"] == "2024-01-01T01:00:00Z"assert result["lastOutboundMessageAt"] is None+ @pytest.mark.parametrize(+ "node,expected",+ [+ (+ {"id": "co_1", "accountOwner": {"id": "u_1"}, "deletedBy": None, "deletedAt": None},+ {"accountOwnerId": "u_1", "deletedByType": None, "deletedById": None, "deletedAt": None},+ ),+ (+ {+ "id": "co_2",+ "accountOwner": None,+ "deletedBy": {"actorType": "MachineUserActor", "machineUserId": "mu_1"},+ },+ {"accountOwnerId": None, "deletedByType": "MachineUserActor", "deletedById": "mu_1"},+ ),+ (+ {"id": "lt_1", "parentLabelType": None, "archivedBy": None},+ {"parentLabelTypeId": None, "archivedByType": None, "archivedById": None},+ ),+ (+ {+ "id": "lt_2",+ "parentLabelType": {"id": "lt_1"},+ "archivedBy": {"actorType": "UserActor", "userId": "u_1"},+ },+ {"parentLabelTypeId": "lt_1", "archivedByType": "UserActor", "archivedById": "u_1"},+ ),+ ],+ )+ def test_flattens_nullable_references_into_stable_columns(self, node, expected):+ result = _flatten_node(node)++ assert {key: result[key] for key in expected} == expected+ assert not {"accountOwner", "parentLabelType", "deletedBy", "archivedBy"} & result.keys()+class TestFlattenTimelineEntry:def test_email_entry(self):@@ -349,3 +388,82 @@ class TestFetchTimelineEntriesStreaming:assert [e["id"] for e in pages[0]] == ["te_1"]# Threads query first, then TIMELINE_ENTRIES_QUERY after we've seen the first edge — no second threads page expected.assert "ThreadIdsList" in executed_queries[0]+++def _connection_page(endpoint: str, ids: list[str], end_cursor: str | None) -> ScriptedResponse:+ return ScriptedResponse(+ json={+ "data": {+ endpoint: {+ "edges": [+ {"node": {"id": node_id, "createdAt": {"iso8601": "2024-01-01T00:00:00Z"}}} for node_id in ids+ ],+ "pageInfo": {"hasNextPage": end_cursor is not None, "endCursor": end_cursor},+ }+ }+ }+ )+++def _run(endpoint: str, script: list[ScriptedResponse], **inputs: Any):+ return SourceDriver(PlainSource(), PlainSourceConfig(api_key="plainApiKey_test")).run(endpoint, script, **inputs)+++class TestLookupEndpoints:+ @pytest.mark.parametrize(+ "endpoint,operation",+ [+ ("companies", "PaginatedCompanies"),+ ("tenants", "PaginatedTenants"),+ ("users", "PaginatedUsers"),+ ("label_types", "PaginatedLabelTypes"),+ ],+ )+ def test_walks_pages_until_has_next_page_is_false(self, endpoint, operation):+ result = _run(+ endpoint,+ [_connection_page(endpoint, ["a", "b"], "cursor_1"), _connection_page(endpoint, ["c"], None)],+ )++ assert [row["id"] for row in result.rows] == ["a", "b", "c"]+ assert result.rows[0]["createdAt"] == "2024-01-01T00:00:00Z"+ bodies = [request.json() for request in result.requests]+ assert all(f"query {operation}(" in body["query"] for body in bodies)+ assert [body["variables"].get("after") for body in bodies] == [None, "cursor_1"]++ @pytest.mark.parametrize(+ "endpoint,incremental,expected_filter",+ [+ ("companies", True, {"updatedAt": {"after": "2024-03-01T12:00:00Z"}}),+ ("tenants", True, {"updatedAt": {"after": "2024-03-01T12:00:00Z"}}),+ ("companies", False, None),+ ("tenants", False, None),+ ],+ )+ def test_incremental_sync_sends_updated_at_filter(self, endpoint, incremental, expected_filter):+ inputs: dict[str, Any] = (+ {"incremental_field": "updatedAt", "db_incremental_field_last_value": datetime(2024, 3, 1, 12, tzinfo=UTC)}+ if incremental+ else {}+ )++ result = _run(endpoint, [_connection_page(endpoint, ["a"], None)], **inputs)++ body = result.requests[0].json()+ assert body["variables"].get("filter") == expected_filter+ assert "$filter" in body["query"]++ @pytest.mark.parametrize(+ "endpoint,expected_sort_mode",+ [+ ("companies", "desc"),+ ("tenants", "desc"),+ ("users", "asc"),+ ("label_types", "asc"),+ ],+ )+ def test_source_for_pipeline_sets_sort_mode(self, endpoint, expected_sort_mode):+ result = _run(endpoint, [_connection_page(endpoint, ["a"], None)])++ assert result.response is not None+ assert result.response.sort_mode == expected_sort_mode