1
1
import unittest
2
2
from pathlib import Path
3
- import os
4
- import json
5
3
import scipy
6
4
import csv
5
+ import json
6
+
7
7
from tests .test_helpers import create_temp_dir_if_non_existent , remove_temp_dir_if_existent
8
8
from causal_testing .json_front .json_class import JsonUtility
9
9
from causal_testing .specification .variable import Input , Output , Meta
@@ -26,9 +26,7 @@ def setUp(self) -> None:
26
26
self .json_path = temp_dir_path / json_file_name
27
27
self .dag_path = temp_dir_path / dag_file_name
28
28
self .data_path = temp_dir_path / data_file_name
29
- self .setup_data_file ()
30
- self .setup_json_file ()
31
- self .setup_dag_file ()
29
+ setup_files (self .json_path , self .data_path , self .dag_path )
32
30
self .json_class = JsonUtility ("logs.log" )
33
31
self .example_distribution = scipy .stats .uniform (0 , 10 )
34
32
self .input_dict_list = [{"name" : "test_input" , "type" : float , "distribution" : self .example_distribution }]
@@ -73,42 +71,50 @@ def test_setup_modelling_scenario(self):
73
71
74
72
def test_setup_causal_specification (self ):
75
73
self .json_class .setup ()
76
-
77
74
self .assertIsInstance (self .json_class .causal_specification , CausalSpecification )
78
75
79
76
def test_concrete_tests_generated (self ):
80
- self .setup_json_file ()
81
- self .setup_data_file ()
82
- self .setup_dag_file ()
77
+ pass
83
78
84
79
def tearDown (self ) -> None :
85
80
remove_temp_dir_if_existent ()
86
81
87
- def setup_json_file (self ):
88
- json_test = {
89
- "tests" : [
90
- {"name" : "test1" , "mutations" : {}, "estimator" : None , "estimate_type" : None , "effect_modifiers" : [],
91
- "expectedEffect" : {}, "skip" : False }]
92
- }
93
- json_object = json .dumps (json_test )
94
- with open (self .json_path , "w" ) as f :
95
- f .write (json_object )
96
- f .close ()
97
-
98
- def setup_data_file (self ):
99
- header = ['test_input' , 'test_output' ]
100
- data = [1 , 2 ]
101
- with open (self .data_path , "w" ) as f :
102
- writer = csv .writer (f )
103
- writer .writerow (header )
104
- writer .writerow (data )
105
-
106
- def setup_dag_file (self ):
107
- dag_dot = (
108
- "digraph G {A->B}"
109
- )
110
- with open (self .dag_path , "w" ) as f :
111
- f .write (dag_dot )
112
82
113
83
def populate_example (* args , ** kwargs ):
114
84
pass
85
+
86
+
87
+ def setup_json_file (json_path ):
88
+ json_test = {
89
+ "tests" : [
90
+ {"name" : "test1" , "mutations" : {}, "estimator" : None , "estimate_type" : None , "effect_modifiers" : [],
91
+ "expectedEffect" : {}, "skip" : False }]
92
+ }
93
+ json_object = json .dumps (json_test )
94
+ with open (json_path , "w" ) as f :
95
+ f .write (json_object )
96
+ f .close ()
97
+
98
+
99
+ def setup_data_file (data_path ):
100
+ header = ['test_input' , 'test_output' ]
101
+ data = [1 , 2 ]
102
+ with open (data_path , "w" ) as f :
103
+ writer = csv .writer (f )
104
+ writer .writerow (header )
105
+ writer .writerow (data )
106
+
107
+
108
+ def setup_dag_file (dag_path ):
109
+ dag_dot = (
110
+ "digraph G {A->B}"
111
+ )
112
+ with open (dag_path , "w" ) as f :
113
+ f .write (dag_dot )
114
+ f .close ()
115
+
116
+
117
+ def setup_files (json_path , data_path , dag_path ):
118
+ setup_data_file (data_path )
119
+ setup_json_file (json_path )
120
+ setup_dag_file (dag_path )
0 commit comments