Skip to content

Commit

Permalink
test: cover wrong 'expires' usage
Browse files Browse the repository at this point in the history
  • Loading branch information
alessio-locatelli committed Oct 29, 2024
1 parent 2ca0004 commit ee27a81
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/unit/test_response.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from datetime import timedelta
from datetime import datetime, timedelta, timezone
from unittest import mock

import pytest
Expand All @@ -9,7 +9,7 @@
from yarl import URL

from aiohttp_client_cache.cache_control import utcnow
from aiohttp_client_cache.response import CachedResponse, RequestInfo
from aiohttp_client_cache.response import CachedResponse, RequestInfo, UnsupportedExpiresError


async def get_test_response(client_factory, url='/', **kwargs):
Expand Down Expand Up @@ -78,8 +78,10 @@ async def test_is_expired(mock_utcnow, aiohttp_client):


async def test_is_expired__invalid(aiohttp_client):
response = await get_test_response(aiohttp_client, expires='asdf')
assert response.is_expired is True
with pytest.raises(AttributeError, match="'str' object has no attribute 'tzinfo'"):
await get_test_response(aiohttp_client, expires='asdf')
with pytest.raises(UnsupportedExpiresError, match='Expected a naive datetime'):
await get_test_response(aiohttp_client, expires=datetime.now(timezone.utc))


async def test_content_disposition(aiohttp_client):
Expand Down

0 comments on commit ee27a81

Please sign in to comment.