Tests: Mock get_local_ip by default too
This commit is contained in:
parent
09ab3e95c0
commit
8d366a7367
6 changed files with 9 additions and 22 deletions
|
@ -6,6 +6,7 @@ Tests initialization.
|
|||
"""
|
||||
import betamax
|
||||
|
||||
from homeassistant import util
|
||||
from homeassistant.util import location
|
||||
|
||||
with betamax.Betamax.configure() as config:
|
||||
|
@ -28,3 +29,4 @@ location.detect_location_info = lambda: location.LocationInfo(
|
|||
)
|
||||
|
||||
location.elevation = lambda latitude, longitude: 0
|
||||
util.get_local_ip = lambda: '127.0.0.1'
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ Tests Home Assistant remote methods and classes.
|
|||
"""
|
||||
# pylint: disable=protected-access,too-many-public-methods
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
import homeassistant.core as ha
|
||||
import homeassistant.bootstrap as bootstrap
|
||||
|
@ -24,7 +23,8 @@ HTTP_BASE_URL = "http://127.0.0.1:{}".format(MASTER_PORT)
|
|||
|
||||
HA_HEADERS = {HTTP_HEADER_HA_AUTH: API_PASSWORD}
|
||||
|
||||
hass, slave, master_api, broken_api = None, None, None, None
|
||||
broken_api = remote.API('127.0.0.1', BROKEN_PORT)
|
||||
hass, slave, master_api = None, None, None
|
||||
|
||||
|
||||
def _url(path=""):
|
||||
|
@ -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
|
||||
""" Initalizes a Home Assistant server and Slave instance. """
|
||||
global hass, slave, master_api, broken_api
|
||||
|
||||
|
@ -63,9 +61,6 @@ def setUpModule(mock_get_local_ip): # pylint: disable=invalid-name
|
|||
|
||||
slave.start()
|
||||
|
||||
# Setup API pointing at nothing
|
||||
broken_api = remote.API("127.0.0.1", "", BROKEN_PORT)
|
||||
|
||||
|
||||
def tearDownModule(): # pylint: disable=invalid-name
|
||||
""" Stops the Home Assistant server and slave. """
|
||||
|
|
Loading…
Add table
Reference in a new issue