20
20
validate_transaction_errors ,
21
21
validate_transaction_metrics ,
22
22
validate_tt_segment_params ,
23
+ override_generic_settings
23
24
)
24
25
from testing_support .mock_external_http_server import (
25
26
MockExternalHTTPHResponseHeadersServer ,
31
32
32
33
from newrelic .api .background_task import background_task
33
34
from newrelic .api .transaction import current_transaction
35
+ from newrelic .api .time_trace import current_trace
36
+ from newrelic .core .config import global_settings
34
37
35
38
ENCODING_KEY = "1234567890123456789012345678901234567890"
36
39
SCOPED_METRICS = []
@@ -438,3 +441,37 @@ def _test():
438
441
# Don't crash if response isn't specified
439
442
client .event_hooks = {"request" : [empty_hook ]}
440
443
make_request (client , exc_expected = False )
444
+
445
+
446
+ @override_generic_settings (global_settings (), {
447
+ 'enabled' : False ,
448
+ })
449
+ def test_sync_nr_disabled (httpx , server ):
450
+ global CAT_RESPONSE_CODE
451
+ CAT_RESPONSE_CODE = 200
452
+
453
+ with httpx .Client () as client :
454
+ trace = current_trace ()
455
+ response = client .get ("http://localhost:%s" % server .port )
456
+
457
+ assert response .status_code == 200
458
+ assert trace is None
459
+
460
+
461
+ @override_generic_settings (global_settings (), {
462
+ 'enabled' : False ,
463
+ })
464
+ def test_async_nr_disabled (httpx , server , loop ):
465
+ global CAT_RESPONSE_CODE
466
+ CAT_RESPONSE_CODE = 200
467
+
468
+ async def _test ():
469
+ async with httpx .AsyncClient () as client :
470
+ response = await client .get ("http://localhost:%s" % server .port )
471
+
472
+ return response
473
+
474
+ trace = current_trace ()
475
+ response = loop .run_until_complete (_test ())
476
+ assert response .status_code == 200
477
+ assert trace is None
0 commit comments