Skip to content

Commit da4aed3

Browse files
author
bjmb
committed
Added some documentation for the timestamp tests
1 parent b6f4a9b commit da4aed3

File tree

1 file changed

+72
-4
lines changed

1 file changed

+72
-4
lines changed

tests/unit/test_timestamps.py

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,13 @@ class TestTimestampGeneratorOutput(unittest.TestCase, _TimestampTestMixin):
6161

6262
def test_timestamps_during_and_after_same_system_time(self):
6363
"""
64-
Timestamps should increase monotonically over repeated system time.
65-
6664
Test that MonotonicTimestampGenerator's output increases by 1 when the
6765
underlying system time is the same, then returns to normal when the
6866
system time increases again.
67+
68+
@since 3.8.0
69+
@expected_result Timestamps should increase monotonically over repeated system time.
70+
@test_category timing
6971
"""
7072
self._call_and_check_results(
7173
system_time_expected_stamp_pairs=(
@@ -77,11 +79,13 @@ def test_timestamps_during_and_after_same_system_time(self):
7779

7880
def test_timestamps_during_and_after_backwards_system_time(self):
7981
"""
80-
Timestamps should increase monotonically over system time going backwards.
81-
8282
Test that MonotonicTimestampGenerator's output increases by 1 when the
8383
underlying system time goes backward, then returns to normal when the
8484
system time increases again.
85+
86+
@since 3.8.0
87+
@expected_result Timestamps should increase monotonically over system time going backwards.
88+
@test_category timing
8589
"""
8690
self._call_and_check_results(
8791
system_time_expected_stamp_pairs=(
@@ -110,6 +114,15 @@ def assertLastCallArgRegex(self, call, pattern):
110114
)
111115

112116
def test_basic_log_content(self):
117+
"""
118+
Tests there are logs
119+
120+
@since 3.8.0
121+
@jira_ticket PYTHON-676
122+
@expected_result logs
123+
124+
@test_category timing
125+
"""
113126
tsg = timestamps.MonotonicTimestampGenerator()
114127
#The units of _last_warn is seconds
115128
tsg._last_warn = 12
@@ -125,13 +138,31 @@ def test_basic_log_content(self):
125138
)
126139

127140
def test_disable_logging(self):
141+
"""
142+
Tests there are no logs when there is a clock skew if logging is disabled
143+
144+
@since 3.8.0
145+
@jira_ticket PYTHON-676
146+
@expected_result no logs
147+
148+
@test_category timing
149+
"""
128150
no_warn_tsg = timestamps.MonotonicTimestampGenerator(warn_on_drift=False)
129151

130152
no_warn_tsg.last = 100
131153
no_warn_tsg._next_timestamp(99, no_warn_tsg.last)
132154
self.assertEqual(len(self.patched_timestamp_log.warn.call_args_list), 0)
133155

134156
def test_warning_threshold_respected_no_logging(self):
157+
"""
158+
Tests there are no logs if `warning_threshold` is not exceeded
159+
160+
@since 3.8.0
161+
@jira_ticket PYTHON-676
162+
@expected_result no logs
163+
164+
@test_category timing
165+
"""
135166
tsg = timestamps.MonotonicTimestampGenerator(
136167
warning_threshold=2e-6,
137168
)
@@ -140,6 +171,15 @@ def test_warning_threshold_respected_no_logging(self):
140171
self.assertEqual(len(self.patched_timestamp_log.warn.call_args_list), 0)
141172

142173
def test_warning_threshold_respected_logs(self):
174+
"""
175+
Tests there are logs if `warning_threshold` is exceeded
176+
177+
@since 3.8.0
178+
@jira_ticket PYTHON-676
179+
@expected_result logs
180+
181+
@test_category timing
182+
"""
143183
tsg = timestamps.MonotonicTimestampGenerator(
144184
warning_threshold=1e-6
145185
)
@@ -148,6 +188,15 @@ def test_warning_threshold_respected_logs(self):
148188
self.assertEqual(len(self.patched_timestamp_log.warn.call_args_list), 1)
149189

150190
def test_warning_interval_respected_no_logging(self):
191+
"""
192+
Tests there only one log in the interval `warning_interval`
193+
194+
@since 3.8.0
195+
@jira_ticket PYTHON-676
196+
@expected_result one log
197+
198+
@test_category timing
199+
"""
151200
tsg = timestamps.MonotonicTimestampGenerator(
152201
warning_interval=2e-6
153202
)
@@ -159,6 +208,16 @@ def test_warning_interval_respected_no_logging(self):
159208
self.assertEqual(len(self.patched_timestamp_log.warn.call_args_list), 1)
160209

161210
def test_warning_interval_respected_logs(self):
211+
"""
212+
Tests there are logs again after if the
213+
clock skew happens after`warning_interval`
214+
215+
@since 3.8.0
216+
@jira_ticket PYTHON-676
217+
@expected_result logs
218+
219+
@test_category timing
220+
"""
162221
tsg = timestamps.MonotonicTimestampGenerator(
163222
warning_interval=1e-6
164223
)
@@ -171,8 +230,17 @@ def test_warning_interval_respected_logs(self):
171230

172231

173232
class TestTimestampGeneratorMultipleThreads(unittest.TestCase):
233+
174234
def test_should_generate_incrementing_timestamps_for_all_threads(self):
235+
"""
236+
Tests when time is "stopped" values are assigned incrementally
175237
238+
@since 3.8.0
239+
@jira_ticket PYTHON-676
240+
@expected_result the returned values increase
241+
242+
@test_category timing
243+
"""
176244
lock = Lock()
177245

178246
def request_time():

0 commit comments

Comments
 (0)