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_int():
""" test util.parse_int works correctly """
assert util.parse_int('194', 5) == 194
assert util.parse_int(9811, -1) == 9811
def test_parse_int_default():
""" test util.parse_int will return default for invalid input"""
assert util.parse_int('1a23', 3) == 3
assert util.parse_int('{}', -1) == -1
request) or defaults.UNKNOWN
request_start = context.get(
'request_started_at', request) or defaults.UNIX_EPOCH
self.request_received_at = util.iso_time_format(request_start)
# response related
response_sent_at = context.get(
'response_sent_at', request) or defaults.UNIX_EPOCH
self.response_sent_at = util.iso_time_format(response_sent_at)
self.response_time_ms = util.time_delta_ms(
request_start, response_sent_at)
self.response_status = util.parse_int(
response_reader.get_status_code(response), defaults.STATUS)
self.response_size_b = util.parse_int(
response_reader.get_response_size(response), defaults.RESPONSE_SIZE_B)
self.response_content_type = response_reader.get_content_type(response)
self._hide_sensitive_fields()