|
| 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