-
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 x_loop_gate
- Loading branch information
Showing
7 changed files
with
132 additions
and
81 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
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,3 +1,3 @@ | ||
#!/bin/bash | ||
|
||
python -m unittest -v | ||
python -m unittest -v $1 |
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
mode: | ||
start_events: ball_starting | ||
priority: 100 | ||
priority: 50 | ||
|
||
ball_saves: | ||
ball_start_ball_save: | ||
|
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,38 @@ | ||
import os | ||
from mpf.core.rgb_color import RGBColor | ||
from mpf.tests.MpfGameTestCase import MpfGameTestCase | ||
|
||
class DeathSaveGameTesting(MpfGameTestCase): | ||
|
||
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 | ||
)) | ||
|
||
################## | ||
# 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) | ||
) |
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,54 +1,32 @@ | ||
"""Tests Base Mode""" | ||
import os | ||
from tests.death_save_game_testing import DeathSaveGameTesting | ||
|
||
from mpf.tests.MpfGameTestCase import MpfGameTestCase | ||
|
||
class TestBase(MpfGameTestCase): | ||
|
||
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 | ||
)) | ||
class TestBase(DeathSaveGameTesting): | ||
|
||
def test_scoring(self): | ||
self.start_game() | ||
v = "score" | ||
score = "score" | ||
|
||
score = 0 | ||
self.assertEqual(score, self.machine.game.player.score) | ||
|
||
self.__increment(v, "s_pop1", 10) | ||
self.__increment(v, "s_pop2", 10) | ||
self.__increment(v, "s_grooveline", 25) | ||
self.__increment(v, "s_qualifier1", 100) | ||
self.__increment(v, "s_qualifier2", 100) | ||
self.__increment(v, "s_qualifier3", 100) | ||
self.__increment(v, "s_podium_hole", 500) | ||
self.__increment(v, "s_prix_hole", 100) | ||
self.__increment(v, "s_grand_hole", 100) | ||
self.__increment(v, "s_spinner", 10) | ||
self.__increment(v, "s_grand_advance", 10) | ||
self.__increment(v, "s_prix_advance", 10) | ||
self.__increment(v, "s_podium_advance1", 10) | ||
self.__increment(v, "s_podium_advance2", 10) | ||
self.__increment(v, "s_slingshot1", 10) | ||
self.__increment(v, "s_slingshot2", 10) | ||
self.__increment(v, "s_inlane1", 25) | ||
self.__increment(v, "s_inlane2", 25) | ||
self.__increment(v, "s_outlane1", 50) | ||
self.__increment(v, "s_outlane2", 50) | ||
|
||
def __increment(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) | ||
) | ||
self.start_game() | ||
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", 25) | ||
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) |
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