Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
92 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#config_version=4 | ||
|
||
switches: | ||
s_position_up: | ||
number: | ||
s_position_down: | ||
number: | ||
|
||
coils: | ||
c_motor_run: | ||
number: | ||
allow_enable: True | ||
|
||
motors: | ||
motorized_drop_target_bank: | ||
motor_coil: c_motor_run | ||
position_switches: | ||
up: s_position_up | ||
down: s_position_down | ||
reset_position: down | ||
go_to_position: | ||
go_up: up | ||
go_down: down | ||
go_down2: down |
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,68 @@ | ||
from unittest.mock import MagicMock | ||
|
||
from mpf.tests.MpfTestCase import MpfTestCase | ||
|
||
|
||
class TestMotors(MpfTestCase): | ||
|
||
def getConfigFile(self): | ||
return 'config.yaml' | ||
|
||
def getMachinePath(self): | ||
return 'tests/machine_files/motor/' | ||
|
||
def testMotorizedDropTargetBank(self): | ||
motor = self.machine.motors.motorized_drop_target_bank | ||
coil = self.machine.coils.c_motor_run | ||
coil.enable = MagicMock() | ||
coil.disable = MagicMock() | ||
|
||
# reset should move it down | ||
motor.reset() | ||
self.advance_time_and_run() | ||
coil.enable.assert_called_with() | ||
coil.enable = MagicMock() | ||
assert not coil.disable.called | ||
|
||
# it goes up. nothing should happen | ||
self.hit_switch_and_run("s_position_up", 1) | ||
assert not coil.enable.called | ||
assert not coil.disable.called | ||
|
||
# it leaves up position | ||
self.release_switch_and_run("s_position_up", 1) | ||
assert not coil.enable.called | ||
assert not coil.disable.called | ||
|
||
self.advance_time_and_run(5) | ||
# it goes down. motor should stop | ||
self.hit_switch_and_run("s_position_down", 1) | ||
assert not coil.enable.called | ||
coil.disable.assert_called_with() | ||
coil.disable = MagicMock() | ||
|
||
# should not start motor | ||
self.post_event("go_down2") | ||
self.advance_time_and_run() | ||
assert not coil.enable.called | ||
coil.disable.assert_called_with() | ||
coil.disable = MagicMock() | ||
|
||
# go up | ||
self.post_event("go_up") | ||
self.advance_time_and_run() | ||
coil.enable.assert_called_with() | ||
coil.enable = MagicMock() | ||
assert not coil.disable.called | ||
|
||
# it leaves down position | ||
self.release_switch_and_run("s_position_down", 0) | ||
assert not coil.enable.called | ||
assert not coil.disable.called | ||
|
||
self.advance_time_and_run(5) | ||
# it goes up. motor should stop | ||
self.hit_switch_and_run("s_position_up", 1) | ||
assert not coil.enable.called | ||
coil.disable.assert_called_with() | ||
coil.disable = MagicMock() |