s/Addres /Address / s/Chnage/Change/ s/Converion/Conversion/ s/Supressing/Suppressing/ s/agains /against / s/allready/already/ s/analagous/analogous/ s/aquired/acquired/ s/arbitray/arbitrary/ s/argment/argument/ s/aroung/around/ s/attibute/attribute/ s/auxillary/auxiliary/ s/befor /before / s/commmand/command/ s/conatin/contain/ s/conection/connection/ s/coresponding/corresponding/ s/entites/entities/ s/enviroment/environment/ s/everyhing/everything/ s/expected expected/expected/ s/explicity/explicitly/ s/formated/formatted/ s/incomming/incoming/ s/informations/information/ s/inital/initial/ s/inteface/interface/ s/interupt/interrupt/ s/mimick/mimic/ s/mulitple/multiple/ s/multible/multiple/ s/occured/occurred/ s/occuring/occurring/ s/overrided/overridden/ s/overriden/overridden/ s/platfrom/platform/ s/positon/position/ s/progess/progress/ s/recieved/received/ s/reciever/receiver/ s/recieving/receiving/ s/reponse/response/ s/representaion/representation/ s/resgister/register/ s/retrive/retrieve/ s/reuqests/requests/ s/segements/segments/ s/seperated/separated/ s/sheduled/scheduled/ s/succesfully/successfully/ s/suppport/support/ s/targetting/targeting/ s/thats/that's/ s/the the/the/ s/unkown/unknown/ s/verison/version/ s/while loggin out/while logging out/
88 lines
2.5 KiB
Python
88 lines
2.5 KiB
Python
"""The tests for the mochad light platform."""
|
|
import unittest
|
|
import unittest.mock as mock
|
|
|
|
import pytest
|
|
|
|
from homeassistant.components import light
|
|
from homeassistant.components.light import mochad
|
|
from homeassistant.setup import setup_component
|
|
|
|
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 light."""
|
|
|
|
PLATFORM = mochad
|
|
COMPONENT = light
|
|
THING = 'light'
|
|
|
|
def setUp(self):
|
|
"""Setup things to be run when tests are started."""
|
|
self.hass = get_test_home_assistant()
|
|
|
|
def tearDown(self):
|
|
"""Stop everything that was started."""
|
|
self.hass.stop()
|
|
|
|
@mock.patch('homeassistant.components.light.mochad.MochadLight')
|
|
def test_setup_adds_proper_devices(self, mock_light):
|
|
"""Test if setup adds devices."""
|
|
good_config = {
|
|
'mochad': {},
|
|
'light': {
|
|
'platform': 'mochad',
|
|
'devices': [
|
|
{
|
|
'name': 'Light1',
|
|
'address': 'a1',
|
|
},
|
|
],
|
|
}
|
|
}
|
|
self.assertTrue(setup_component(self.hass, light.DOMAIN, good_config))
|
|
|
|
|
|
class TestMochadLight(unittest.TestCase):
|
|
"""Test for mochad light platform."""
|
|
|
|
def setUp(self):
|
|
"""Setup things to be run when tests are started."""
|
|
self.hass = get_test_home_assistant()
|
|
controller_mock = mock.MagicMock()
|
|
dev_dict = {'address': 'a1', 'name': 'fake_light'}
|
|
self.light = mochad.MochadLight(self.hass, controller_mock,
|
|
dev_dict)
|
|
|
|
def teardown_method(self, method):
|
|
"""Stop everything that was started."""
|
|
self.hass.stop()
|
|
|
|
def test_name(self):
|
|
"""Test the name."""
|
|
self.assertEqual('fake_light', self.light.name)
|
|
|
|
def test_turn_on_with_no_brightness(self):
|
|
"""Test turn_on."""
|
|
self.light.turn_on()
|
|
self.light.device.send_cmd.assert_called_once_with('xdim 255')
|
|
|
|
def test_turn_on_with_brightness(self):
|
|
"""Test turn_on."""
|
|
self.light.turn_on(brightness=45)
|
|
self.light.device.send_cmd.assert_called_once_with('xdim 45')
|
|
|
|
def test_turn_off(self):
|
|
"""Test turn_off."""
|
|
self.light.turn_off()
|
|
self.light.device.send_cmd.assert_called_once_with('off')
|