-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: reorganize and test more green flag edges
- Loading branch information
Showing
20 changed files
with
290 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ if [ -z "$1" ]; then | |
else | ||
FILES="$1" | ||
fi | ||
python -m unittest -v $FILES | ||
python -m unittest $FILES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
################## | ||
# Helper Methods # | ||
################## | ||
|
||
# For given :var, activate given :switch and check | ||
# whether value has increased by given :value | ||
# | ||
# @param var: variable to check (score, bonus, etc.) | ||
# @param switch: switch to activate (s_spinner, s_pop1, etc.) | ||
# @param value: amount we expect the :var to increase by | ||
# | ||
# Example: self.assertIncrement("score", "s_spinner", 10) | ||
# | ||
def _assertIncrement(self, var, switch, value): | ||
current_val = getattr(self.machine.game.player, var) | ||
value, getattr(self.machine.game.player, var) | ||
self.hit_and_release_switch(switch) | ||
self.advance_time_and_run(1) | ||
new_val = getattr(self.machine.game.player, var) | ||
self.assertEqual( | ||
value, new_val - current_val, | ||
"Expected %s, got %s" % (value, new_val - current_val) | ||
) | ||
|
||
def _start(self): | ||
self.assertEqual(3, | ||
self.machine.ball_devices.bd_trough.balls) | ||
self.assertModeRunning('attract') | ||
self.assertModeNotRunning('base') | ||
self.hit_and_release_switch("s_start") | ||
self.advance_time_and_run(1) | ||
self.assertEqual(2, | ||
self.machine.ball_devices["bd_trough"].balls) | ||
self.assertEqual(1, | ||
self.machine.ball_devices["bd_shooter_lane"].balls) | ||
self.assertEqual(0, self.machine.playfield.balls) | ||
self.hit_and_release_switch("s_shooter_lane") | ||
self.advance_time_and_run(4) | ||
self.assertEqual(1, self.machine.playfield.balls) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,11 @@ | ||
import os | ||
from mpf.core.rgb_color import RGBColor | ||
from mpf.tests.MpfGameTestCase import MpfGameTestCase | ||
from mpf.tests.MpfMachineTestCase import MpfMachineTestCase | ||
import tests.death_save as death_save | ||
|
||
class DeathSaveGameTesting(MpfGameTestCase): | ||
class DeathSaveGameTesting(MpfMachineTestCase): | ||
|
||
def get_config_file(self): | ||
return 'development.yaml' | ||
def _assertIncrement(self, var, switch, value): | ||
death_save._assertIncrement(self, var, switch, value) | ||
|
||
def get_machine_path(self): | ||
return os.path.abspath(os.path.join( | ||
os.path.realpath(__file__), | ||
os.pardir,os.pardir | ||
)) | ||
|
||
################## | ||
# Helper Methods # | ||
################## | ||
|
||
# For given :var, activate given :switch and check | ||
# whether value has increased by given :value | ||
# | ||
# @param var: variable to check (score, bonus, etc.) | ||
# @param switch: switch to activate (s_spinner, s_pop1, etc.) | ||
# @param value: amount we expect the :var to increase by | ||
# | ||
# Example: self.assertIncrement("score", "s_spinner", 10) | ||
# | ||
def assertIncrement(self, var, switch, value): | ||
current_val = getattr(self.machine.game.player, var) | ||
value, getattr(self.machine.game.player, var) | ||
self.hit_and_release_switch(switch) | ||
self.advance_time_and_run(1) | ||
new_val = getattr(self.machine.game.player, var) | ||
self.assertEqual( | ||
value, new_val - current_val, | ||
"Expected %s, got %s" % (value, new_val - current_val) | ||
) | ||
def _start(self): | ||
death_save._start(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import os | ||
from mpfmc.tests.FullMpfMachineTestCase import FullMachineTestCase | ||
import tests.death_save as death_save | ||
|
||
class DeathSaveMcTesting(FullMachineTestCase): | ||
|
||
def _assertIncrement(self, var, switch, value): | ||
death_save._assertIncrement(self, var, switch, value) | ||
|
||
def _start(self): | ||
death_save._start(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,32 @@ | ||
"""Tests Base Mode""" | ||
from tests.death_save_game_testing import DeathSaveGameTesting | ||
|
||
class TestBase(DeathSaveGameTesting): | ||
|
||
def test_scoring(self): | ||
score = "score" | ||
|
||
self.start_game() | ||
self._start() | ||
self.assertEqual(0, self.machine.game.player.score) | ||
self.assertIncrement(score, "s_pop1", 10) | ||
self.assertIncrement(score, "s_pop2", 10) | ||
self.assertIncrement(score, "s_grooveline", 50) | ||
self._assertIncrement(score, "s_pop1", 10) | ||
self._assertIncrement(score, "s_pop2", 10) | ||
self._assertIncrement(score, "s_grooveline", 50) | ||
|
||
self.assertIncrement(score, "s_qualifier2", 100) | ||
self.assertIncrement(score, "s_qualifier3", 100) | ||
self.assertIncrement(score, "s_podium_hole", 500) | ||
self.assertIncrement(score, "s_prix_hole", 100) | ||
self.assertIncrement(score, "s_grand_hole", 100) | ||
self.assertIncrement(score, "s_spinner", 10) | ||
self.assertIncrement(score, "s_grand_advance", 10) | ||
self.assertIncrement(score, "s_prix_advance", 10) | ||
self.assertIncrement(score, "s_podium_advance1", 10) | ||
self.assertIncrement(score, "s_podium_advance2", 10) | ||
self.assertIncrement(score, "s_slingshot1", 10) | ||
self.assertIncrement(score, "s_slingshot2", 10) | ||
self.assertIncrement(score, "s_inlane1", 25) | ||
self.assertIncrement(score, "s_inlane2", 25) | ||
self.assertIncrement(score, "s_outlane1", 50) | ||
self.assertIncrement(score, "s_outlane2", 50) | ||
self._assertIncrement(score, "s_qualifier2", 100) | ||
self._assertIncrement(score, "s_qualifier3", 100) | ||
self._assertIncrement(score, "s_podium_hole", 500) | ||
self._assertIncrement(score, "s_prix_hole", 100) | ||
self._assertIncrement(score, "s_grand_hole", 100) | ||
self._assertIncrement(score, "s_spinner", 10) | ||
self._assertIncrement(score, "s_grand_advance", 10) | ||
self._assertIncrement(score, "s_prix_advance", 10) | ||
self._assertIncrement(score, "s_podium_advance1", 10) | ||
self._assertIncrement(score, "s_podium_advance2", 10) | ||
self._assertIncrement(score, "s_slingshot1", 10) | ||
self._assertIncrement(score, "s_slingshot2", 10) | ||
self._assertIncrement(score, "s_inlane1", 25) | ||
self._assertIncrement(score, "s_inlane2", 25) | ||
self._assertIncrement(score, "s_outlane1", 50) | ||
self._assertIncrement(score, "s_outlane2", 50) | ||
# Activates green_flag mode, so check last | ||
# to prevent scoring false positives | ||
self.assertIncrement(score, "s_qualifier1", 100) | ||
self._assertIncrement(score, "s_qualifier1", 100) |
Oops, something went wrong.