-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
30 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 16 additions & 14 deletions
30
...odules/dagster/dagster_tests/definitions_tests/metadata_tests/test_source_metadata_set.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,38 @@ | ||
import pytest | ||
from dagster._core.definitions.events import AssetMaterialization | ||
from dagster._core.definitions.metadata import SourceDataMetadataSet, SourcePathMetadataSet | ||
from dagster._core.test_utils import raise_exception_on_warnings | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def error_on_warning() -> None: | ||
raise_exception_on_warnings() | ||
from dagster._core.definitions.metadata import ( | ||
DEFAULT_SOURCE_FILE_KEY, | ||
SourceDataMetadataSet, | ||
SourcePathMetadataSet, | ||
) | ||
|
||
|
||
def test_source_metadata_set() -> None: | ||
source_metadata = SourceDataMetadataSet( | ||
source_paths=[ | ||
SourcePathMetadataSet( | ||
source_paths={ | ||
DEFAULT_SOURCE_FILE_KEY: SourcePathMetadataSet( | ||
path_to_module="/Users/dagster/Documents/my_module", | ||
path_from_module="assets/my_asset.py", | ||
line_number=12, | ||
) | ||
] | ||
} | ||
) | ||
|
||
dict_source_metadata = dict(source_metadata) | ||
assert dict_source_metadata == {"dagster/source_paths": source_metadata.source_paths} | ||
assert len(dict_source_metadata["dagster/source_paths"]) == 1 | ||
assert isinstance(dict_source_metadata["dagster/source_paths"][0], SourcePathMetadataSet) | ||
assert isinstance( | ||
dict_source_metadata["dagster/source_paths"][DEFAULT_SOURCE_FILE_KEY], SourcePathMetadataSet | ||
) | ||
AssetMaterialization(asset_key="a", metadata=dict_source_metadata) | ||
|
||
splat_source_metadata = {**source_metadata} | ||
assert splat_source_metadata == {"dagster/source_paths": source_metadata.source_paths} | ||
assert len(splat_source_metadata["dagster/source_paths"]) == 1 | ||
assert isinstance(splat_source_metadata["dagster/source_paths"][0], SourcePathMetadataSet) | ||
assert isinstance( | ||
splat_source_metadata["dagster/source_paths"][DEFAULT_SOURCE_FILE_KEY], | ||
SourcePathMetadataSet, | ||
) | ||
AssetMaterialization(asset_key="a", metadata=splat_source_metadata) | ||
|
||
assert dict(SourceDataMetadataSet()) == {"dagster/source_paths": []} | ||
assert dict(SourceDataMetadataSet()) == {"dagster/source_paths": {}} | ||
assert SourceDataMetadataSet.extract(dict(SourceDataMetadataSet())) == SourceDataMetadataSet() |