@@ -275,8 +275,8 @@ def _test_patched_api_call_with_credentials(self):
275275 args = ("operation_name" ,)
276276 kwargs = {}
277277 initial_attributes = {}
278- mock_extension = self . _get_mock_extension ()
279- mock_call_context = self . _get_mock_call_context ()
278+ mock_extension = _get_mock_extension ()
279+ mock_call_context = _get_mock_call_context ()
280280
281281 def mock_start_span (* args , ** kwargs ):
282282 attributes = kwargs .get ("attributes" , {})
@@ -326,8 +326,8 @@ def _test_patched_api_call_with_no_credentials(self):
326326 args = ("operation_name" ,)
327327 kwargs = {}
328328 initial_attributes = {}
329- mock_extension = self . _get_mock_extension ()
330- mock_call_context = self . _get_mock_call_context ()
329+ mock_extension = _get_mock_extension ()
330+ mock_call_context = _get_mock_call_context ()
331331
332332 def mock_start_span (* args , ** kwargs ):
333333 attributes = kwargs .get ("attributes" , {})
@@ -372,8 +372,8 @@ def _test_patched_api_call_with_no_access_key(self):
372372 args = ("operation_name" ,)
373373 kwargs = {}
374374 initial_attributes = {}
375- mock_extension = self . _get_mock_extension ()
376- mock_call_context = self . _get_mock_call_context ()
375+ mock_extension = _get_mock_extension ()
376+ mock_call_context = _get_mock_call_context ()
377377
378378 def mock_start_span (* args , ** kwargs ):
379379 attributes = kwargs .get ("attributes" , {})
@@ -411,34 +411,6 @@ def mock_start_span(*args, **kwargs):
411411 self .assertTrue ("aws.region" in initial_attributes )
412412 instrumentor .uninstrument ()
413413
414- def _get_mock_extension (self ):
415- # Mock extension
416- mock_extension = MagicMock ()
417- mock_extension .should_trace_service_call .return_value = True
418- mock_extension .tracer_schema_version .return_value = "1.0.0"
419- mock_extension .event_logger_schema_version .return_value = "1.0.0"
420- mock_extension .meter_schema_version .return_value = "1.0.0"
421- mock_extension .should_end_span_on_exit .return_value = True
422- mock_extension .extract_attributes = lambda x : None
423- mock_extension .before_service_call = lambda * args , ** kwargs : None
424- mock_extension .after_service_call = lambda * args , ** kwargs : None
425- mock_extension .on_success = lambda * args , ** kwargs : None
426- mock_extension .on_error = lambda * args , ** kwargs : None
427- mock_extension .setup_metrics = lambda meter , metrics : None
428- return mock_extension
429-
430- def _get_mock_call_context (self ):
431- # Mock call context
432- mock_call_context = MagicMock ()
433- mock_call_context .service = "test-service"
434- mock_call_context .service_id = "test-service"
435- mock_call_context .operation = "test-operation"
436- mock_call_context .region = "us-west-2"
437- mock_call_context .span_name = "test-span"
438- mock_call_context .span_kind = "CLIENT"
439- mock_call_context .endpoint_url = "https://www.awsmocktest.com"
440- return mock_call_context
441-
442414 def _test_patched_gevent_os_ssl_instrumentation (self ):
443415 # Only ssl and os module should have been patched since the environment variable was set to 'os, ssl'
444416 self .assertTrue (gevent .monkey .is_module_patched ("ssl" ), "gevent ssl module has not been patched" )
@@ -711,3 +683,33 @@ def set_side_effect(set_key, set_value):
711683 extension .on_success (span_mock , result , mock_instrumentor_context )
712684
713685 return span_attributes
686+
687+
688+ def _get_mock_extension ():
689+ # Mock extension
690+ mock_extension = MagicMock ()
691+ mock_extension .should_trace_service_call .return_value = True
692+ mock_extension .tracer_schema_version .return_value = "1.0.0"
693+ mock_extension .event_logger_schema_version .return_value = "1.0.0"
694+ mock_extension .meter_schema_version .return_value = "1.0.0"
695+ mock_extension .should_end_span_on_exit .return_value = True
696+ mock_extension .extract_attributes = lambda x : None
697+ mock_extension .before_service_call = lambda * args , ** kwargs : None
698+ mock_extension .after_service_call = lambda * args , ** kwargs : None
699+ mock_extension .on_success = lambda * args , ** kwargs : None
700+ mock_extension .on_error = lambda * args , ** kwargs : None
701+ mock_extension .setup_metrics = lambda meter , metrics : None
702+ return mock_extension
703+
704+
705+ def _get_mock_call_context ():
706+ # Mock call context
707+ mock_call_context = MagicMock ()
708+ mock_call_context .service = "test-service"
709+ mock_call_context .service_id = "test-service"
710+ mock_call_context .operation = "test-operation"
711+ mock_call_context .region = "us-west-2"
712+ mock_call_context .span_name = "test-span"
713+ mock_call_context .span_kind = "CLIENT"
714+ mock_call_context .endpoint_url = "https://www.awsmocktest.com"
715+ return mock_call_context
0 commit comments