diff options
author | Devaev Maxim <[email protected]> | 2020-09-13 21:43:52 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-09-13 21:43:52 +0300 |
commit | 5ed0c27f1f7201783d60e035ba26f35f62539a08 (patch) | |
tree | b51e154595e9ce14499cd950d902c8dc41da49c8 /testenv | |
parent | 0ad0d17528eeb52ba0dee78d5be440f092fed7d7 (diff) |
removed rpi.gpio
Diffstat (limited to 'testenv')
-rw-r--r-- | testenv/linters/vulture-wl.py | 2 | ||||
-rw-r--r-- | testenv/requirements.txt | 2 | ||||
-rw-r--r-- | testenv/tests/__init__.py | 39 | ||||
-rw-r--r-- | testenv/tests/test_gpio.py | 58 |
4 files changed, 0 insertions, 101 deletions
diff --git a/testenv/linters/vulture-wl.py b/testenv/linters/vulture-wl.py index afb95bc2..62338131 100644 --- a/testenv/linters/vulture-wl.py +++ b/testenv/linters/vulture-wl.py @@ -20,8 +20,6 @@ IpmiServer.handle_raw_request _AtxApiPart.switch_power -fake_rpi.RPi.GPIO - _KeyMapping.web_name _KeyMapping.serial_code _KeyMapping.arduino_name diff --git a/testenv/requirements.txt b/testenv/requirements.txt index a88dd993..74cfcdb5 100644 --- a/testenv/requirements.txt +++ b/testenv/requirements.txt @@ -1,5 +1,3 @@ -git+git://github.com/willbuckner/rpi-gpio-development-mock@master#egg=rpi -fake_rpi aiohttp aiofiles passlib diff --git a/testenv/tests/__init__.py b/testenv/tests/__init__.py index d1faace6..1e91f7fa 100644 --- a/testenv/tests/__init__.py +++ b/testenv/tests/__init__.py @@ -18,42 +18,3 @@ # along with this program. If not, see <https://www.gnu.org/licenses/>. # # # # ========================================================================== # - - -import sys - -from typing import Dict -from typing import Optional - -import fake_rpi.RPi - - -# ===== -class _GPIO(fake_rpi.RPi._GPIO): # pylint: disable=protected-access - def __init__(self) -> None: - super().__init__() - self.__states: Dict[int, int] = {} - - @fake_rpi.RPi.printf - def setup(self, channel: int, state: int, initial: int=0, pull_up_down: Optional[int]=None) -> None: - _ = state # Makes linter happy - _ = pull_up_down # Makes linter happy - self.__states[int(channel)] = int(initial) - - @fake_rpi.RPi.printf - def output(self, channel: int, state: int) -> None: - self.__states[int(channel)] = int(state) - - @fake_rpi.RPi.printf - def input(self, channel: int) -> int: # pylint: disable=arguments-differ - return self.__states[int(channel)] - - @fake_rpi.RPi.printf - def cleanup(self, channel: Optional[int]=None) -> None: # pylint: disable=arguments-differ - _ = channel # Makes linter happy - self.__states = {} - - -# ===== -fake_rpi.RPi.GPIO = _GPIO() -sys.modules["RPi"] = fake_rpi.RPi diff --git a/testenv/tests/test_gpio.py b/testenv/tests/test_gpio.py deleted file mode 100644 index 3db61609..00000000 --- a/testenv/tests/test_gpio.py +++ /dev/null @@ -1,58 +0,0 @@ -# ========================================================================== # -# # -# KVMD - The main Pi-KVM daemon. # -# # -# Copyright (C) 2018 Maxim Devaev <[email protected]> # -# # -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU General Public License as published by # -# the Free Software Foundation, either version 3 of the License, or # -# (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU General Public License for more details. # -# # -# You should have received a copy of the GNU General Public License # -# along with this program. If not, see <https://www.gnu.org/licenses/>. # -# # -# ========================================================================== # - - -import pytest - -from kvmd import gpio - - -# ===== [email protected]("pin", [0, 1, 13]) -def test_ok__loopback_initial_false(pin: int) -> None: - with gpio.bcm(): - assert gpio.set_output(pin, False) == pin - assert gpio.read(pin) is False - gpio.write(pin, True) - assert gpio.read(pin) is True - - [email protected]("pin", [0, 1, 13]) -def test_ok__loopback_initial_true(pin: int) -> None: - with gpio.bcm(): - assert gpio.set_output(pin, True) == pin - assert gpio.read(pin) is True - gpio.write(pin, False) - assert gpio.read(pin) is False - - [email protected]("pin", [0, 1, 13]) -def test_ok__input(pin: int) -> None: - with gpio.bcm(): - assert gpio.set_input(pin) == pin - assert gpio.read(pin) is False - - -def test_fail__invalid_pin() -> None: - with pytest.raises(AssertionError): - gpio.set_output(-1, False) - with pytest.raises(AssertionError): - gpio.set_input(-1) |