@@ -99,6 +99,52 @@ def test_should_cause_metamorphic_relations_correct_spec(self):
99
99
test_results = should_cause_MR .execute_tests (self .data_collector )
100
100
should_cause_MR .test_oracle (test_results )
101
101
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
+
102
148
def test_should_cause_metamorphic_relations_correct_spec_one_input (self ):
103
149
"""Test if the ShouldCause MR passes all metamorphic tests where the DAG perfectly represents the program
104
150
and there is only a single input."""
0 commit comments