Skip to content

Commit bedca5b

Browse files
committed
Document test
1 parent 07112bd commit bedca5b

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

tests/test_exceptions.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@
44

55
import io
66
import random
7-
from datetime import datetime, timedelta
87

98
import pytest
10-
import pytz
9+
from freezegun import freeze_time
1110
from mock_vws import MockVWS
1211
from mock_vws.database import VuforiaDatabase
1312
from mock_vws.states import States
1413
from PIL import Image
1514
from requests import codes
1615

17-
from freezegun import freeze_time
1816
from vws import VWS, CloudRecoService
1917
from vws.exceptions import (
2018
AuthenticationFailure,
@@ -224,10 +222,21 @@ def test_metadata_too_large(
224222

225223

226224
def test_request_time_too_skewed(vws_client: VWS) -> None:
227-
vws_max_time_skew = timedelta(minutes=5)
228-
leeway = timedelta(seconds=10)
225+
"""
226+
A ``RequestTimeTooSkewed`` exception is raised when the request time is
227+
more than five minutes different from the server time.
228+
"""
229+
vws_max_time_skew = 60 * 5
230+
leeway = 10
229231
time_difference_from_now = vws_max_time_skew + leeway
230-
with freeze_time(auto_tick_seconds=time_difference_from_now.seconds):
232+
233+
# We use a custom tick because we expect the following:
234+
#
235+
# * At least one time check when creating the request
236+
# * At least one time check when processing the request
237+
#
238+
# >= 1 ticks are acceptable.
239+
with freeze_time(auto_tick_seconds=time_difference_from_now):
231240
with pytest.raises(RequestTimeTooSkewed):
232241
vws_client.get_target_record(target_id='a')
233242

0 commit comments

Comments
 (0)