From 3b59f9b55e118ae191be79ba8b522360096c85e1 Mon Sep 17 00:00:00 2001 From: Alex Langenfeld Date: Mon, 18 Sep 2023 16:58:32 -0500 Subject: [PATCH] [storage tests] runless events (#16520) update storage tests to ensure runless asset events work across storages related to https://github.com/dagster-io/dagster/pull/16424 ## How I Tested These Changes --- .../storage_tests/utils/event_log_storage.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/python_modules/dagster/dagster_tests/storage_tests/utils/event_log_storage.py b/python_modules/dagster/dagster_tests/storage_tests/utils/event_log_storage.py index a3bc122214c4d..5d47a57660f7f 100644 --- a/python_modules/dagster/dagster_tests/storage_tests/utils/event_log_storage.py +++ b/python_modules/dagster/dagster_tests/storage_tests/utils/event_log_storage.py @@ -67,6 +67,7 @@ ExternalRepositoryOrigin, InProcessCodeLocationOrigin, ) +from dagster._core.instance import RUNLESS_JOB_NAME, RUNLESS_RUN_ID from dagster._core.storage.asset_check_execution_record import ( AssetCheckExecutionRecordStatus, ) @@ -3965,3 +3966,26 @@ def test_asset_checks(self, storage): AssetKey(["my_asset"]), "my_check", limit=10, materialization_event_storage_id=42 ) assert len(checks) == 1 + + def test_external_asset_event(self, storage): + key = AssetKey("test_asset") + log_entry = EventLogEntry( + error_info=None, + user_message="", + level="debug", + run_id=RUNLESS_RUN_ID, + timestamp=time.time(), + dagster_event=DagsterEvent( + event_type_value=DagsterEventType.ASSET_MATERIALIZATION.value, + job_name=RUNLESS_JOB_NAME, + event_specific_data=StepMaterializationData( + materialization=AssetMaterialization(asset_key=key, metadata={"was": "here"}) + ), + ), + ) + + storage.store_event(log_entry) + + mats = storage.get_latest_materialization_events([key]) + assert mats + assert mats[key].asset_materialization.metadata["was"].value == "here"