import pytest

from aiohttp_apiset.routes import SwaggerRouter


@pytest.mark.asyncio
async def test_setup(app):
    SwaggerRouter(
        'data/root.yaml',
        search_dirs=['tests']
    ).setup(app)


@pytest.mark.asyncio
async def test_routes(swagger_router: SwaggerRouter):
    paths = [url for m, url, *args in swagger_router.routes]
    assert '/api/1/file/image' in paths


@pytest.mark.asyncio
async def test_route_include(swagger_router: SwaggerRouter):
    paths = [url for m, url, *args in swagger_router.routes]
    assert '/api/1/include2/inc/image' in paths


def test_route_swagger_include(swagger_router: SwaggerRouter):
    paths = swagger_router._swagger_data['paths']
    assert '/include/image' in paths


def test_route_swagger_view(swagger_router: SwaggerRouter):
    paths = swagger_router._swagger_data['paths']
    assert '/file/image' in paths


@pytest.mark.asyncio
async def test_handler(swagger_router: SwaggerRouter):
    paths = [(m, url) for m, url, *args in swagger_router.routes]
    assert ('GET', '/api/1/include/image') in paths

@@ -293,36 +293,43 @@
 = %5Burl for m
+ethod
 , url, 
-*args
+handler
  in swagger_
@@ -333,32 +333,41 @@
 er_router.routes
+.values()
 %5D%0A    assert '/a
@@ -494,36 +494,43 @@
 = %5Burl for m
+ethod
 , url, 
-*args
+handler
  in swagger_
@@ -534,32 +534,41 @@
 er_router.routes
+.values()
 %5D%0A    assert '/a
@@ -995,33 +995,30 @@
 = %5B(
-m, url) for m, url, *args
+r.method, r.url) for r
  in 
@@ -1038,16 +1038,25 @@
 r.routes
+.values()
 %5D%0A    as

test refactor