1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Remove more test requirements (#7574)

* No longer require pyunify during tests

* No longer require cast during tests

* No longer required dependency for tests

* No longer require pymochad for tests

* Astral is a core dependency

* Avoid having to install datadog dependency during tests

* CMUS test doesn't test anything

* Frontier Silicon doesn't test anything

* No longer require mutagen

* Update requirements_test_all.txt

* Remove stale comment
This commit is contained in:
Paulus Schoutsen
2017-05-13 21:25:54 -07:00
committed by GitHub
parent 206d02d531
commit 352cca1037
14 changed files with 223 additions and 257 deletions

View File

@@ -2,6 +2,8 @@
import unittest
import unittest.mock as mock
import pytest
from homeassistant.setup import setup_component
from homeassistant.components import switch
from homeassistant.components.switch import mochad
@@ -9,6 +11,15 @@ from homeassistant.components.switch import mochad
from tests.common import get_test_home_assistant
@pytest.fixture(autouse=True)
def pymochad_mock():
"""Mock pymochad."""
with mock.patch.dict('sys.modules', {
'pymochad': mock.MagicMock(),
}):
yield
class TestMochadSwitchSetup(unittest.TestCase):
"""Test the mochad switch."""
@@ -18,17 +29,14 @@ class TestMochadSwitchSetup(unittest.TestCase):
def setUp(self):
"""Setup things to be run when tests are started."""
super(TestMochadSwitchSetup, self).setUp()
self.hass = get_test_home_assistant()
def tearDown(self):
"""Stop everyhing that was started."""
self.hass.stop()
super(TestMochadSwitchSetup, self).tearDown()
@mock.patch('pymochad.controller.PyMochad')
@mock.patch('homeassistant.components.switch.mochad.MochadSwitch')
def test_setup_adds_proper_devices(self, mock_switch, mock_client):
def test_setup_adds_proper_devices(self, mock_switch):
"""Test if setup adds devices."""
good_config = {
'mochad': {},
@@ -50,12 +58,8 @@ class TestMochadSwitch(unittest.TestCase):
def setUp(self):
"""Setup things to be run when tests are started."""
super(TestMochadSwitch, self).setUp()
self.hass = get_test_home_assistant()
controller_mock = mock.MagicMock()
device_patch = mock.patch('pymochad.device.Device')
device_patch.start()
self.addCleanup(device_patch.stop)
dev_dict = {'address': 'a1', 'name': 'fake_switch'}
self.switch = mochad.MochadSwitch(self.hass, controller_mock,
dev_dict)