Skip to content

Commit 06be85f

Browse files
committed
shortening the tests - somewhat
1 parent b94081a commit 06be85f

File tree

1 file changed

+17
-29
lines changed

1 file changed

+17
-29
lines changed

tests/test_audit.py

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from datetime import datetime, timedelta, timezone
2+
13
import pytest
24
from freezegun import freeze_time
35

@@ -150,25 +152,21 @@ async def test_get_audit_parameterized(
150152
"2025-08-01",
151153
],
152154
),
153-
(
154-
{"months": 2},
155-
"action:protected_branch.create created:2025-06-01",
156-
["2025-06-01", "2025-06-02", "2025-06-03"],
157-
),
158-
(
159-
{"years": 1},
160-
"action:protected_branch.create created:2024-08-01",
161-
["2024-08-01", "2024-08-02", "2024-08-03"],
162-
),
163155
(
164156
{"days": 15, "months": 1},
165157
"action:protected_branch.create created:2025-06-16",
166-
["2025-06-16", "2025-06-17", "2025-06-18"],
167-
),
168-
(
169-
{"days": 10, "months": 1, "years": 1},
170-
"action:protected_branch.create created:2024-06-21",
171-
["2024-06-21", "2024-06-22", "2024-06-23"],
158+
[
159+
(
160+
datetime(2025, 6, 16, tzinfo=timezone.utc) + timedelta(days=i)
161+
).strftime("%Y-%m-%d")
162+
for i in range(
163+
(
164+
datetime(2025, 8, 1, tzinfo=timezone.utc)
165+
- datetime(2025, 6, 16, tzinfo=timezone.utc)
166+
).days
167+
+ 1
168+
)
169+
],
172170
),
173171
],
174172
)
@@ -205,19 +203,9 @@ async def test_get_audit_lookback_periods(
205203
json=GITHUB_AUDIT,
206204
)
207205

208-
# replacing generate_date_range with test dates
209-
# so that we don't iterate through all dates
210-
import nodestream_github.audit as client_module
211-
212-
original_generate = client_module.generate_date_range
213-
client_module.generate_date_range = lambda x: expected_dates
214-
215-
try:
216-
all_records = [record async for record in extractor.extract_records()]
217-
expected_output = GITHUB_EXPECTED_OUTPUT * len(expected_dates)
218-
assert all_records == expected_output
219-
finally:
220-
client_module.generate_date_range = original_generate
206+
all_records = [record async for record in extractor.extract_records()]
207+
expected_output = GITHUB_EXPECTED_OUTPUT * len(expected_dates)
208+
assert all_records == expected_output
221209

222210

223211
# Test generate_date_range

0 commit comments

Comments
 (0)