Skip to content

Commit

Permalink
Make test gpio control work again (#2034)
Browse files Browse the repository at this point in the history
* Made test_gpio_control work again

* Test configuration file had still `functionCallDown` and `functionCallUp` as function calls instead of newer `functionCall1` and `functionCall2`
* Made path of config file relative to the location from where the imports work (and the test is executed which is `./components/gpio_control/`

* Mocked function os.system in test_gpio_control

* Test didn't finished without this setting since os.system is used to check if a phoniebox service is running on the machine which may not run on machines this unit tests run on
  • Loading branch information
topas-rec authored Sep 2, 2023
1 parent 015897e commit 52f30de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions components/gpio_control/test/gpio_settings_test.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ PinUp: 16
PinDown: 19
timeBase: 0.1
; timeBase only for rotary encoder
functionCallDown: functionCallVolD
functionCallUp: functionCallVolU
functionCall1: functionCallVolU
functionCall2: functionCallVolD
functionCallTwoButtons: functionCallVol0
; functionCallTwoButtons only for TwoButtonControl
; functionCallButton: functionCallPlayerPause ; only for RotaryEncoderClickable
Expand Down
5 changes: 3 additions & 2 deletions components/gpio_control/test/test_gpio_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import logging

from mock import patch, MagicMock
from gpio_control import gpio_control
with patch('os.system', return_value=0):
from gpio_control import gpio_control
import function_calls

# def test_functionCallTwoButtonsOnlyBtn2Pressed(btn1Mock, btn2Mock, functionCall1Mock, functionCall2Mock,
Expand All @@ -29,7 +30,7 @@

def testMain():
config = configparser.ConfigParser()
config.read('./gpio_settings_test.ini')
config.read('./test/gpio_settings_test.ini')

phoniebox_function_calls = function_calls.phoniebox_function_calls()
gpio_controler = gpio_control(phoniebox_function_calls)
Expand Down

0 comments on commit 52f30de

Please sign in to comment.