def test_serialize_api_call_event_with_attempts(self): event = APICallEvent(service=self.service, operation=self.operation, timestamp=1000) event.new_api_call_attempt(2000) serialized_event_dict = self.get_serialized_event_dict(event) self.assertEqual(serialized_event_dict['AttemptCount'], 1)
def test_serialize_api_call_event_http_status_code(self): event = APICallEvent( service=self.service, operation=self.operation, timestamp=1000) attempt = event.new_api_call_attempt(2000) attempt.http_status_code = 200 serialized_event_dict = self.get_serialized_event_dict(event) self.assertEqual(serialized_event_dict['FinalHttpStatusCode'], 200)
def test_serialize_api_call_event_user_agent(self): event = APICallEvent( service=self.service, operation=self.operation, timestamp=1000) attempt = event.new_api_call_attempt(2000) attempt.request_headers = {'User-Agent': self.user_agent} serialized_event_dict = self.get_serialized_event_dict(event) self.assertEqual(serialized_event_dict['UserAgent'], self.user_agent)
def test_serialize_api_call_event_http_status_code(self): event = APICallEvent(service=self.service, operation=self.operation, timestamp=1000) attempt = event.new_api_call_attempt(2000) attempt.http_status_code = 200 serialized_event_dict = self.get_serialized_event_dict(event) self.assertEqual(serialized_event_dict['FinalHttpStatusCode'], 200)
def test_serialize_api_call_event_user_agent(self): event = APICallEvent(service=self.service, operation=self.operation, timestamp=1000) attempt = event.new_api_call_attempt(2000) attempt.request_headers = {'User-Agent': self.user_agent} serialized_event_dict = self.get_serialized_event_dict(event) self.assertEqual(serialized_event_dict['UserAgent'], self.user_agent)
def test_serialize_api_call_event_wire_exception(self): event = APICallEvent(service=self.service, operation=self.operation, timestamp=1000) attempt = event.new_api_call_attempt(2000) attempt.wire_exception = Exception('Error on the wire') serialized_event_dict = self.get_serialized_event_dict(event) self.assertEqual(serialized_event_dict['FinalSdkException'], 'Exception') self.assertEqual(serialized_event_dict['FinalSdkExceptionMessage'], 'Error on the wire')
def test_serialize_api_call_event_wire_exception(self): event = APICallEvent( service=self.service, operation=self.operation, timestamp=1000) attempt = event.new_api_call_attempt(2000) attempt.wire_exception = Exception('Error on the wire') serialized_event_dict = self.get_serialized_event_dict(event) self.assertEqual( serialized_event_dict['FinalSdkException'], 'Exception') self.assertEqual( serialized_event_dict['FinalSdkExceptionMessage'], 'Error on the wire' )
def test_new_api_call_attempt_event(self): event = APICallEvent( service='MyService', operation='MyOperation', timestamp=1000, latency=2000, attempts=[] ) attempt_event = event.new_api_call_attempt(timestamp=2000) self.assertEqual( attempt_event, APICallAttemptEvent( service='MyService', operation='MyOperation', timestamp=2000 ) ) self.assertEqual(event.attempts, [attempt_event])
def test_new_api_call_attempt_event(self): event = APICallEvent(service='MyService', operation='MyOperation', timestamp=1000, latency=2000, attempts=[]) attempt_event = event.new_api_call_attempt(timestamp=2000) self.assertEqual( attempt_event, APICallAttemptEvent(service='MyService', operation='MyOperation', timestamp=2000)) self.assertEqual(event.attempts, [attempt_event])
def test_serialize_api_call_event_parsed_error(self): event = APICallEvent(service=self.service, operation=self.operation, timestamp=1000) attempt = event.new_api_call_attempt(2000) attempt.parsed_error = { 'Code': 'MyErrorCode', 'Message': 'My error message' } serialized_event_dict = self.get_serialized_event_dict(event) self.assertEqual(serialized_event_dict['FinalAwsException'], 'MyErrorCode') self.assertEqual(serialized_event_dict['FinalAwsExceptionMessage'], 'My error message')
def test_serialize_api_call_event_region(self): event = APICallEvent(service=self.service, operation=self.operation, timestamp=1000) attempt = event.new_api_call_attempt(2000) auth_value = ( 'AWS4-HMAC-SHA256 ' 'Credential=myaccesskey/20180523/my-region-1/ec2/aws4_request,' 'SignedHeaders=content-type;host;x-amz-date, ' 'Signature=somesignature') self.request_headers['Authorization'] = auth_value attempt.request_headers = self.request_headers serialized_event_dict = self.get_serialized_event_dict(event) self.assertEqual(serialized_event_dict['Region'], 'my-region-1')
def test_serialize_api_call_event_parsed_error(self): event = APICallEvent( service=self.service, operation=self.operation, timestamp=1000) attempt = event.new_api_call_attempt(2000) attempt.parsed_error = { 'Code': 'MyErrorCode', 'Message': 'My error message' } serialized_event_dict = self.get_serialized_event_dict(event) self.assertEqual( serialized_event_dict['FinalAwsException'], 'MyErrorCode') self.assertEqual( serialized_event_dict['FinalAwsExceptionMessage'], 'My error message' )
def test_serialize_api_call_event_region(self): event = APICallEvent( service=self.service, operation=self.operation, timestamp=1000) attempt = event.new_api_call_attempt(2000) auth_value = ( 'AWS4-HMAC-SHA256 ' 'Credential=myaccesskey/20180523/my-region-1/ec2/aws4_request,' 'SignedHeaders=content-type;host;x-amz-date, ' 'Signature=somesignature' ) self.request_headers['Authorization'] = auth_value attempt.request_headers = self.request_headers serialized_event_dict = self.get_serialized_event_dict(event) self.assertEqual(serialized_event_dict['Region'], 'my-region-1')
def test_serialize_api_call_event_with_attempts(self): event = APICallEvent( service=self.service, operation=self.operation, timestamp=1000) event.new_api_call_attempt(2000) serialized_event_dict = self.get_serialized_event_dict(event) self.assertEqual(serialized_event_dict['AttemptCount'], 1)