Skip to content

Commit 5827060

Browse files
committed
fix test
1 parent 8651d50 commit 5827060

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

tests/test_all.py

+14-5
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,10 @@ def test_is_banned(self):
671671
res = Response(
672672
req.url,
673673
status=503,
674-
headers={"Zyte-Error-Type": "/limits/over-global-limit"},
674+
headers={
675+
"Zyte-Request-Id": "123456789",
676+
"Zyte-Error-Type": "/limits/over-global-limit",
677+
},
675678
)
676679
res = mw.process_response(req, res, self.spider)
677680
self.assertFalse(mw._is_banned(res))
@@ -682,18 +685,24 @@ def test_is_banned(self):
682685
res = Response(
683686
req.url,
684687
status=520,
685-
headers={"Zyte-Error-Type": "/download/temporary-error"},
688+
headers={
689+
"Zyte-Request-Id": "123456789",
690+
"Zyte-Error-Type": "/download/temporary-error",
691+
},
686692
)
687-
assert mw.crawler.stats.get_value("zyte_smartproxy/response/banned") == 1
688693
res = mw.process_response(req, res, self.spider)
694+
assert mw.crawler.stats.get_value("zyte_smartproxy/response/banned") == 1
689695
self.assertTrue(mw._is_banned(res))
690696
res = Response(
691697
req.url,
692698
status=521,
693-
headers={"Zyte-Error-Type": "/download/internal-error"},
699+
headers={
700+
"Zyte-Request-Id": "123456789",
701+
"Zyte-Error-Type": "/download/internal-error",
702+
},
694703
)
695704
res = mw.process_response(req, res, self.spider)
696-
assert mw.crawler.stats.get_value("zyte_smartproxy/response/banned") == 3
705+
assert mw.crawler.stats.get_value("zyte_smartproxy/response/banned") == 2
697706
self.assertTrue(mw._is_banned(res))
698707

699708
@patch("random.uniform")

0 commit comments

Comments
 (0)