"""Unit tests for config.py pure functions.""" import os import sys from pathlib import Path import pytest sys.path.insert(0, str(Path(__file__).parent.parent / "skills" / "ir_generation_skill")) import config def test_set_input_file(): original = config.INPUT_JSON try: config.set_input_file("/tmp/test_input.json") assert config.INPUT_JSON == "/tmp/test_input.json" finally: config.set_input_file(original) def test_no_hardcoded_input_file(): """INPUT_JSON should not have a hardcoded default — comes from env or None.""" # When IR_INPUT_JSON env is not set, INPUT_JSON should be None env_val = os.environ.pop("IR_INPUT_JSON", None) try: import importlib importlib.reload(config) # After reload without env var, INPUT_JSON should be None assert config.INPUT_JSON is None, \ f"INPUT_JSON should be None when env not set, got: {config.INPUT_JSON}" finally: if env_val is not None: os.environ["IR_INPUT_JSON"] = env_val importlib.reload(config) def test_set_input_file_accepts_none(): """set_input_file(None) should work for resetting.""" original = config.INPUT_JSON try: config.set_input_file("/tmp/test.json") config.set_input_file(None) assert config.INPUT_JSON is None finally: config.set_input_file(original) def test_config_constants_exist(): """Verify all expected path constants are defined.""" assert config.BASE_DIR assert config.PROJECT_ROOT assert config.PROJECT_OUTPUT assert config.IR_OUTPUT assert config.FINAL_OUTPUT assert config.OUTPUT_DIR assert config.PROMPTS_DIR assert config.TESTS_DIR assert config.DOC_PARSER_OUTPUT assert config.SEMANTIC_INDEX_JSON assert config.IR_FRAGMENTS_JSON assert config.PATH_ENUM_JSON assert config.IR_AUTOCOMPLETE_FRAGMENTS_JSON assert config.IR_FINAL_JSON assert config.IR_AUDIT_REPORT_MD def test_output_dir_is_under_project_root(): """PROJECT_OUTPUT, IR_OUTPUT, FINAL_OUTPUT should all be under PROJECT_ROOT.""" assert config.PROJECT_OUTPUT.startswith(config.PROJECT_ROOT) assert config.IR_OUTPUT.startswith(config.PROJECT_OUTPUT) assert config.FINAL_OUTPUT.startswith(config.PROJECT_OUTPUT) def test_output_dir_structure(): """IR files should go to output/ir/, final deliverable to output/final/.""" assert config.IR_OUTPUT.endswith(os.path.join("output", "ir")) assert config.FINAL_OUTPUT.endswith(os.path.join("output", "final")) assert config.SEMANTIC_INDEX_JSON.startswith(config.IR_OUTPUT) assert config.IR_FRAGMENTS_JSON.startswith(config.IR_OUTPUT) assert config.IR_FINAL_JSON.startswith(config.FINAL_OUTPUT) assert config.IR_AUDIT_REPORT_MD.startswith(config.FINAL_OUTPUT) def test_ensemble_temperatures_count(): """Should have exactly 3 ensemble temperatures.""" assert len(config.ENSEMBLE_TEMPERATURES) == 3 def test_max_tokens_is_int(): assert isinstance(config.MAX_TOKENS, int) assert config.MAX_TOKENS > 0 def test_temperature_is_float(): assert isinstance(config.TEMPERATURE, float) assert 0.0 <= config.TEMPERATURE <= 2.0 def test_provider_models_has_expected_keys(): assert "deepseek" in config.PROVIDER_MODELS assert "dashscope" in config.PROVIDER_MODELS def test_model_name_in_provider_models(): assert config.MODEL_NAME in config.PROVIDER_MODELS.values()