Skip to content

Commit 48f479a

Browse files
Test for no data case
1 parent 433c1f4 commit 48f479a

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

tests/json_front_tests/test_json_class.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from statistics import StatisticsError
44
import scipy
55

6-
76
from causal_testing.testing.estimators import LinearRegressionEstimator
87
from causal_testing.testing.causal_test_outcome import NoEffect, Positive
98
from tests.test_helpers import remove_temp_dir_if_existent
@@ -99,7 +98,7 @@ def test_f_flag(self):
9998
effects = {"NoEffect": NoEffect()}
10099
mutates = {
101100
"Increase": lambda x: self.json_class.scenario.treatment_variables[x].z3
102-
> self.json_class.scenario.variables[x].z3
101+
> self.json_class.scenario.variables[x].z3
103102
}
104103
estimators = {"LinearRegressionEstimator": LinearRegressionEstimator}
105104
with self.assertRaises(StatisticsError):
@@ -148,7 +147,7 @@ def test_run_json_tests_from_json(self):
148147
effects = {"NoEffect": NoEffect()}
149148
mutates = {
150149
"Increase": lambda x: self.json_class.scenario.treatment_variables[x].z3
151-
> self.json_class.scenario.variables[x].z3
150+
> self.json_class.scenario.variables[x].z3
152151
}
153152
estimators = {"LinearRegressionEstimator": LinearRegressionEstimator}
154153

@@ -178,7 +177,7 @@ def test_generate_tests_from_json_no_dist(self):
178177
effects = {"NoEffect": NoEffect()}
179178
mutates = {
180179
"Increase": lambda x: self.json_class.scenario.treatment_variables[x].z3
181-
> self.json_class.scenario.variables[x].z3
180+
> self.json_class.scenario.variables[x].z3
182181
}
183182
estimators = {"LinearRegressionEstimator": LinearRegressionEstimator}
184183

@@ -208,7 +207,7 @@ def test_formula_in_json_test(self):
208207
effects = {"Positive": Positive()}
209208
mutates = {
210209
"Increase": lambda x: self.json_class.scenario.treatment_variables[x].z3
211-
> self.json_class.scenario.variables[x].z3
210+
> self.json_class.scenario.variables[x].z3
212211
}
213212
estimators = {"LinearRegressionEstimator": LinearRegressionEstimator}
214213

@@ -241,6 +240,26 @@ def test_run_concrete_json_testcase(self):
241240
temp_out = reader.readlines()
242241
self.assertIn("FAILED", temp_out[-1])
243242

243+
def test_no_data_provided(self):
244+
example_test = {
245+
"tests": [
246+
{
247+
"name": "test1",
248+
"mutations": {"test_input": "Increase"},
249+
"estimator": "LinearRegressionEstimator",
250+
"estimate_type": "ate",
251+
"effect_modifiers": [],
252+
"expected_effect": {"test_output": "NoEffect"},
253+
"skip": False,
254+
}
255+
]
256+
}
257+
json_class = JsonUtility("temp_out.txt", True)
258+
json_class.set_paths(self.json_path, self.dag_path)
259+
json_class.setup(self.scenario)
260+
261+
self.assertRaises(ValueError)
262+
244263
def tearDown(self) -> None:
245264
remove_temp_dir_if_existent()
246265

0 commit comments

Comments
 (0)