Skip to content

Commit 079bf74

Browse files
committed
Add unit test for sequence_key and sequence_index for unified metadata
1 parent aeea336 commit 079bf74

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/unit/metadata/test_metadata.py

+33
Original file line numberDiff line numberDiff line change
@@ -826,3 +826,36 @@ def test_anonymize(self, mock_load_from_dict):
826826
# Assert
827827
metadata._get_anonymized_dict.assert_called_once()
828828
mock_load_from_dict.assert_called_once_with({})
829+
830+
@patch('sdv.metadata.multi_table.visualize_graph')
831+
def test_visualize_with_sequence_key_and_index(self, visualize_graph_mock):
832+
"""Test the ``visualize`` method with sequence key and index"""
833+
# Setup
834+
metadata_dict = {
835+
'tables': {
836+
'nasdaq100_2019': {
837+
'columns': {
838+
'Symbol': {'sdtype': 'id', 'regex_format': '[A-Z]{4}'},
839+
'Date': {'sdtype': 'datetime', 'datetime_format': '%Y-%m-%d'},
840+
},
841+
'sequence_index': 'Date',
842+
'sequence_key': 'Symbol',
843+
}
844+
},
845+
'relationships': [],
846+
'METADATA_SPEC_VERSION': 'V1',
847+
}
848+
metadata = Metadata.load_from_dict(metadata_dict)
849+
850+
# Run
851+
metadata.visualize('full', True)
852+
853+
# Assert
854+
expected_label = (
855+
'{nasdaq100_2019|Symbol : id\\lDate : datetime\\l|Primary key: None\\l'
856+
'Sequence key: Symbol\\lSequence index: Date\\l}'
857+
)
858+
expected_nodes = {
859+
'nasdaq100_2019': expected_label,
860+
}
861+
visualize_graph_mock.assert_called_once_with(expected_nodes, [], None)

0 commit comments

Comments
 (0)