1
1
import unittest
2
2
from pathlib import Path
3
3
import os
4
+
5
+ import scipy
6
+
4
7
from tests .test_helpers import create_temp_dir_if_non_existent , remove_temp_dir_if_existent
5
8
from causal_testing .json_front .json_class import JsonUtility
6
9
from causal_testing .specification .variable import Input , Output , Meta
@@ -22,9 +25,9 @@ def setUp(self) -> None:
22
25
self .dag_path = os .path .join (temp_dir_path , json_file_name )
23
26
self .data_path = os .path .join (temp_dir_path , json_file_name )
24
27
self .json_class = JsonUtility ("logs.log" )
25
- self .input_dict_list = [{"name" : "test_input" , "type" : float , "distribution" : " uniform" }]
28
+ self .input_dict_list = [{"name" : "test_input" , "type" : float , "distribution" : scipy . stats . uniform ( 0 , 1 ) }]
26
29
self .output_dict_list = [{"name" : "test_output" , "type" : float }]
27
- self .meta_dict_list = [{"name" : "test_meta" , "type" : float , "populate" : "populate_num_lines_unit" }]
30
+ self .meta_dict_list = [{"name" : "test_meta" , "type" : float , "populate" : populate_example }]
28
31
self .json_class .set_variables (self .input_dict_list , self .output_dict_list , self .meta_dict_list )
29
32
30
33
def test_setting_paths (self ):
@@ -34,9 +37,20 @@ def test_setting_paths(self):
34
37
self .assertEqual (self .json_class .data_path , Path (self .data_path ))
35
38
36
39
def test_set_inputs (self ):
40
+ ctf_input = Input ("test_input" , float , scipy .stats .uniform (0 , 1 ))
41
+ self .assertEqual (self .json_class .inputs , ctf_input )
37
42
38
- pass
43
+ def test_set_outputs (self ):
44
+ ctf_input = Output ("test_output" , float )
45
+ self .assertEqual (self .json_class .inputs , ctf_input )
39
46
47
+ def test_set_metas (self ):
48
+ ctf_input = Input ("test_meta" , float , populate_example )
49
+ self .assertEqual (self .json_class .inputs , ctf_input )
40
50
41
51
def tearDown (self ) -> None :
42
52
remove_temp_dir_if_existent ()
53
+
54
+
55
+ def populate_example ():
56
+ pass
0 commit comments