Skip to content

Commit ba72d7e

Browse files
committed
Test causal testing paths
1 parent 0a070b4 commit ba72d7e

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/main_tests/test_main.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import unittest
2+
import shutil
3+
from pathlib import Path
4+
from causal_testing.main import CausalTestingPaths
5+
6+
7+
class TestCausalTestingPaths(unittest.TestCase):
8+
9+
def setUp(self):
10+
self.dag_path = "tests/resources/data/dag.dot"
11+
self.data_paths = ["tests/resources/data/data.csv"]
12+
self.test_config_path = "tests/resources/data/tests.json"
13+
self.output_path = Path("results/results.json")
14+
15+
def test_missing_dag(self):
16+
with self.assertRaises(FileNotFoundError) as e:
17+
CausalTestingPaths("missing.dot", self.data_paths, self.test_config_path, self.output_path).validate_paths()
18+
self.assertEqual("DAG file not found: missing.dot", str(e.exception))
19+
20+
def test_missing_data(self):
21+
with self.assertRaises(FileNotFoundError) as e:
22+
CausalTestingPaths(self.dag_path, ["missing.csv"], self.test_config_path, self.output_path).validate_paths()
23+
self.assertEqual("Data file not found: missing.csv", str(e.exception))
24+
25+
def test_missing_tests(self):
26+
with self.assertRaises(FileNotFoundError) as e:
27+
CausalTestingPaths(self.dag_path, self.data_paths, "missing.json", self.output_path).validate_paths()
28+
self.assertEqual("Test configuration file not found: missing.json", str(e.exception))
29+
30+
def test_output_file_created(self):
31+
self.assertFalse(self.output_path.parent.exists())
32+
CausalTestingPaths(self.dag_path, self.data_paths, self.test_config_path, self.output_path).validate_paths()
33+
self.assertTrue(self.output_path.parent.exists())
34+
35+
def tearDown(self):
36+
if self.output_path.parent.exists():
37+
shutil.rmtree(self.output_path.parent)

0 commit comments

Comments
 (0)