Skip to content

Commit

Permalink
unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
R-Palazzo committed Jun 19, 2024
1 parent e644d86 commit af7e837
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions tests/unit/utils/test_poc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,21 @@ def test_drop_unknown_references(mock_drop_unknown_references):
# Setup
data = Mock()
metadata = Mock()
drop_missing_values = Mock()
verbose = Mock()
expected_message = re.escape(
"Please access the 'drop_unknown_references' function directly from the sdv.utils module"
'instead of sdv.utils.poc.'
)

# Run
with pytest.warns(FutureWarning, match=expected_message):
drop_unknown_references(data, metadata)
drop_unknown_references(data, metadata, drop_missing_values, verbose)

# Assert
mock_drop_unknown_references.assert_called_once_with(data, metadata)
mock_drop_unknown_references.assert_called_once_with(
data, metadata, drop_missing_values, verbose
)


@patch('sdv.utils.poc._get_total_estimated_columns')
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/utils/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _drop_rows(data, metadata, drop_missing_values):
}
metadata.validate.assert_called_once()
metadata.validate_data.assert_called_once_with(data)
mock_drop_rows.assert_called_once_with(result, metadata, True)
mock_drop_rows.assert_called_once_with(result, metadata, False)
for table_name, table in result.items():
pd.testing.assert_frame_equal(table, expected_result[table_name])

Expand Down Expand Up @@ -189,7 +189,7 @@ def test_drop_unknown_references_with_nan(mock_validate_foreign_keys, mock_get_r
mock_get_rows_to_drop.return_value = defaultdict(set, {'child': {4}, 'grandchild': {0, 3, 4}})

# Run
result = drop_unknown_references(data, metadata, verbose=False)
result = drop_unknown_references(data, metadata, drop_missing_values=True, verbose=False)

# Assert
metadata.validate.assert_called_once()
Expand Down

0 comments on commit af7e837

Please sign in to comment.