-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_campaign_mission_types.py
More file actions
53 lines (44 loc) · 1.62 KB
/
test_campaign_mission_types.py
File metadata and controls
53 lines (44 loc) · 1.62 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
"""This file contains tests for the mission types of mission files
Imports From:
campaign.py
report.py
Functions:
test_campaign_mission_types()
"""
from campaign import Campaign
from report import Report
def test_campaign_mission_types(current_campaign: Campaign) -> Report:
"""Test each mission to ensure that mission types are correct, in filename and file entry
Parameters:
current_campaign: Campaign | The parsed campaign to be tested
Returns:
Report | The completed Report to be returned
"""
report = Report()
if not current_campaign.campaign_data.parsed:
return report
for mission in current_campaign.missions:
try:
if (
mission.type
not in current_campaign.campaign_data.player_mission_data["types"]
and mission.type
not in current_campaign.campaign_data.ai_mission_data["types"]
):
report.errors.append(
f"ERROR: Mission {mission.name} of unrecognized type {mission.type}."
)
except AttributeError:
continue
for mission in current_campaign.missions:
try:
part_name = mission.name.split("_")[0]
for part in mission.name.split("_")[1:-1]:
part_name += f"_{part}"
if mission.type != part_name and mission.type != mission.name:
report.errors.append(
f"Mission {mission.name} is not of the same type as specified in the file!"
)
except AttributeError:
continue
return report