MCPcopy Create free account
hub / github.com/requests-cache/requests-cache / test_request_refresh

Function test_request_refresh

tests/unit/test_session.py:1113–1128  ·  view source on GitHub ↗

The refresh option should send a conditional request, if possible

(mock_session)

Source from the content-addressed store, hash-verified

1111
1112
1113def test_request_refresh(mock_session):
1114 """The refresh option should send a conditional request, if possible"""
1115 response_1 = mock_session.get(MOCKED_URL_ETAG, expire_after=60)
1116 response_2 = mock_session.get(MOCKED_URL_ETAG)
1117 mock_session.mock_adapter.register_uri('GET', MOCKED_URL_ETAG, status_code=304)
1118
1119 response_3 = mock_session.get(MOCKED_URL_ETAG, refresh=True, expire_after=60)
1120 response_4 = mock_session.get(MOCKED_URL_ETAG)
1121
1122 assert response_1.from_cache is False
1123 assert response_2.from_cache is True
1124 assert response_3.from_cache is True and response_3.revalidated is True
1125 assert response_4.from_cache is True and response_4.revalidated is False
1126
1127 # Expect expiration to get reset after revalidation
1128 assert response_2.expires < response_4.expires
1129
1130
1131def test_request_refresh__no_validator(mock_session):

Callers

nothing calls this directly

Calls 1

getMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…