Skip to content

Commit 7f5cf81

Browse files
committed
extra tests
1 parent ed229f8 commit 7f5cf81

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

tests/json_front_tests/test_json_class.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ def test_generate_tests_from_json(self):
131131
temp_out = reader.readlines()
132132
self.assertIn("failed", temp_out[-1])
133133

134-
135134
def test_generate_tests_from_json_no_dist(self):
136135
example_test = {
137136
"tests": [

tests/specification_tests/test_metamorphic_relations.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,52 @@ def test_should_cause_metamorphic_relations_correct_spec(self):
9999
test_results = should_cause_MR.execute_tests(self.data_collector)
100100
should_cause_MR.test_oracle(test_results)
101101

102+
def test_should_not_cause_json_stub(self):
103+
"""Test if the ShouldCause MR passes all metamorphic tests where the DAG perfectly represents the program
104+
and there is only a single input."""
105+
causal_dag = CausalDAG(self.dag_dot_path)
106+
self.data_collector = SingleInputProgramUnderTestEDC(
107+
self.scenario, self.default_control_input_config, self.default_treatment_input_config
108+
)
109+
causal_dag.graph.remove_nodes_from(["X2", "X3"])
110+
adj_set = list(causal_dag.direct_effect_adjustment_sets(["X1"], ["Z"])[0])
111+
should_not_cause_MR = ShouldNotCause("X1", "Z", adj_set, causal_dag)
112+
self.assertEqual(
113+
should_not_cause_MR.to_json_stub(),
114+
{
115+
"effect": "direct",
116+
"estimate_type": "coefficient",
117+
"estimator": "LinearRegressionEstimator",
118+
"expectedEffect": {"Z": "NoEffect"},
119+
"mutations": ["X1"],
120+
"name": "X1 _||_ Z",
121+
"skip": True,
122+
},
123+
)
124+
125+
def test_should_cause_json_stub(self):
126+
"""Test if the ShouldCause MR passes all metamorphic tests where the DAG perfectly represents the program
127+
and there is only a single input."""
128+
causal_dag = CausalDAG(self.dag_dot_path)
129+
self.data_collector = SingleInputProgramUnderTestEDC(
130+
self.scenario, self.default_control_input_config, self.default_treatment_input_config
131+
)
132+
causal_dag.graph.remove_nodes_from(["X2", "X3"])
133+
adj_set = list(causal_dag.direct_effect_adjustment_sets(["X1"], ["Z"])[0])
134+
should_cause_MR = ShouldCause("X1", "Z", adj_set, causal_dag)
135+
self.assertEqual(
136+
should_cause_MR.to_json_stub(),
137+
{
138+
"effect": "direct",
139+
"estimate_type": "coefficient",
140+
"estimator": "LinearRegressionEstimator",
141+
"expectedEffect": {"Z": "SomeEffect"},
142+
"mutations": ["X1"],
143+
"name": "X1 --> Z",
144+
"skip": True,
145+
},
146+
)
147+
102148
def test_should_cause_metamorphic_relations_correct_spec_one_input(self):
103149
"""Test if the ShouldCause MR passes all metamorphic tests where the DAG perfectly represents the program
104150
and there is only a single input."""

0 commit comments

Comments
 (0)