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)
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)
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))
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)
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)
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)
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))
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)