Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_parse_JSON_fails_when_JSON_data_is_None(self):
self.assertRaises(ParseResponseError, ObservationListParser.parse_JSON,
self.__instance, None)
def test_parse_JSON_fails_with_malformed_JSON_data(self):
self.assertRaises(ParseResponseError, SO2IndexParser.parse_JSON,
self.__instance, SO2INDEX_MALFORMED_JSON)
def test_parse_JSON_fails_with_malformed_JSON_data(self):
self.assertRaises(ParseResponseError, SO2IndexParser.parse_JSON,
self.__instance, SO2INDEX_MALFORMED_JSON)
def test_parse_JSON_fails_with_none_input(self):
instance = AggregatedMeasurementParser()
with self.assertRaises(parse_response_error.ParseResponseError):
instance.parse_JSON(None)
def test_get_json_parse_error(self):
def monkey_patched_get(uri, params=None, headers=None, timeout=None,
verify=False):
return MockResponse(200, 123846237647236)
requests.get = monkey_patched_get
self.assertRaises(parse_response_error.ParseResponseError,
HttpClient().get_json,
'http://anyurl.com',
params=dict(a=1, b=2))
requests.get = self.requests_original_get
def test_next_year(self):
result = timeutils.next_year()
expected = datetime.now() + timedelta(days=365)
self.assertAlmostEqual(
float(timeformatutils.to_UNIXtime(expected)),
float(timeformatutils.to_UNIXtime(result)))
def test_last_week(self):
result = timeutils.last_week()
expected = datetime.now() + timedelta(days=-7)
self.assertAlmostEqual(
float(timeformatutils.to_UNIXtime(expected)),
float(timeformatutils.to_UNIXtime(result)))
def test_last_week(self):
result = timeutils.last_week()
expected = datetime.now() + timedelta(days=-7)
self.assertAlmostEqual(
float(timeformatutils.to_UNIXtime(expected)),
float(timeformatutils.to_UNIXtime(result)))
def test_next_hour(self):
result = timeutils.next_hour()
expected = datetime.now() + timedelta(hours=1)
self.assertAlmostEqual(
float(timeformatutils.to_UNIXtime(expected)),
float(timeformatutils.to_UNIXtime(result)))
def test_next_year(self):
result = timeutils.next_year()
expected = datetime.now() + timedelta(days=365)
self.assertAlmostEqual(
float(timeformatutils.to_UNIXtime(expected)),
float(timeformatutils.to_UNIXtime(result)))