Skip to content

Commit

Permalink
removed unused arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
davitacols committed Dec 24, 2023
1 parent 3e7989e commit 3c7bd10
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions tests/test_compatibility.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
"""
Tests for asgiref compatibility functions.
"""

import pytest
from asgiref.compatibility import double_to_single_callable, is_double_callable
from asgiref.testing import ApplicationCommunicator


def double_application_function(scope):
"""A nested function-based double-callable application."""
async def double_application_function(scope):
"""
A nested function-based double-callable application.
"""
async def inner(receive, send):
message = await receive()
await send({"scope": scope["value"], "message": message["value"]})
return inner


class DoubleApplicationClass:
"""A classic class-based double-callable application."""
"""
A classic class-based double-callable application.
"""
def __init__(self, scope):
pass

Expand All @@ -21,7 +29,9 @@ async def __call__(self, receive, send):


class DoubleApplicationClassNestedFunction:
"""A function closure inside a class."""
"""
A function closure inside a class.
"""
def __init__(self):
pass

Expand All @@ -32,22 +42,28 @@ async def inner(receive, send):


async def single_application_function(scope, receive, send):
"""A single-function single-callable application."""
"""
A single-function single-callable application.
"""
pass


class SingleApplicationClass:
"""A single-callable class."""
"""
A single-callable class.
"""
def __init__(self):
pass

async def __call__(self, scope, receive, send):
async def __call__(self, receive, send):
pass


@pytest.mark.asyncio
async def test_is_double_callable():
"""Test the behavior of is_double_callable function."""
"""
Test the behavior of is_double_callable function.
"""
assert is_double_callable(double_application_function)
assert is_double_callable(DoubleApplicationClass)
assert is_double_callable(DoubleApplicationClassNestedFunction())
Expand All @@ -57,14 +73,18 @@ async def test_is_double_callable():

@pytest.mark.asyncio
async def test_double_to_single_callable():
"""Test the behavior of double_to_single_callable function."""
"""
Test the behavior of double_to_single_callable function.
"""
new_app = double_to_single_callable(double_application_function)
assert not is_double_callable(new_app)


@pytest.mark.asyncio
async def test_double_to_single_communicator():
"""Test the behavior of the new application using ApplicationCommunicator."""
"""
Test the behavior of the new application using ApplicationCommunicator.
"""
new_app = double_to_single_callable(double_application_function)
instance = ApplicationCommunicator(new_app, {"value": "woohoo"})
await instance.send_input({"value": 42})
Expand Down

0 comments on commit 3c7bd10

Please sign in to comment.