Merge pull request #1262 from balloob/chore/tests-cleanup
More testing cleanup
This commit is contained in:
commit
cdc93ab670
10 files changed
+56
-62
No files matched your search
@@ -28,9 +28,7 @@ def _url(data={}):
|
||||
return "{}{}locative?{}".format(HTTP_BASE_URL, const.URL_API, data)
|
||||
|
||||
|
||||
@patch('homeassistant.components.http.util.get_local_ip',
|
||||
return_value='127.0.0.1')
|
||||
def setUpModule(mock_get_local_ip): # pylint: disable=invalid-name
|
||||
def setUpModule(): # pylint: disable=invalid-name
|
||||
""" Initalizes a Home Assistant server. """
|
||||
global hass
|
||||
|
||||
@@ -66,6 +64,9 @@ def tearDownModule(): # pylint: disable=invalid-name
|
||||
class TestLocative(unittest.TestCase):
|
||||
""" Test Locative """
|
||||
|
||||
def tearDown(self):
|
||||
hass.pool.block_till_done()
|
||||
|
||||
def test_missing_data(self, update_config):
|
||||
data = {
|
||||
'latitude': 1.0,
|
||||
|
||||
@@ -172,12 +172,12 @@ class TestLightMQTT(unittest.TestCase):
|
||||
self.assertIsNone(state.attributes.get('brightness'))
|
||||
self.assertIsNone(state.attributes.get('rgb_color'))
|
||||
|
||||
fire_mqtt_message(self.hass, 'test_light_rgb/rgb/status',
|
||||
'{"hello": [1, 2, 3]}')
|
||||
fire_mqtt_message(self.hass, 'test_light_rgb/status',
|
||||
'{"hello": "ON"}')
|
||||
fire_mqtt_message(self.hass, 'test_light_rgb/brightness/status',
|
||||
'{"hello": "50"}')
|
||||
fire_mqtt_message(self.hass, 'test_light_rgb/rgb/status',
|
||||
'{"hello": [1, 2, 3]}')
|
||||
self.hass.pool.block_till_done()
|
||||
|
||||
state = self.hass.states.get('light.test')
|
||||
|
||||
@@ -7,7 +7,6 @@ Tests Home Assistant Alexa component does what it should do.
|
||||
# pylint: disable=protected-access,too-many-public-methods
|
||||
import unittest
|
||||
import json
|
||||
from unittest.mock import patch
|
||||
|
||||
import requests
|
||||
|
||||
@@ -29,9 +28,7 @@ hass = None
|
||||
calls = []
|
||||
|
||||
|
||||
@patch('homeassistant.components.http.util.get_local_ip',
|
||||
return_value='127.0.0.1')
|
||||
def setUpModule(mock_get_local_ip): # pylint: disable=invalid-name
|
||||
def setUpModule(): # pylint: disable=invalid-name
|
||||
""" Initalize a Home Assistant server for testing this module. """
|
||||
global hass
|
||||
|
||||
@@ -105,6 +102,9 @@ def _req(data={}):
|
||||
class TestAlexa(unittest.TestCase):
|
||||
""" Test Alexa. """
|
||||
|
||||
def tearDown(self):
|
||||
hass.pool.block_till_done()
|
||||
|
||||
def test_launch_request(self):
|
||||
data = {
|
||||
'version': '1.0',
|
||||
|
||||
@@ -32,9 +32,7 @@ def _url(path=""):
|
||||
return HTTP_BASE_URL + path
|
||||
|
||||
|
||||
@patch('homeassistant.components.http.util.get_local_ip',
|
||||
return_value='127.0.0.1')
|
||||
def setUpModule(mock_get_local_ip): # pylint: disable=invalid-name
|
||||
def setUpModule(): # pylint: disable=invalid-name
|
||||
""" Initializes a Home Assistant server. """
|
||||
global hass
|
||||
|
||||
@@ -61,6 +59,9 @@ def tearDownModule(): # pylint: disable=invalid-name
|
||||
class TestAPI(unittest.TestCase):
|
||||
""" Test the API. """
|
||||
|
||||
def tearDown(self):
|
||||
hass.pool.block_till_done()
|
||||
|
||||
# TODO move back to http component and test with use_auth.
|
||||
def test_access_denied_without_password(self):
|
||||
req = requests.get(_url(const.URL_API))
|
||||
|
||||
@@ -7,7 +7,6 @@ Tests Home Assistant HTTP component does what it should do.
|
||||
# pylint: disable=protected-access,too-many-public-methods
|
||||
import re
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
import requests
|
||||
|
||||
@@ -30,9 +29,7 @@ def _url(path=""):
|
||||
return HTTP_BASE_URL + path
|
||||
|
||||
|
||||
@patch('homeassistant.components.http.util.get_local_ip',
|
||||
return_value='127.0.0.1')
|
||||
def setUpModule(mock_get_local_ip): # pylint: disable=invalid-name
|
||||
def setUpModule(): # pylint: disable=invalid-name
|
||||
""" Initalizes a Home Assistant server. """
|
||||
global hass
|
||||
|
||||
@@ -59,6 +56,9 @@ def tearDownModule(): # pylint: disable=invalid-name
|
||||
class TestFrontend(unittest.TestCase):
|
||||
""" Test the frontend. """
|
||||
|
||||
def tearDown(self):
|
||||
hass.pool.block_till_done()
|
||||
|
||||
def test_frontend_and_static(self):
|
||||
""" Tests if we can get the frontend. """
|
||||
req = requests.get(_url(""))
|
||||
|
||||
Reference in new issue
Block a user