diff options
author | Eddy Pedroni <eddy@0xf7.com> | 2022-01-03 15:56:59 +0100 |
---|---|---|
committer | Eddy Pedroni <eddy@0xf7.com> | 2022-01-03 15:56:59 +0100 |
commit | 794d645856da721e0bc7e97a788dcc60e4c87f0c (patch) | |
tree | ab150e8e99a32a43e00ab8a66137eec0ecd85154 | |
parent | 3472fa7854b575d0d08b4baa23a672cccd1ccaab (diff) |
Refactored tests, dropped SimpleQueue usage
-rw-r--r-- | midi_launchpad_mini_integrationtest.py | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/midi_launchpad_mini_integrationtest.py b/midi_launchpad_mini_integrationtest.py index e5b757c..5a28925 100644 --- a/midi_launchpad_mini_integrationtest.py +++ b/midi_launchpad_mini_integrationtest.py @@ -6,11 +6,9 @@ from player_mock import Player as PlayerMock class MidiWrapperMock: def __init__(self): - from queue import SimpleQueue self.callback = None self.connectedDevice = None - self.sentMessages = SimpleQueue() - self.latestMessage = None + self.sentMessages = list() def setCallback(self, callback): self.callback = callback @@ -19,8 +17,7 @@ class MidiWrapperMock: self.connectedDevice = deviceName def sendMessage(self, note, velocity, channel): - self.latestMessage = (note, velocity, channel) - self.sentMessages.put(self.latestMessage) + self.sentMessages.append((note, velocity, channel)) def simulateInput(self, note, velocity=127, channel=0): if self.callback is not None: @@ -29,7 +26,7 @@ class MidiWrapperMock: self.callback(msg) def getLatestMessage(self): - return self.latestMessage + return self.sentMessages[-1] @pytest.fixture def playerMock(): @@ -231,9 +228,6 @@ def test_initializationMessages(uut, midiWrapperMock): uut.connect() - sentMessages = set() - while (not midiWrapperMock.sentMessages.empty()): - sentMessages.add(midiWrapperMock.sentMessages.get()) - - assert sentMessages == expectedMessages + sentMessagesSet = set(midiWrapperMock.sentMessages) + assert sentMessagesSet == expectedMessages |