Skip to content

Commit

Permalink
Add regression tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
umaannamalai authored and a-feld committed Jan 21, 2021
1 parent 20f1a72 commit f4daa87
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/external_httpx/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
validate_transaction_errors,
validate_transaction_metrics,
validate_tt_segment_params,
override_generic_settings
)
from testing_support.mock_external_http_server import (
MockExternalHTTPHResponseHeadersServer,
Expand All @@ -31,6 +32,8 @@

from newrelic.api.background_task import background_task
from newrelic.api.transaction import current_transaction
from newrelic.api.time_trace import current_trace
from newrelic.core.config import global_settings

ENCODING_KEY = "1234567890123456789012345678901234567890"
SCOPED_METRICS = []
Expand Down Expand Up @@ -438,3 +441,37 @@ def _test():
# Don't crash if response isn't specified
client.event_hooks = {"request": [empty_hook]}
make_request(client, exc_expected=False)


@override_generic_settings(global_settings(), {
'enabled': False,
})
def test_sync_nr_disabled(httpx, server):
global CAT_RESPONSE_CODE
CAT_RESPONSE_CODE = 200

with httpx.Client() as client:
trace = current_trace()
response = client.get("http://localhost:%s" % server.port)

assert response.status_code == 200
assert trace is None


@override_generic_settings(global_settings(), {
'enabled': False,
})
def test_async_nr_disabled(httpx, server, loop):
global CAT_RESPONSE_CODE
CAT_RESPONSE_CODE = 200

async def _test():
async with httpx.AsyncClient() as client:
response = await client.get("http://localhost:%s" % server.port)

return response

trace = current_trace()
response = loop.run_until_complete(_test())
assert response.status_code == 200
assert trace is None

0 comments on commit f4daa87

Please sign in to comment.