| 1 | from config import ConfigLoader |
| 2 | |
| 3 | |
| 4 | def test_validate_normalizes_invalid_thread(tmp_path): |
| 5 | config_file = tmp_path / "config.yml" |
| 6 | config_file.write_text("link:\n - https://www.douyin.com/video/123\npath: ./out\nthread: -1\n") |
| 7 | loader = ConfigLoader(str(config_file)) |
| 8 | assert loader.validate() is True |
| 9 | assert loader.get("thread") == 5 |
| 10 | |
| 11 | |
| 12 | def test_validate_normalizes_invalid_start_time(tmp_path): |
| 13 | config_file = tmp_path / "config.yml" |
| 14 | config_file.write_text( |
| 15 | "link:\n - https://www.douyin.com/video/123\npath: ./out\nstart_time: not-a-date\n" |
| 16 | ) |
| 17 | loader = ConfigLoader(str(config_file)) |
| 18 | assert loader.validate() is True |
| 19 | assert loader.get("start_time") == "" |
| 20 | |
| 21 | |
| 22 | def test_env_thread_invalid_ignored(tmp_path, monkeypatch): |
| 23 | config_file = tmp_path / "config.yml" |
| 24 | config_file.write_text("link:\n - https://www.douyin.com/video/123\npath: ./out\n") |
| 25 | monkeypatch.setenv("DOUYIN_THREAD", "not_a_number") |
| 26 | loader = ConfigLoader(str(config_file)) |
| 27 | assert loader.get("thread") == 5 |
| 28 |