コード例 #1
0
    def test_allowed_methods_with_status_forcelist(self) -> None:
        # Falsey allowed_methods means to retry on any method.
        retry = Retry(status_forcelist=[500], allowed_methods=None)
        assert retry.is_retry("GET", status_code=500)
        assert retry.is_retry("POST", status_code=500)

        # Criteria of allowed_methods and status_forcelist are ANDed.
        retry = Retry(status_forcelist=[500], allowed_methods=["POST"])
        assert not retry.is_retry("GET", status_code=500)
        assert retry.is_retry("POST", status_code=500)
コード例 #2
0
    def test_method_whitelist_with_status_forcelist(self):
        # Falsey method_whitelist means to retry on any method.
        retry = Retry(status_forcelist=[500], method_whitelist=None)
        assert retry.is_retry("GET", status_code=500)
        assert retry.is_retry("POST", status_code=500)

        # Criteria of method_whitelist and status_forcelist are ANDed.
        retry = Retry(status_forcelist=[500], method_whitelist=["POST"])
        assert not retry.is_retry("GET", status_code=500)
        assert retry.is_retry("POST", status_code=500)
コード例 #3
0
ファイル: test_retry.py プロジェクト: vpfautz/urllib3
    def test_method_whitelist_with_status_forcelist(self):
        # Falsey method_whitelist means to retry on any method.
        retry = Retry(status_forcelist=[500], method_whitelist=None)
        self.assertTrue(retry.is_retry('GET', status_code=500))
        self.assertTrue(retry.is_retry('POST', status_code=500))

        # Criteria of method_whitelist and status_forcelist are ANDed.
        retry = Retry(status_forcelist=[500], method_whitelist=['POST'])
        self.assertFalse(retry.is_retry('GET', status_code=500))
        self.assertTrue(retry.is_retry('POST', status_code=500))
コード例 #4
0
ファイル: test_retry.py プロジェクト: cloudera/hue
    def test_method_whitelist_with_status_forcelist(self):
        # Falsey method_whitelist means to retry on any method.
        retry = Retry(status_forcelist=[500], method_whitelist=None)
        assert retry.is_retry('GET', status_code=500)
        assert retry.is_retry('POST', status_code=500)

        # Criteria of method_whitelist and status_forcelist are ANDed.
        retry = Retry(status_forcelist=[500], method_whitelist=['POST'])
        assert not retry.is_retry('GET', status_code=500)
        assert retry.is_retry('POST', status_code=500)
コード例 #5
0
    def test_status_forcelist(self) -> None:
        retry = Retry(status_forcelist=range(500, 600))
        assert not retry.is_retry("GET", status_code=200)
        assert not retry.is_retry("GET", status_code=400)
        assert retry.is_retry("GET", status_code=500)

        retry = Retry(total=1, status_forcelist=[418])
        assert not retry.is_retry("GET", status_code=400)
        assert retry.is_retry("GET", status_code=418)

        # String status codes are not matched.
        retry = Retry(total=1, status_forcelist=["418"])  # type: ignore[list-item]
        assert not retry.is_retry("GET", status_code=418)
コード例 #6
0
    def test_status_forcelist(self):
        retry = Retry(status_forcelist=xrange(500, 600))
        assert not retry.is_retry("GET", status_code=200)
        assert not retry.is_retry("GET", status_code=400)
        assert retry.is_retry("GET", status_code=500)

        retry = Retry(total=1, status_forcelist=[418])
        assert not retry.is_retry("GET", status_code=400)
        assert retry.is_retry("GET", status_code=418)

        # String status codes are not matched.
        retry = Retry(total=1, status_forcelist=["418"])
        assert not retry.is_retry("GET", status_code=418)
コード例 #7
0
ファイル: test_retry.py プロジェクト: vpfautz/urllib3
    def test_status_forcelist(self):
        retry = Retry(status_forcelist=xrange(500, 600))
        self.assertFalse(retry.is_retry('GET', status_code=200))
        self.assertFalse(retry.is_retry('GET', status_code=400))
        self.assertTrue(retry.is_retry('GET', status_code=500))

        retry = Retry(total=1, status_forcelist=[418])
        self.assertFalse(retry.is_retry('GET', status_code=400))
        self.assertTrue(retry.is_retry('GET', status_code=418))

        # String status codes are not matched.
        retry = Retry(total=1, status_forcelist=['418'])
        self.assertFalse(retry.is_retry('GET', status_code=418))
コード例 #8
0
ファイル: test_retry.py プロジェクト: cloudera/hue
    def test_status_forcelist(self):
        retry = Retry(status_forcelist=xrange(500, 600))
        assert not retry.is_retry('GET', status_code=200)
        assert not retry.is_retry('GET', status_code=400)
        assert retry.is_retry('GET', status_code=500)

        retry = Retry(total=1, status_forcelist=[418])
        assert not retry.is_retry('GET', status_code=400)
        assert retry.is_retry('GET', status_code=418)

        # String status codes are not matched.
        retry = Retry(total=1, status_forcelist=['418'])
        assert not retry.is_retry('GET', status_code=418)