mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Fix broken tests after API upgrade
This commit is contained in:
parent
94d9cbf76e
commit
98c2f1ea42
@ -259,7 +259,8 @@ class RequestHandler(SimpleHTTPRequestHandler):
|
||||
self.server.logger.exception(
|
||||
"Exception parsing JSON: {}".format(body_content))
|
||||
|
||||
self.send_response(HTTP_UNPROCESSABLE_ENTITY)
|
||||
self._message(
|
||||
"Error parsing JSON", HTTP_UNPROCESSABLE_ENTITY)
|
||||
return
|
||||
else:
|
||||
data.update({key: value[-1] for key, value in
|
||||
|
@ -313,14 +313,9 @@ def get_event_listeners(api, logger=None):
|
||||
return {}
|
||||
|
||||
|
||||
def fire_event(api, event_type, event_data=None, logger=None):
|
||||
def fire_event(api, event_type, data=None, logger=None):
|
||||
""" Fire an event at remote API. """
|
||||
|
||||
if event_data:
|
||||
data = {'event_data': event_data}
|
||||
else:
|
||||
data = None
|
||||
|
||||
try:
|
||||
req = api(METHOD_POST, URL_API_EVENTS_EVENT.format(event_type), data)
|
||||
|
||||
|
@ -89,16 +89,6 @@ class TestHTTP(unittest.TestCase):
|
||||
""" things to be run when tests are started. """
|
||||
cls.hass = ensure_homeassistant_started()
|
||||
|
||||
def test_debug_interface(self):
|
||||
""" Test if we can login by comparing not logged in screen to
|
||||
logged in screen. """
|
||||
|
||||
with_pw = requests.get(_url(), headers=HA_HEADERS)
|
||||
|
||||
without_pw = requests.get(_url())
|
||||
|
||||
self.assertNotEqual(without_pw.text, with_pw.text)
|
||||
|
||||
def test_api_password(self):
|
||||
""" Test if we get access denied if we omit or provide
|
||||
a wrong api password. """
|
||||
@ -210,7 +200,7 @@ class TestHTTP(unittest.TestCase):
|
||||
|
||||
requests.post(
|
||||
_url(remote.URL_API_EVENTS_EVENT.format("test_event_with_data")),
|
||||
data=json.dumps({"event_data": {"test": 1}}),
|
||||
data=json.dumps({"test": 1}),
|
||||
headers=HA_HEADERS)
|
||||
|
||||
# Allow the event to take place
|
||||
@ -231,7 +221,7 @@ class TestHTTP(unittest.TestCase):
|
||||
|
||||
req = requests.post(
|
||||
_url(remote.URL_API_EVENTS_EVENT.format("test_event")),
|
||||
data=json.dumps({"event_data": 'not an object'}),
|
||||
data=json.dumps('not an object'),
|
||||
headers=HA_HEADERS)
|
||||
|
||||
# It shouldn't but if it fires, allow the event to take place
|
||||
|
Loading…
x
Reference in New Issue
Block a user