def test_bad_json_decode(hass, aioclient_mock): """Test decoding invalid json result.""" aioclient_mock.get( "https://api.teksavvy.com/" "web/Usage/UsageSummaryRecords?" "$filter=IsCurrent%20eq%20true", text='this is not json') tsd = TekSavvyData(hass.loop, async_get_clientsession(hass), 'notakey', 400) result = yield from tsd.async_update() assert result is False
def test_bad_return_code(hass, aioclient_mock): """Test handling a return code that isn't HTTP OK.""" aioclient_mock.get( "https://api.teksavvy.com/" "web/Usage/UsageSummaryRecords?" "$filter=IsCurrent%20eq%20true", status=404) tsd = TekSavvyData(hass.loop, async_get_clientsession(hass), 'notakey', 400) result = yield from tsd.async_update() assert result is False