/ tests / test_import_output_path.py
test_import_output_path.py
 1  """Test that _default_output_path produces the expected directory structure."""
 2  
 3  import re
 4  
 5  from cli.import_jobs import _default_output_path
 6  from config import settings
 7  
 8  
 9  class TestDefaultOutputPath:
10      def test_path_has_date_subfolder_and_time_filename(self) -> None:
11          # Verify the output path lands under settings.output_dir with a date
12          # subfolder and time-stamped filename, so downstream pipelines co-locate.
13          path = _default_output_path()
14          # Root should be settings.output_dir.
15          assert path.parent.parent == settings.output_dir, (
16              f"Expected root {settings.output_dir}, got: {path.parent.parent}"
17          )
18          # Parent directory name should be a date like 2026_03_26.
19          assert re.fullmatch(r"\d{4}_\d{2}_\d{2}", path.parent.name), (
20              f"Expected date folder, got: {path.parent.name}"
21          )
22          # Filename should be jobs_HHhMM.json.
23          assert re.fullmatch(r"jobs_\d{2}h\d{2}\.json", path.name), (
24              f"Expected jobs_HHhMM.json, got: {path.name}"
25          )