Skip to content

Commit

Permalink
minor changes in the class Validator, update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanna Imshenetska authored and Hanna Imshenetska committed Oct 25, 2024
1 parent 3a53989 commit a8dc2d9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/syngen/ml/config/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,12 @@ def _check_existence_of_referenced_columns(self, table_name: str):
]
if non_existed_columns:
message = (
f"The 'referenced.columns' of the {config_of_key['type']} '{key}' - "
f"The 'references.columns' of the {config_of_key['type']} '{key}' - "
f"{', '.join(non_existed_columns)} "
f"don't exist in the referenced table - '{referenced_table}'"
)
self.errors[
"check existence of the key columns in 'referenced.columns'"
"check existence of the key columns in 'references.columns'"
][key] = message

def _fetch_existed_columns(self, table_name: str) -> List[str]:
Expand Down
28 changes: 14 additions & 14 deletions src/tests/unit/validation_metadata/test_validation_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,6 @@ def test_validate_metadata_of_related_tables_with_fk_key_in_train_process(
"contained only the primary key and the foreign key used in the training process"
)
test_metadata = {
"table_a": {
"train_settings": {
"source": "path/to/table_a.csv"
},
"keys": {
"pk_id": {
"type": "PK",
"columns": ["id"]
}
}
},
"table_b": {
"train_settings": {
"source": "path/to/table_b.csv"
Expand All @@ -266,7 +255,18 @@ def test_validate_metadata_of_related_tables_with_fk_key_in_train_process(
}
}
}
}
},
"table_a": {
"train_settings": {
"source": "path/to/table_a.csv"
},
"keys": {
"pk_id": {
"type": "PK",
"columns": ["id"]
}
}
},
}
validator = Validator(
metadata=test_metadata,
Expand Down Expand Up @@ -2021,8 +2021,8 @@ def test_check_not_existent_referenced_columns_in_fk(rp_logger):
assert validator.merged_metadata == test_metadata
assert str(error.value) == (
"The validation of the metadata has been failed. The error(s) found in - \n"
"\"check existence of the key columns in 'referenced.columns'\": {\n \"fk_id\": "
"\"The 'referenced.columns' of the FK 'fk_id' - 'non-existent column' don't exist "
"\"check existence of the key columns in 'references.columns'\": {\n \"fk_id\": "
"\"The 'references.columns' of the FK 'fk_id' - 'non-existent column' don't exist "
"in the referenced table - 'table_b'\"}"
)
rp_logger.info(SUCCESSFUL_MESSAGE)

0 comments on commit a8dc2d9

Please sign in to comment.