Skip to content

Commit 495818b

Browse files
add outputs and metas tests
1 parent 3ff087f commit 495818b

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

tests/json_front_tests/test_json_class.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import unittest
22
from pathlib import Path
33
import os
4+
5+
import scipy
6+
47
from tests.test_helpers import create_temp_dir_if_non_existent, remove_temp_dir_if_existent
58
from causal_testing.json_front.json_class import JsonUtility
69
from causal_testing.specification.variable import Input, Output, Meta
@@ -22,9 +25,9 @@ def setUp(self) -> None:
2225
self.dag_path = os.path.join(temp_dir_path, json_file_name)
2326
self.data_path = os.path.join(temp_dir_path, json_file_name)
2427
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)}]
2629
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}]
2831
self.json_class.set_variables(self.input_dict_list, self.output_dict_list, self.meta_dict_list)
2932

3033
def test_setting_paths(self):
@@ -34,9 +37,20 @@ def test_setting_paths(self):
3437
self.assertEqual(self.json_class.data_path, Path(self.data_path))
3538

3639
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)
3742

38-
pass
43+
def test_set_outputs(self):
44+
ctf_input = Output("test_output", float)
45+
self.assertEqual(self.json_class.inputs, ctf_input)
3946

47+
def test_set_metas(self):
48+
ctf_input = Input("test_meta", float, populate_example)
49+
self.assertEqual(self.json_class.inputs, ctf_input)
4050

4151
def tearDown(self) -> None:
4252
remove_temp_dir_if_existent()
53+
54+
55+
def populate_example():
56+
pass

0 commit comments

Comments
 (0)