Skip to content

Commit

Permalink
Add regression test for arbitrary state data (#15506)
Browse files Browse the repository at this point in the history
  • Loading branch information
desertaxle authored Sep 26, 2024
1 parent a15bd82 commit 13b57d0
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/test_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
from prefect import flow
from prefect.exceptions import CancelledRun, CrashedRun, FailedRun
from prefect.results import (
PersistedResult,
ResultRecord,
ResultRecordMetadata,
ResultStore,
)
from prefect.serializers import JSONSerializer
from prefect.states import (
Cancelled,
Completed,
Expand Down Expand Up @@ -377,3 +380,27 @@ def test_counts_message_some_non_final(self):
assert "'FAILED'=1" in counts_message
assert "'CRASHED'=1" in counts_message
assert "'RUNNING'=2" in counts_message


def test_state_returns_expected_result(ignore_prefect_deprecation_warnings):
"""
Regression test for https://github.com/PrefectHQ/prefect/issues/14927
"""
state = Completed(data="test")
assert state.result() == "test"

state = Completed(
data=ResultRecord(
result="test",
metadata=ResultRecordMetadata(
serializer=JSONSerializer(), storage_key="test"
),
)
)
assert state.result() == "test"

# legacy case
result = PersistedResult(serializer_type="pickle", storage_key="test")
result._cache = "test"
state = Completed(data=result)
assert state.result() == "test"

0 comments on commit 13b57d0

Please sign in to comment.