Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auditor checks if events exist before setting to 0 #1619

Merged
merged 2 commits into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mpf/core/file_interface.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Interface for config file loaders."""
import logging
import os
from typing import Union, Tuple, Optional
from typing import Tuple, Optional

MYPY = False
if MYPY: # pragma: no cover
Expand All @@ -24,7 +24,7 @@ def __init__(self):
def find_file(self, filename) -> Tuple[Optional[str], Optional[str]]:
"""Test whether the passed file is valid.

If the file does not have an externsion, this method will test for files with that base name with
If the file does not have an extension, this method will test for files with that base name with
all the extensions it can read.

Args:
Expand Down
5 changes: 3 additions & 2 deletions mpf/plugins/auditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ def _load_defaults(self):
self.switchnames_to_audit = {x.name for x in self.machine.switches.values()
if 'no_audit' not in x.tags}

for event in self.config["events"]:
self.current_audits["events"][event] = 0
for event in self.config['events']:
if event not in self.current_audits['events']:
self.current_audits['events'][event] = 0

# Make sure we have all the player stuff in our audit dict
if 'player' in self.config['audit']:
Expand Down
4 changes: 3 additions & 1 deletion mpf/tests/test_Auditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_auditor_player_vars(self):
'my_var': {'top': [200, 0], 'average': 100.0, 'total': 2}},
auditor.data_manager.written_data["player"])

def test_auditor_switches(self):
def test_auditor_switches_events(self):
auditor = self.machine.plugins[0]
self.assertIsInstance(auditor, Auditor)
data_manager = auditor.data_manager
Expand Down Expand Up @@ -149,3 +149,5 @@ def test_auditor_switches(self):

self.assertEqual(0, auditor.current_audits['switches']['s_test'])
self.assertEqual(0, data_manager.written_data['switches']['s_test'])
self.assertEqual(0, auditor.current_audits['events']['game_started'])
self.assertEqual(0, data_manager.written_data['events']['game_started'])