-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_mission_events.py
46 lines (37 loc) · 1.24 KB
/
test_mission_events.py
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
"""This file contains tests for the win/loss events found in mission files.
Imports From:
campaign.py
report.py
Functions:
test_mission_events()
"""
from campaign import Campaign
from report import Report
def test_mission_events(current_campaign: Campaign):
"""Test each mission to ensure the specified win/loss events exist
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:
try:
if (
win := mission.events["win"]
) not in current_campaign.language_info.events.events:
report.errors.append(
f'ERROR: Mission {mission.name} calls for missing win event "{win}".'
)
except KeyError:
continue
try:
if (
fail := mission.events["fail"]
) not in current_campaign.language_info.events.events:
report.errors.append(
f'ERROR: Mission {mission.name} calls for missing fail event "{fail}".'
)
except KeyError:
continue
return report