-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_mission_vessel_inventory_integrity.py
More file actions
68 lines (61 loc) · 2.64 KB
/
test_mission_vessel_inventory_integrity.py
File metadata and controls
68 lines (61 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""This file contains tests to compare all vessels found in mission files to the vessel inventories
Imports From:
campaign.py
report.py
Functions:
test_mission_vessel_inventory_integrity()
"""
from campaign import Campaign
from report import Report
def test_mission_vessel_inventory_integrity(current_campaign: Campaign) -> Report:
"""Test the vessels found in a mission for incorrect vessels and selectors
Parameters:
current_campaign: Campaign | The parsed campaign to be tested
Returns:
Report | The completed Report to be returned
"""
report = Report()
for mission in current_campaign.missions:
mission_name = mission.name
all_vessels: list[str] = []
if (
not current_campaign.vessel_inventory.vessel_inventory
and not current_campaign.vessel_inventory.selectors
):
report.announcements.append(
"ANNOUNCEMENT: Vessel inventory not loaded. Skipping vessel name integrity checks."
)
return report
try:
for index, vessel_role in enumerate(mission.enemy_units["classes"]):
for vessel in vessel_role.split("|"):
all_vessels.append(vessel)
if mission.enemy_units["important"][index] == "TRUE":
if (
vessel
in current_campaign.vessel_inventory.vessel_inventory.keys()
):
if (
current_campaign.vessel_inventory.vessel_inventory[
vessel
]
== 0
and len(vessel_role.split("|")) == 1
):
report.infos.append(
f"INFO: In mission {mission_name} critical vessel {vessel} "
"has no units availible and so this mission cannot appear."
)
except (KeyError, IndexError):
continue
for vessel in all_vessels:
if (
vessel not in current_campaign.vessel_inventory.vessel_inventory.keys()
and vessel not in current_campaign.vessel_inventory.selectors.keys()
and vessel != "testship"
):
report.warnings.append(
f"WARNING: Mission {mission_name} has vessel {vessel}, "
"which is neither in the vessel inventory nor a valid selector."
)
return report