Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
R-Palazzo committed Nov 22, 2023
1 parent 4b8eaec commit fb43098
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 2 deletions.
53 changes: 52 additions & 1 deletion tests/unit/reports/multi_table/test_base_multi_table_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,64 @@ def test__validate_data_format(self):

# Run and Assert
expected_message = (
'Multi table report BaseMultiTableReport expects real and synthetic data to be '
'Multi table BaseMultiTableReport expects real and synthetic data to be '
'dictionaries of pandas.DataFrame. If your real and synthetic data are '
'pd.DataFrame, please use the single-table BaseMultiTableReport instead.'
)
with pytest.raises(ValueError, match=expected_message):
base_report._validate_data_format(real_data, synthetic_data)

def test__validate_metadata_format(self):
"""Test the ``_validate_metadata_format`` method.
This test checks that the method raises an error when the metadata is not a dictionnary.
"""
# Setup
base_report = BaseMultiTableReport()
metadata = []

# Run and Assert
expected_message = 'The provided metadata is not a dictionary.'
with pytest.raises(TypeError, match=expected_message):
base_report._validate_metadata_format(metadata)

def test__validate_metadata_format_with_no_tables(self):
"""Test the ``_validate_metadata_format`` method.
This test checks that the method raises an error when the metadata does not contain a
'tables' key.
"""
# Setup
base_report = BaseMultiTableReport()
metadata = {}

# Run and Assert
expected_message = (
'Multi table reports expect metadata to contain a "tables" key with a mapping from '
'table names to metadata for each table.'
)
with pytest.raises(ValueError, match=expected_message):
base_report._validate_metadata_format(metadata)

def test__validate_metadata_format_with_no_columns(self):
"""Test the ``_validate_metadata_format`` method.
This test checks that the method raises an error when the metadata does not contain a
'columns' key.
"""
# Setup
base_report = BaseMultiTableReport()
metadata = {
'tables': {
'Table_1': {}
}
}

# Run and Assert
expected_message = 'The metadata for table "Table_1" is missing a "columns" key.'
with pytest.raises(ValueError, match=expected_message):
base_report._validate_metadata_format(metadata)

def test__validate_relationships(self):
"""Test the ``_validate_relationships`` method."""
# Setup
Expand Down
36 changes: 35 additions & 1 deletion tests/unit/reports/test_base_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,47 @@ def test__validate_data_format(self):

# Run and Assert
expected_message = (
'Single table report BaseReport expects real and synthetic data to be '
'Single table BaseReport expects real and synthetic data to be '
'pandas.DataFrame. If your real and synthetic data are dictionaries of '
'tables, please use the multi-table BaseReport instead.'
)
with pytest.raises(ValueError, match=expected_message):
base_report._validate_data_format(real_data, synthetic_data)

def test__validate_metadata_format(self):
"""Test the ``_validate_metadata_format`` method.
This test checks that the method raises an error when the metadata is not a dictionary.
"""
# Setup
base_report = BaseReport()
metadata = 'metadata'

# Run and Assert
expected_message = (
'The provided metadata is not a dictionary.'
)
with pytest.raises(TypeError, match=expected_message):
base_report._validate_metadata_format(metadata)

def test__validate_metadata_format_no_columns(self):
"""Test the ``_validate_metadata_format`` method.
This test checks that the method raises an error when the metadata does not contain a
'columns' key.
"""
# Setup
base_report = BaseReport()
metadata = {}

# Run and Assert
expected_message = (
'Single table reports expect metadata to contain a "columns" key with a mapping'
' from column names to column informations.'
)
with pytest.raises(ValueError, match=expected_message):
base_report._validate_metadata_format(metadata)

def test__validate_metadata_matches_data(self):
"""Test the ``_validate_metadata_matches_data`` method.
Expand Down

0 comments on commit fb43098

Please sign in to comment.