Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiedemaria committed Nov 14, 2024
1 parent 05f28a8 commit 10cd2d9
Showing 1 changed file with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"]

0 comments on commit 10cd2d9

Please sign in to comment.