@@ -93,33 +93,36 @@ def test_abstract_test_case_generation(self):
93
93
abstract_test_case = self .json_class ._create_abstract_test_case (example_test , mutates , effects )
94
94
self .assertIsInstance (abstract_test_case , AbstractCausalTestCase )
95
95
96
- def test_execute_concrete_test (self ):
96
+ def test_generate_tests_from_json (self ):
97
+ example_test = {
98
+ "tests" : [
99
+ {
100
+ "name" : "test1" ,
101
+ "mutations" : {"test_input" : "Increase" },
102
+ "estimator" : "LinearRegressionEstimator" ,
103
+ "estimate_type" : "ate" ,
104
+ "effect_modifiers" : [],
105
+ "expectedEffect" : {"test_output" : "NoEffect" },
106
+ "skip" : False ,
107
+ }
108
+ ]
109
+ }
97
110
self .json_class .setup ()
98
- dag_string = "digraph G { test_input -> B; B -> C; test_output -> test_input; test_output -> C}"
99
- setup_dag_file (self .dag_path , dag_string )
111
+ self .json_class .test_plan = example_test
100
112
effects = {"NoEffect" : NoEffect ()}
101
113
mutates = {
102
114
"Increase" : lambda x : self .json_class .modelling_scenario .treatment_variables [x ].z3 >
103
115
self .json_class .modelling_scenario .variables [x ].z3
104
116
}
105
- expected_effect = dict ({"test_output" : "NoEffect" })
106
- example_test = {
107
- "name" : "test1" ,
108
- "mutations" : {"test_input" : "Increase" },
109
- "estimator" : "LinearRegressionEstimator" ,
110
- "estimate_type" : "ate" ,
111
- "effect_modifiers" : [],
112
- "expectedEffect" : expected_effect ,
113
- "skip" : False ,
117
+ estimators = {
118
+ "LinearRegressionEstimator" : LinearRegressionEstimator
114
119
}
115
- estimators = {"LinearRegressionEstimator" : LinearRegressionEstimator }
116
- abstract_test_case = self .json_class ._create_abstract_test_case (example_test , mutates , effects )
117
- concrete_tests , dummy = abstract_test_case .generate_concrete_tests (5 , 0.5 )
118
120
119
- # This scenario should produce 5 failures
120
- failures = self .json_class ._execute_tests (concrete_tests , estimators , example_test , False )
121
- self .assertEqual (failures , 5 )
121
+ with self .assertLogs () as captured :
122
+ self .json_class .generate_tests (effects , mutates , estimators , False )
122
123
124
+ # Test that the final log message is that all tests have failed, which is expected behaviour for this scenario
125
+ self .assertEqual (captured .records [- 1 ].getMessage (), "105/105 failed" )
123
126
def tearDown (self ) -> None :
124
127
remove_temp_dir_if_existent ()
125
128
0 commit comments