Reconcile all83 observed Semrush URLs and make complete CI verification independent of PyPI
Rebuild V2 candidate verification / candidate (push) Failing after 1m27s
Rebuild V2 candidate verification / candidate (push) Failing after 1m27s
This commit is contained in:
1 parent
44c5797144
commit
e8cef39175
89 files changed
+110413
-1374
No files matched your search
@@ -0,0 +1,21 @@
|
||||
"""A simulated429 must persist Retry-After and prevent subsequent network calls."""
|
||||
import tempfile,unittest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
from types import SimpleNamespace
|
||||
import fetch
|
||||
class RateLimit(unittest.TestCase):
|
||||
def test_stop_all_following_wayback_fetches(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root=Path(directory);raw=root/'raw';raw.mkdir()
|
||||
def respond(cmd,**kwargs):
|
||||
Path(cmd[cmd.index('-D')+1]).write_text('HTTP/2 429\nRetry-After: 120\n')
|
||||
Path(cmd[cmd.index('-o')+1]).write_text('Too Many Requests')
|
||||
return SimpleNamespace(stdout='429\nhttps://web.archive.org/web/test',stderr='',returncode=0)
|
||||
with patch.object(fetch,'ROOT',root),patch.object(fetch,'RAW',raw),patch.object(fetch.subprocess,'run',side_effect=respond) as network:
|
||||
result=fetch.fetch('https://web.archive.org/web/test','first.html')
|
||||
self.assertEqual(result['httpStatus'],'429')
|
||||
self.assertIn('120',(raw/'wayback-rate-limit.json').read_text())
|
||||
with self.assertRaisesRegex(RuntimeError,'stop marker'):fetch.fetch('https://web.archive.org/cdx/search/cdx','second.json')
|
||||
self.assertEqual(network.call_count,1)
|
||||
if __name__=='__main__':unittest.main()
|
||||
Reference in new issue
Block a user