From 3e24a35c1e46586cd3d27cced3e15db70b798a11 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 1 Oct 2016 13:57:10 -0700 Subject: [PATCH] Skip RFXtrx tests unless RFXTRX=RUN (#3625) * Skip RFXtrx tests unless RFXTRX=RUN * Remove my previous hacks to slightly speed up rfxtrx * Exclude RFXTRX tests from coverage * Remove unused import in rfxtrx tstt * Add close connection back to RFXtrx tests * Typo --- .coveragerc | 3 +++ tests/components/cover/test_rfxtrx.py | 2 +- tests/components/light/test_rfxtrx.py | 2 +- tests/components/rollershutter/test_rfxtrx.py | 2 +- tests/components/sensor/test_rfxtrx.py | 4 +++- tests/components/switch/test_rfxtrx.py | 2 +- tests/components/test_rfxtrx.py | 19 ++++++++----------- 7 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.coveragerc b/.coveragerc index c2a0e2636e8..e1652fb23b6 100644 --- a/.coveragerc +++ b/.coveragerc @@ -49,6 +49,9 @@ omit = homeassistant/components/qwikswitch.py homeassistant/components/*/qwikswitch.py + homeassistant/components/rfxtrx.py + homeassistant/components/*/rfxtrx.py + homeassistant/components/rpi_gpio.py homeassistant/components/*/rpi_gpio.py diff --git a/tests/components/cover/test_rfxtrx.py b/tests/components/cover/test_rfxtrx.py index a73a2b978dc..80d49dface4 100644 --- a/tests/components/cover/test_rfxtrx.py +++ b/tests/components/cover/test_rfxtrx.py @@ -9,7 +9,7 @@ from homeassistant.components import rfxtrx as rfxtrx_core from tests.common import get_test_home_assistant -@pytest.mark.skipif("os.environ.get('RFXTRX') == 'SKIP'") +@pytest.mark.skipif("os.environ.get('RFXTRX') != 'RUN'") class TestCoverRfxtrx(unittest.TestCase): """Test the Rfxtrx cover platform.""" diff --git a/tests/components/light/test_rfxtrx.py b/tests/components/light/test_rfxtrx.py index 80014dfd1c1..a9c2b2d8bcb 100644 --- a/tests/components/light/test_rfxtrx.py +++ b/tests/components/light/test_rfxtrx.py @@ -9,7 +9,7 @@ from homeassistant.components import rfxtrx as rfxtrx_core from tests.common import get_test_home_assistant -@pytest.mark.skipif("os.environ.get('RFXTRX') == 'SKIP'") +@pytest.mark.skipif("os.environ.get('RFXTRX') != 'RUN'") class TestLightRfxtrx(unittest.TestCase): """Test the Rfxtrx light platform.""" diff --git a/tests/components/rollershutter/test_rfxtrx.py b/tests/components/rollershutter/test_rfxtrx.py index 1218ab37a59..e16f841c3fe 100644 --- a/tests/components/rollershutter/test_rfxtrx.py +++ b/tests/components/rollershutter/test_rfxtrx.py @@ -9,7 +9,7 @@ from homeassistant.components import rfxtrx as rfxtrx_core from tests.common import get_test_home_assistant -@pytest.mark.skipif("os.environ.get('RFXTRX') == 'SKIP'") +@pytest.mark.skipif("os.environ.get('RFXTRX') != 'RUN'") class TestRollershutterRfxtrx(unittest.TestCase): """Test the Rfxtrx roller shutter platform.""" diff --git a/tests/components/sensor/test_rfxtrx.py b/tests/components/sensor/test_rfxtrx.py index e42aaea7e04..cfe5a95605d 100644 --- a/tests/components/sensor/test_rfxtrx.py +++ b/tests/components/sensor/test_rfxtrx.py @@ -10,7 +10,7 @@ from homeassistant.const import TEMP_CELSIUS from tests.common import get_test_home_assistant -@pytest.mark.skipif("os.environ.get('RFXTRX') == 'SKIP'") +@pytest.mark.skipif("os.environ.get('RFXTRX') != 'RUN'") class TestSensorRfxtrx(unittest.TestCase): """Test the Rfxtrx sensor platform.""" @@ -23,6 +23,8 @@ class TestSensorRfxtrx(unittest.TestCase): """Stop everything that was started.""" rfxtrx_core.RECEIVED_EVT_SUBSCRIBERS = [] rfxtrx_core.RFX_DEVICES = {} + if rfxtrx_core.RFXOBJECT: + rfxtrx_core.RFXOBJECT.close_connection() self.hass.stop() def test_default_config(self): diff --git a/tests/components/switch/test_rfxtrx.py b/tests/components/switch/test_rfxtrx.py index 729abf6db06..4caf7b3405d 100644 --- a/tests/components/switch/test_rfxtrx.py +++ b/tests/components/switch/test_rfxtrx.py @@ -9,7 +9,7 @@ from homeassistant.components import rfxtrx as rfxtrx_core from tests.common import get_test_home_assistant -@pytest.mark.skipif("os.environ.get('RFXTRX') == 'SKIP'") +@pytest.mark.skipif("os.environ.get('RFXTRX') != 'RUN'") class TestSwitchRfxtrx(unittest.TestCase): """Test the Rfxtrx switch platform.""" diff --git a/tests/components/test_rfxtrx.py b/tests/components/test_rfxtrx.py index bd37d873150..b26483c8771 100644 --- a/tests/components/test_rfxtrx.py +++ b/tests/components/test_rfxtrx.py @@ -1,7 +1,6 @@ -"""Th tests for the Rfxtrx component.""" +"""The tests for the Rfxtrx component.""" # pylint: disable=too-many-public-methods,protected-access import unittest -from unittest.mock import patch import pytest @@ -10,7 +9,7 @@ from homeassistant.components import rfxtrx as rfxtrx from tests.common import get_test_home_assistant -@pytest.mark.skipif("os.environ.get('RFXTRX') == 'SKIP'") +@pytest.mark.skipif("os.environ.get('RFXTRX') != 'RUN'") class TestRFXTRX(unittest.TestCase): """Test the Rfxtrx component.""" @@ -22,10 +21,11 @@ class TestRFXTRX(unittest.TestCase): """Stop everything that was started.""" rfxtrx.RECEIVED_EVT_SUBSCRIBERS = [] rfxtrx.RFX_DEVICES = {} + if rfxtrx.RFXOBJECT: + rfxtrx.RFXOBJECT.close_connection() self.hass.stop() - @patch('RFXtrx.sleep') - def test_default_config(self, mock_sleep): + def test_default_config(self): """Test configuration.""" self.assertTrue(_setup_component(self.hass, 'rfxtrx', { 'rfxtrx': { @@ -41,8 +41,7 @@ class TestRFXTRX(unittest.TestCase): self.assertEqual(len(rfxtrx.RFXOBJECT.sensors()), 2) - @patch('RFXtrx.sleep') - def test_valid_config(self, mock_sleep): + def test_valid_config(self): """Test configuration.""" self.assertTrue(_setup_component(self.hass, 'rfxtrx', { 'rfxtrx': { @@ -71,8 +70,7 @@ class TestRFXTRX(unittest.TestCase): '-RFXCOM_RFXtrx433_A1Y0NJGR-if00-port0', 'invalid_key': True}})) - @patch('RFXtrx.sleep') - def test_fire_event(self, mock_sleep): + def test_fire_event(self): """Test fire event.""" self.assertTrue(_setup_component(self.hass, 'rfxtrx', { 'rfxtrx': { @@ -116,8 +114,7 @@ class TestRFXTRX(unittest.TestCase): self.assertEqual(calls[0].data, {'entity_id': 'switch.test', 'state': 'on'}) - @patch('RFXtrx.sleep') - def test_fire_event_sensor(self, mock_sleep): + def test_fire_event_sensor(self): """Test fire event.""" self.assertTrue(_setup_component(self.hass, 'rfxtrx', { 'rfxtrx': {