From 76dd0106be5d924f01ebade22880f31254cdc3bf Mon Sep 17 00:00:00 2001 From: Georg K Date: Thu, 28 Jul 2022 01:53:23 +0300 Subject: [PATCH] fix: update tests --- pyproject.toml | 5 ++++- tests/test_hook_to_custom_response.py | 1 + tests/test_oas/test_view.py | 2 +- tests/test_validation_body.py | 4 ++-- tests/test_validation_header.py | 6 +++--- tests/test_validation_query_string.py | 12 ++++++------ 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6228f7d..2b8ce62 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,4 +3,7 @@ requires = [ "setuptools >= 46.4.0", "wheel", ] -build-backend = "setuptools.build_meta" \ No newline at end of file +build-backend = "setuptools.build_meta" + +[tool.pytest.ini_options] +asyncio_mode = "auto" \ No newline at end of file diff --git a/tests/test_hook_to_custom_response.py b/tests/test_hook_to_custom_response.py index dd3b5b5..5c9b855 100644 --- a/tests/test_hook_to_custom_response.py +++ b/tests/test_hook_to_custom_response.py @@ -44,6 +44,7 @@ async def test_post_an_article_with_wrong_type_field_should_return_an_error_mess client = await aiohttp_client(app) resp = await client.post("/article", json={"name": "foo", "nb_page": "foo"}) + a = await resp.text() assert resp.status == 400 assert resp.content_type == "application/json" assert await resp.json() == [ diff --git a/tests/test_oas/test_view.py b/tests/test_oas/test_view.py index 83363ce..040b579 100644 --- a/tests/test_oas/test_view.py +++ b/tests/test_oas/test_view.py @@ -98,7 +98,7 @@ async def ensure_content_durability(client): @pytest.fixture -async def generated_oas(aiohttp_client, loop) -> web.Application: +async def generated_oas(aiohttp_client, event_loop) -> web.Application: app = web.Application() app.router.add_view("/pets", PetCollectionView) app.router.add_view("/pets/{id}", PetItemView) diff --git a/tests/test_validation_body.py b/tests/test_validation_body.py index 6a03316..5e5fcc9 100644 --- a/tests/test_validation_body.py +++ b/tests/test_validation_body.py @@ -68,7 +68,7 @@ async def test_post_an_article_with_wrong_type_field_should_return_an_error_mess ] -async def test_post_an_array_json_is_supported(aiohttp_client, loop): +async def test_post_an_array_json_is_supported(aiohttp_client, event_loop): app = web.Application() app.router.add_view("/article", ArticleView) @@ -120,7 +120,7 @@ async def test_post_an_object_json_to_a_list_model_should_return_an_error( ] -async def test_post_a_valid_article_should_return_the_parsed_type(aiohttp_client, loop): +async def test_post_a_valid_article_should_return_the_parsed_type(aiohttp_client, event_loop): app = web.Application() app.router.add_view("/article", ArticleView) diff --git a/tests/test_validation_header.py b/tests/test_validation_header.py index 95d317a..19843cc 100644 --- a/tests/test_validation_header.py +++ b/tests/test_validation_header.py @@ -130,7 +130,7 @@ async def test_get_article_with_valid_header_containing_hyphen_should_be_returne assert await resp.json() == {"signature": "2020-10-04T18:01:00"} -async def test_wrong_value_to_header_defined_with_str_enum(aiohttp_client, loop): +async def test_wrong_value_to_header_defined_with_str_enum(aiohttp_client, event_loop): app = web.Application() app.router.add_view("/coord", ViewWithEnumType) @@ -153,7 +153,7 @@ async def test_wrong_value_to_header_defined_with_str_enum(aiohttp_client, loop) assert resp.content_type == "application/json" -async def test_correct_value_to_header_defined_with_str_enum(aiohttp_client, loop): +async def test_correct_value_to_header_defined_with_str_enum(aiohttp_client, event_loop): app = web.Application() app.router.add_view("/coord", ViewWithEnumType) @@ -164,7 +164,7 @@ async def test_correct_value_to_header_defined_with_str_enum(aiohttp_client, loo assert resp.content_type == "application/json" -async def test_with_signature_group(aiohttp_client, loop): +async def test_with_signature_group(aiohttp_client, event_loop): app = web.Application() app.router.add_view("/article", ArticleViewWithSignatureGroup) diff --git a/tests/test_validation_query_string.py b/tests/test_validation_query_string.py index d6041f1..d50a56f 100644 --- a/tests/test_validation_query_string.py +++ b/tests/test_validation_query_string.py @@ -153,7 +153,7 @@ async def test_get_article_with_multiple_value_for_qs_age_must_failed( assert resp.content_type == "application/json" -async def test_get_article_with_multiple_value_of_tags(aiohttp_client, loop): +async def test_get_article_with_multiple_value_of_tags(aiohttp_client, event_loop): app = web.Application() app.router.add_view("/article", ArticleView) @@ -172,7 +172,7 @@ async def test_get_article_with_multiple_value_of_tags(aiohttp_client, loop): assert resp.content_type == "application/json" -async def test_get_article_with_one_value_of_tags_must_be_a_list(aiohttp_client, loop): +async def test_get_article_with_one_value_of_tags_must_be_a_list(aiohttp_client, event_loop): app = web.Application() app.router.add_view("/article", ArticleView) @@ -191,7 +191,7 @@ async def test_get_article_with_one_value_of_tags_must_be_a_list(aiohttp_client, assert resp.content_type == "application/json" -async def test_get_article_without_required_field_page(aiohttp_client, loop): +async def test_get_article_without_required_field_page(aiohttp_client, event_loop): app = web.Application() app.router.add_view("/article", ArticleViewWithPaginationGroup) @@ -210,7 +210,7 @@ async def test_get_article_without_required_field_page(aiohttp_client, loop): assert resp.content_type == "application/json" -async def test_get_article_with_page(aiohttp_client, loop): +async def test_get_article_with_page(aiohttp_client, event_loop): app = web.Application() app.router.add_view("/article", ArticleViewWithPaginationGroup) @@ -222,7 +222,7 @@ async def test_get_article_with_page(aiohttp_client, loop): assert resp.content_type == "application/json" -async def test_get_article_with_page_and_page_size(aiohttp_client, loop): +async def test_get_article_with_page_and_page_size(aiohttp_client, event_loop): app = web.Application() app.router.add_view("/article", ArticleViewWithPaginationGroup) @@ -236,7 +236,7 @@ async def test_get_article_with_page_and_page_size(aiohttp_client, loop): assert resp.content_type == "application/json" -async def test_get_article_with_page_and_wrong_page_size(aiohttp_client, loop): +async def test_get_article_with_page_and_wrong_page_size(aiohttp_client, event_loop): app = web.Application() app.router.add_view("/article", ArticleViewWithPaginationGroup)