Skip to content

Commit

Permalink
Adding aioredis tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-schilling committed May 4, 2021
1 parent 6cf5def commit 1823bd7
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions tests/integration/instruments/test_aioredis_py36plus.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,31 +144,37 @@ async def test_echo(tracked_request):
assert tracked_request.complete_spans[0].operation == "Redis/ECHO"


# def test_pipeline_echo(redis_conn, tracked_request):
# with redis_conn.pipeline() as p:
# p.echo("Hello World!")
# p.execute()
@async_test
async def test_pipeline_echo(tracked_request):
redis_conn = await get_redis_conn()
with redis_conn.pipeline() as p:
p.echo("Hello World!")
p.execute()

# assert len(tracked_request.complete_spans) == 1
# assert tracked_request.complete_spans[0].operation == "Redis/MULTI"
assert len(tracked_request.complete_spans) == 1
assert tracked_request.complete_spans[0].operation == "Redis/MULTI"


# def test_execute_command_missing_argument(redis_conn, tracked_request):
# # Redis instrumentation doesn't crash if op is missing.
# # This raises a TypeError (Python 3) or IndexError (Python 2)
# # when calling the original method.
# with pytest.raises(IndexError):
# redis_conn.execute_command()
@async_test
async def test_execute_command_missing_argument(tracked_request):
redis_conn = await get_redis_conn()
# Redis instrumentation doesn't crash if op is missing.
# This raises a TypeError (Python 3) or IndexError (Python 2)
# when calling the original method.
with pytest.raises(IndexError):
redis_conn.execute_command()

# assert len(tracked_request.complete_spans) == 1
# assert tracked_request.complete_spans[0].operation == "Redis/Unknown"
assert len(tracked_request.complete_spans) == 1
assert tracked_request.complete_spans[0].operation == "Redis/Unknown"


# def test_perform_request_bad_url(redis_conn, tracked_request):
# with pytest.raises(TypeError):
# # Redis instrumentation doesn't crash if op has the wrong type.
# # This raises a TypeError when calling the original method.
# redis_conn.execute_command(None)
@async_test
async def test_perform_request_bad_url(tracked_request):
redis_conn = await get_redis_conn()
with pytest.raises(TypeError):
# Redis instrumentation doesn't crash if op has the wrong type.
# This raises a TypeError when calling the original method.
redis_conn.execute_command(None)

# assert len(tracked_request.complete_spans) == 1
# assert tracked_request.complete_spans[0].operation == "Redis/None"
assert len(tracked_request.complete_spans) == 1
assert tracked_request.complete_spans[0].operation == "Redis/None"

0 comments on commit 1823bd7

Please sign in to comment.