aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--midi_launchpad_mini_unittest.py41
1 files changed, 19 insertions, 22 deletions
diff --git a/midi_launchpad_mini_unittest.py b/midi_launchpad_mini_unittest.py
index 43fc561..4ae5480 100644
--- a/midi_launchpad_mini_unittest.py
+++ b/midi_launchpad_mini_unittest.py
@@ -1,3 +1,5 @@
+import pytest
+
from midi_controller_launchpad_mini import MidiController
class MidiWrapperMock:
@@ -66,23 +68,27 @@ class SoloToolMock:
else:
self.currentSong = max(self.currentSong - 1, 0)
-def test_connect():
- expectedDevice = "Launchpad Mini MIDI 1"
+@pytest.fixture
+def soloToolMock():
+ return SoloToolMock()
+
+@pytest.fixture
+def midiWrapperMock():
+ return MidiWrapperMock()
- soloToolMock = SoloToolMock()
- midiWrapperMock = MidiWrapperMock()
- uut = MidiController(soloToolMock, midiWrapperMock)
+@pytest.fixture
+def uut(soloToolMock, midiWrapperMock):
+ return MidiController(soloToolMock, midiWrapperMock)
+
+def test_connect(uut, midiWrapperMock):
+ expectedDevice = "Launchpad Mini MIDI 1"
uut.connect()
assert midiWrapperMock.connectedDevice == expectedDevice
-def test_startStopAndPauseButtons():
+def test_startStopAndPauseButtons(uut, midiWrapperMock, soloToolMock):
playPauseButton = 112
stopButton = 96
-
- soloToolMock = SoloToolMock()
- midiWrapperMock = MidiWrapperMock()
- uut = MidiController(soloToolMock, midiWrapperMock)
uut.connect()
assert soloToolMock.state == SoloToolMock.STOPPED
@@ -104,11 +110,8 @@ def test_startStopAndPauseButtons():
midiWrapperMock.simulateInput(stopButton)
assert soloToolMock.state == SoloToolMock.STOPPED
-def test_jumpToAButton():
+def test_jumpToAButton(uut, midiWrapperMock, soloToolMock):
ab = (0.5, 0.6)
- soloToolMock = SoloToolMock()
- midiWrapperMock = MidiWrapperMock()
- uut = MidiController(soloToolMock, midiWrapperMock)
uut.connect()
soloToolMock.currentAbLimit = (ab[0], ab[1])
@@ -117,10 +120,7 @@ def test_jumpToAButton():
midiWrapperMock.simulateInput(101)
assert soloToolMock.position == ab[0]
-def test_previousAndNextSongButtons():
- soloToolMock = SoloToolMock()
- midiWrapperMock = MidiWrapperMock()
- uut = MidiController(soloToolMock, midiWrapperMock)
+def test_previousAndNextSongButtons(uut, midiWrapperMock, soloToolMock):
uut.connect()
assert soloToolMock.currentSong == None
@@ -136,11 +136,8 @@ def test_previousAndNextSongButtons():
midiWrapperMock.simulateInput(118)
assert soloToolMock.currentSong == 0
-def test_unprogrammedButton():
+def test_unprogrammedButton(uut, midiWrapperMock, soloToolMock):
unusedButton = 48
- soloToolMock = SoloToolMock()
- midiWrapperMock = MidiWrapperMock()
- uut = MidiController(soloToolMock, midiWrapperMock)
uut.connect()
# expect no crash