|
1 | 1 | """Validate the set-mission command"""
|
2 | 2 |
|
3 | 3 | import json
|
| 4 | +from pathlib import Path |
4 | 5 |
|
5 | 6 | from tests.fixtures import BASE_CONFIG
|
6 | 7 | from zeusops_bot.reforger_config_gen import ReforgerConfigGenerator, as_config_file
|
7 | 8 |
|
8 | 9 |
|
9 |
| -def test_load_mission(tmp_path): |
| 10 | +def test_load_mission(base_config: Path, mission_dir: Path): |
10 | 11 | """Scenario: Load mission from previous upload"""
|
11 | 12 | # Given a Zeusops mission was uploaded already under <filename>
|
12 |
| - config_base = tmp_path / "reforger_configs" |
13 | 13 | filename = "Jib_20250228"
|
14 |
| - uploaded_conf_path = as_config_file(config_base, filename) |
15 |
| - uploaded_conf_path.parent.mkdir(parents=True, exist_ok=True) |
16 |
| - gen = ReforgerConfigGenerator( |
17 |
| - base_config_file=uploaded_conf_path, target_folder=config_base |
18 |
| - ) |
| 14 | + uploaded_conf_path = as_config_file(mission_dir, filename) |
19 | 15 | uploaded_conf_path.write_text(json.dumps(BASE_CONFIG))
|
| 16 | + config_gen = ReforgerConfigGenerator( |
| 17 | + base_config_file=base_config, target_folder=mission_dir |
| 18 | + ) |
20 | 19 | # When Zeus calls "/zeus-set-mission" with <filename>
|
21 |
| - base_conf = tmp_path / "base.json" |
22 |
| - base_conf.write_text(json.dumps(BASE_CONFIG)) |
23 |
| - gen.zeus_set_mission(filename) |
| 20 | + config_gen.zeus_set_mission(filename) |
24 | 21 | # Then a symbolic link is created from "current-config.json" to <filename>
|
25 |
| - target = config_base / "current-config.json" |
| 22 | + target = mission_dir / "current-config.json" |
26 | 23 | assert target.exists(), "Should have created latest config symlink"
|
27 | 24 | assert target.is_symlink(), "Target config should be a symlink"
|
28 | 25 | assert target.readlink() == uploaded_conf_path.relative_to(
|
29 |
| - config_base |
| 26 | + mission_dir |
30 | 27 | ), "Target should point to uploaded file"
|
31 | 28 |
|
32 | 29 |
|
33 |
| -def test_load_mission_twice(tmp_path): |
| 30 | +def test_load_mission_twice(base_config: Path, mission_dir: Path): |
34 | 31 | """Scenario: Load two missions back to back"""
|
35 | 32 | # Given a Zeusops mission was uploaded already under <filename>
|
36 |
| - config_base = tmp_path / "reforger_configs" |
37 | 33 | filename = "Jib_20250228"
|
38 |
| - uploaded_conf_path = as_config_file(config_base, filename) |
39 |
| - uploaded_conf_path.parent.mkdir(parents=True, exist_ok=True) |
40 |
| - gen = ReforgerConfigGenerator( |
41 |
| - base_config_file=uploaded_conf_path, target_folder=config_base |
42 |
| - ) |
| 34 | + uploaded_conf_path = as_config_file(mission_dir, filename) |
43 | 35 | uploaded_conf_path.write_text(json.dumps(BASE_CONFIG))
|
| 36 | + config_gen = ReforgerConfigGenerator( |
| 37 | + base_config_file=base_config, target_folder=mission_dir |
| 38 | + ) |
44 | 39 | # And another Zeusops mission was uploaded already under <filename2>
|
45 | 40 | filename2 = "Jib_20250229"
|
46 |
| - uploaded_conf_path2 = as_config_file(config_base, filename2) |
| 41 | + uploaded_conf_path2 = as_config_file(mission_dir, filename2) |
47 | 42 | uploaded_conf_path2.write_text(json.dumps(BASE_CONFIG))
|
48 | 43 | # And Zeus has already called "/zeus-set-mission" with <filename>
|
49 |
| - gen.zeus_set_mission(filename) |
| 44 | + config_gen.zeus_set_mission(filename) |
50 | 45 | # When Zeus calls "/zeus-set-mission" with <filename2>
|
51 |
| - gen.zeus_set_mission(filename2) |
| 46 | + config_gen.zeus_set_mission(filename2) |
52 | 47 | # Then a symbolic link is created from "current-config.json" to <filename2>
|
53 |
| - target = config_base / "current-config.json" |
| 48 | + target = mission_dir / "current-config.json" |
54 | 49 | assert target.exists(), "Should have created latest config symlink"
|
55 | 50 | assert target.is_symlink(), "Target config should be a symlink"
|
56 | 51 | assert target.readlink() == uploaded_conf_path2.relative_to(
|
57 |
| - config_base |
| 52 | + mission_dir |
58 | 53 | ), "Target should point to latest mission set"
|
0 commit comments