1+ from typing import Any
12
23import pytest
34
78
89
910class TestValidateManifest :
11+ """Tests for ValidateManifest class"""
1012
1113 @pytest .mark .parametrize (
1214 ("manifest" , "model" , "root_node" ),
@@ -16,47 +18,59 @@ class TestValidateManifest:
1618 "example_test_nones.model.csv" ,
1719 "MockComponent" ,
1820 ),
19- # (
20- # "mock_manifests/Valid_Test_Manifest_with_nones .csv",
21- # "example_test_nones.model2 .csv",
22- # "MockComponent",
23- # ),
21+ (
22+ "mock_manifests/Invalid_Test_Manifest_with_nones .csv" ,
23+ "example_test_nones.model .csv" ,
24+ "MockComponent" ,
25+ ),
2426 ],
2527 )
2628 def test_validate_manifest_values (
27- self , helpers , manifest , model , root_node
29+ self , helpers : Any , manifest : str , model : str , root_node : str
2830 ):
31+ """Tests for ValidateManifest.validate_manifest_values
32+
33+ Args:
34+ helpers (Any): An object with helper functions
35+ manifest (str): A path to the manifest to be tested
36+ model (str): A path to the model to be tested
37+ root_node (str): The name of the component to be tested
38+ """
2939 # Get manifest and data model path
30- manifest_path = helpers .get_data_path (manifest )
31- model_path = helpers .get_data_path (model )
40+ manifest_path : str = helpers .get_data_path (manifest )
41+ model_path : str = helpers .get_data_path (model )
3242
33- # Gather parmeters needed to run validate_manifest_rules
43+ # Gather parameters needed to run validate_manifest_rules
3444 errors = []
3545 load_args = {
3646 "dtype" : "string" ,
3747 }
3848
3949 dmge = helpers .get_data_model_graph_explorer (path = model )
4050
41- self .data_model_js = DataModelJSONSchema (
42- jsonld_path = model_path , graph = dmge .graph
43- )
44- json_schema = self .data_model_js .get_json_validation_schema (
51+ data_model_js = DataModelJSONSchema (jsonld_path = model_path , graph = dmge .graph )
52+ json_schema = data_model_js .get_json_validation_schema (
4553 root_node , root_node + "_validation"
4654 )
4755
48- manifest = load_df (
56+ manifest_df = load_df (
4957 manifest_path ,
5058 preserve_raw_input = False ,
5159 allow_na_values = True ,
5260 ** load_args ,
5361 )
5462
55- vm = ValidateManifest (errors , manifest , manifest_path , dmge , json_schema )
56- errors , warnings = vm .validate_manifest_values (manifest , json_schema , dmge )
57- import logging
63+ vm = ValidateManifest (errors , manifest_df , manifest_path , dmge , json_schema )
64+ errors , warnings = vm .validate_manifest_values (manifest_df , json_schema , dmge )
5865 assert not warnings
5966 assert errors
60- for error in errors :
61- logging .warning (error )
62- assert False
67+
68+ # Both manifests will have errors of type "<xxx> is not of type 'array'
69+ # Only the invalid manifest will have errors of type "<xxx is not one of
70+ # ['Breast', 'None', 'Prostate', 'Colorectal', 'Skin', 'Lung']" in the
71+ # "Cancer Type" column.
72+ error_attributes = [error [1 ] for error in errors ]
73+ if manifest == "mock_manifests/Valid_Test_Manifest_with_nones.csv" :
74+ assert "Cancer Type" not in error_attributes
75+ else :
76+ assert "Cancer Type" in error_attributes
0 commit comments