def test_api_get_error_log(self):
Test the return of the error log.
test_content = "Test String°"
with tempfile.NamedTemporaryFile() as log:
log.write(test_content.encode("utf-8"))
log.flush()
with patch.object(hass.config, "path", return_value=log.name):
After Change
// support the buffer API"), but wsgiserver requires byte types// ("WSGI Applications must yield bytes"). So just mock our own// read method.m_open = Mock(return_value=Mock(
read=Mock(side_effect=[test_string]))
)with patch("homeassistant.components.http.open", m_open, create=True):
req = requests.get(_url(const.URL_API_ERROR_LOG),
headers=HA_HEADERS)
self.assertEqual(test_string, req.text.encode("UTF-8"))