|
| 1 | +from datetime import datetime, timedelta, timezone |
| 2 | + |
1 | 3 | import pytest
|
2 | 4 | from freezegun import freeze_time
|
3 | 5 |
|
@@ -150,25 +152,21 @@ async def test_get_audit_parameterized(
|
150 | 152 | "2025-08-01",
|
151 | 153 | ],
|
152 | 154 | ),
|
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 |
| - ), |
163 | 155 | (
|
164 | 156 | {"days": 15, "months": 1},
|
165 | 157 | "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 | + ], |
172 | 170 | ),
|
173 | 171 | ],
|
174 | 172 | )
|
@@ -205,19 +203,9 @@ async def test_get_audit_lookback_periods(
|
205 | 203 | json=GITHUB_AUDIT,
|
206 | 204 | )
|
207 | 205 |
|
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 |
221 | 209 |
|
222 | 210 |
|
223 | 211 | # Test generate_date_range
|
|
0 commit comments