From 10cd2d97f2ad653b5793ce108b2e17943599f2e1 Mon Sep 17 00:00:00 2001 From: JamieDeMaria Date: Wed, 13 Nov 2024 15:03:39 -0500 Subject: [PATCH] test --- .../graphql/test_runs_feed.py | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/python_modules/dagster-graphql/dagster_graphql_tests/graphql/test_runs_feed.py b/python_modules/dagster-graphql/dagster_graphql_tests/graphql/test_runs_feed.py index 776dd3370f887..2455e716759f6 100644 --- a/python_modules/dagster-graphql/dagster_graphql_tests/graphql/test_runs_feed.py +++ b/python_modules/dagster-graphql/dagster_graphql_tests/graphql/test_runs_feed.py @@ -1,5 +1,6 @@ import time from typing import Mapping, Optional +from unittest import mock import pytest from dagster._core.execution.backfill import BulkActionStatus, PartitionBackfill @@ -56,6 +57,30 @@ } """ +MINIMAL_GET_RUNS_FEED_QUERY = """ +query RunsFeedEntryQuery($cursor: String, $limit: Int!, $filter: RunsFilter, $includeRunsFromBackfills: Boolean!) { + runsFeedOrError(cursor: $cursor, limit: $limit, filter: $filter, includeRunsFromBackfills: $includeRunsFromBackfills) { + ... on RunsFeedConnection { + results { + __typename + id + } + cursor + hasMore + } + ... on PythonError { + stack + message + } + } + runsFeedCountOrError(filter: $filter, includeRunsFromBackfills: $includeRunsFromBackfills) { + ... on RunsFeedCount { + count + } + } +} +""" + # when runs are inserted into the database, sqlite uses CURRENT_TIMESTAMP to set the creation time. # CURRENT_TIMESTAMP only has second precision for sqlite, so if we create runs and backfills without any delay # the resulting list is a chunk of runs and then a chunk of backfills when ordered by time. Adding a small @@ -1304,3 +1329,34 @@ def test_get_backfill_id_filter(self, graphql_context): assert not result.errors assert result.data _assert_results_match_count_match_expected(result, 0) + + def test_runs_not_fetched_when_excluding_subruns_and_filtering_backfills(self, graphql_context): + # TestRunsFeedUniqueSetups::test_runs_not_fetched_when_excluding_subruns_and_filtering_backfills + def _fake_get_run_records(*args, **kwargs): + raise Exception("get_run_records should not be called") + + backfill_id = _create_backfill(graphql_context) + _create_run_for_backfill(graphql_context, backfill_id) + _create_run_for_backfill(graphql_context, backfill_id) + _create_run_for_backfill(graphql_context, backfill_id) + + with mock.patch.object(graphql_context.instance, "get_run_records", _fake_get_run_records): + result = execute_dagster_graphql( + graphql_context, + MINIMAL_GET_RUNS_FEED_QUERY, + variables={ + "limit": 20, + "cursor": None, + "filter": { + "tags": [ + {"key": BACKFILL_ID_TAG, "value": backfill_id}, + ] + }, + "includeRunsFromBackfills": False, + }, + ) + + assert not result.errors + assert result.data + assert len(result.data["runsFeedOrError"]["results"]) == 1 + assert not result.data["runsFeedOrError"]["hasMore"]