Skip to content

Commit

Permalink
test: add basic displays test
Browse files Browse the repository at this point in the history
  • Loading branch information
unRARed committed Dec 7, 2024
1 parent 60de70b commit f56173f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 9 deletions.
43 changes: 43 additions & 0 deletions tests/test_displays.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from mpfmc.tests.FullMpfMachineTestCase import FullMachineTestCase

class TestDisplays(FullMachineTestCase):

def test_game_loop(self):
self.assertModeRunning("attract")

# TODO: decide what to display on the segments
# during the attract mode
widgets = self._get_display_text_widgets()
self.assertIn(
"1234567", [x.text for x in widgets]
)

# game begins and puts player1's score
# on the segment display
self.hit_and_release_switch("s_start")
self.advance_time_and_run(1)

widgets = self._get_display_text_widgets()
self.assertIn(
self.machine.game.player.score,
[int(x.text) for x in widgets]
)

# start game and player scores 10 points
# by hitting the grand advance switch
self.hit_and_release_switch("s_shooter_lane")
self.hit_and_release_switch("s_grand_advance")
self.advance_time_and_run(4)
widgets = self._get_display_text_widgets()
self.assertIn(10, [int(x.text) for x in widgets])

#############
## Helpers ##
#############

def _get_display_text_widgets(self):
current_widgets = []
for wgt in self.mc.displays['apron'].current_slide.widgets:
if hasattr(wgt.widget, 'text'):
current_widgets.append(wgt.widget)
return current_widgets
9 changes: 0 additions & 9 deletions tests/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@ class TestGeneral(MpfMachineTestCase):

"""Tests start-up sequence"""

def get_config_file(self):
return 'development.yaml'

def get_machine_path(self):
return os.path.abspath(os.path.join(
os.path.realpath(__file__),
os.pardir,os.pardir
))

def test_game_start(self):
self._machine_boots
self._game_begins
Expand Down

0 comments on commit f56173f

Please sign in to comment.