Skip to content

Commit

Permalink
add some more credits mode tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jabdoa2 committed May 26, 2016
1 parent d9e4851 commit 3a781c1
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 4 deletions.
49 changes: 49 additions & 0 deletions mpf/tests/machine_files/credits/config/config_freeplay.yaml
@@ -0,0 +1,49 @@
#config_version=4

modes:
- credits

machine:
min_balls: 0

switches:
s_left_coin:
number:
s_center_coin:
number:
s_right_coin:
number:
s_esc:
number:
s_start:
number:
tags: start

coils:
c_eject:
number:

credits:
max_credits: 12
free_play: yes
service_credits_switch: s_esc
switches:
- switch: s_left_coin
type: money
value: .25
- switch: s_center_coin
type: money
value: .25
- switch: s_right_coin
type: money
value: 1
pricing_tiers:
- price: .50
credits: 1
- price: 2
credits: 5
fractional_credit_expiration_time: 15m
credit_expiration_time: 2h
persist_credits_while_off_time: 1h
free_play_string: FREE PLAY
credits_string: CREDITS
29 changes: 25 additions & 4 deletions mpf/tests/test_CreditsMode.py
Expand Up @@ -5,7 +5,10 @@
class TestCreditsMode(MpfTestCase):

def getConfigFile(self):
return 'config.yaml'
if self._testMethodName == "test_free_play_at_start":
return 'config_freeplay.yaml'
else:
return 'config.yaml'

def getMachinePath(self):
return 'tests/machine_files/credits/'
Expand All @@ -23,6 +26,20 @@ def start_game(self, should_work):
else:
self.assertIsNone(self.machine.game)

def start_two_player_game(self):
# game start should work
self.machine.playfield.add_ball = MagicMock()
self.machine.ball_controller.num_balls_known = 3
self.hit_and_release_switch("s_start")
self.advance_time_and_run()
self.assertIsNotNone(self.machine.game)
self.assertEqual(1, self.machine.game.num_players)

# add another player
self.hit_and_release_switch("s_start")
self.advance_time_and_run(1)
self.assertEqual(2, self.machine.game.num_players)

def stop_game(self):
# stop game
self.assertIsNotNone(self.machine.game)
Expand All @@ -42,8 +59,12 @@ def testFreePlay(self):

self.assertEqual("FREEEE", self.machine.get_machine_var('credits_string'))

# game start should work
self.start_game(True)
self.start_two_player_game()

def test_free_play_at_start(self):
self.assertEqual("FREE PLAY", self.machine.get_machine_var('credits_string'))

self.start_two_player_game()

def testToggleEvents(self):
self.assertTrue(self.machine.mode_controller.is_active('credits'))
Expand All @@ -60,7 +81,7 @@ def testToggleEvents(self):
self.post_event("toggle_credit_play")
self.assertEqual("FREE PLAY", self.machine.get_machine_var('credits_string'))

self.start_game(True)
self.start_two_player_game()
self.stop_game()

self.post_event("enable_credit_play")
Expand Down

0 comments on commit 3a781c1

Please sign in to comment.