Ejemplo n.º 1
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)
Ejemplo n.º 2
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)