Skip to content

Commit

Permalink
Add ignore decorator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
romis2012 committed Oct 2, 2024
1 parent 76e7529 commit aa53bf8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[tool.black]
line-length = 99
target-version = ['py37', 'py38', 'py39']
target-version = ['py38', 'py39', 'py310', 'py311', 'py312']
skip-string-normalization = true
experimental-string-processing = true
preview = true
verbose = true

[tool.pytest.ini_options]
Expand Down
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@ async def public_view(request):
async def secret_view(request):
return web.Response(text='Secret view')

@auth.ignore
async def ignored_view(request):
return web.Response(text='Ignored view')

app = web.Application(middlewares=[auth], loop=loop)
app.router.add_get('/', public_view)
app.router.add_get('/secret', secret_view)
app.router.add_get('/ignored', ignored_view)
return app

return factory
8 changes: 8 additions & 0 deletions tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ async def test_public_views_respond_200_when_auth_not_forced(aiohttp_client, app
assert resp.status == 200


async def test_ignored_views_respond_200_when_auth_forced(aiohttp_client, app_factory):
app = app_factory(auth_force=True)
client = await aiohttp_client(app)
resp = await client.get('/ignored')

assert resp.status == 200


async def test_protected_views_respond_401_when_auth_not_forced(aiohttp_client, app_factory):
app = app_factory(auth_force=False)
client = await aiohttp_client(app)
Expand Down

0 comments on commit aa53bf8

Please sign in to comment.