diff options
author | Simon Leiner <simon@leiner.me> | 2023-03-14 18:23:40 +0100 |
---|---|---|
committer | Jordan Cook <jordan.cook.git@proton.me> | 2023-03-24 18:50:18 -0500 |
commit | 94331ef108ad160faddb48cfc6a259c8a2497c99 (patch) | |
tree | ff52bb7d9d7536e2ba139806b3532ed3401d56f0 /tests | |
parent | 812301ab85a3b54387dcebd7d65407ace2589b9f (diff) | |
download | requests-cache-94331ef108ad160faddb48cfc6a259c8a2497c99.tar.gz |
Allow regexes for URL expiration patterns
This allows for more fine-grained control over URL patterns than
globbing in the rare cases where that is needed.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/policy/test_expiration.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/unit/policy/test_expiration.py b/tests/unit/policy/test_expiration.py index 54eb2a2..0a453db 100644 --- a/tests/unit/policy/test_expiration.py +++ b/tests/unit/policy/test_expiration.py @@ -1,3 +1,4 @@ +import re from datetime import datetime, timedelta, timezone from unittest.mock import patch @@ -56,6 +57,8 @@ def test_get_expiration_datetime__httpdate(): ('http://site_2.com/resource_1/index.html', 60 * 60 * 2), ('http://site_2.com/resource_2/', 60 * 60 * 24), ('http://site_2.com/static/', -1), + ('http://site_2.com/api/resource/123', 60 * 60 * 24 * 7), + ('http://site_2.com/api/resource/xyz', None), ('http://site_2.com/static/img.jpg', -1), ('site_2.com', None), ('some_other_site.com', None), @@ -67,6 +70,7 @@ def test_get_url_expiration(url, expected_expire_after, mock_session): '*.site_1.com': 60 * 60, 'site_2.com/resource_1': 60 * 60 * 2, 'site_2.com/resource_2': 60 * 60 * 24, + re.compile(r'site_2\.com/api/resource/\d+'): 60 * 60 * 24 * 7, 'site_2.com/static': -1, } assert get_url_expiration(url, urls_expire_after) == expected_expire_after |