Skip to content

Commit

Permalink
integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
R-Palazzo committed Sep 12, 2024
1 parent 49e4958 commit 6ed0260
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/integration/metadata/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,41 @@ def test_metadata():
assert instance.relationships == []


def test_load_from_json_single_table_metadata(tmp_path):
"""Test the ``load_from_json`` method with a single table metadata."""
# Setup
old_metadata = SingleTableMetadata.load_from_dict({
'columns': {
'column_1': {'sdtype': 'numerical'},
'column_2': {'sdtype': 'categorical'},
},
})
old_metadata.save_to_json(tmp_path / 'metadata.json')
expected_warning = re.escape(
'You are loading an older SingleTableMetadata object. This will be converted '
f"into the new Metadata object with a placeholder table name ('{DEFAULT_TABLE_NAME}')."
' Please save this new object for future usage.'
)

# Run
with pytest.warns(UserWarning, match=expected_warning):
metadata = Metadata.load_from_json(tmp_path / 'metadata.json')

# Assert
assert metadata.to_dict() == {
'tables': {
DEFAULT_TABLE_NAME: {
'columns': {
'column_1': {'sdtype': 'numerical'},
'column_2': {'sdtype': 'categorical'},
},
},
},
'relationships': [],
'METADATA_SPEC_VERSION': 'V1',
}


def test_detect_from_dataframes_multi_table():
"""Test the ``detect_from_dataframes`` method works with multi-table."""
# Setup
Expand Down

0 comments on commit 6ed0260

Please sign in to comment.