Esempio n. 1
0
    def test_status_forcelist(self):
        retry = Retry(status_forcelist=xrange(500, 600))
        self.assertFalse(retry.is_forced_retry('GET', status_code=200))
        self.assertFalse(retry.is_forced_retry('GET', status_code=400))
        self.assertTrue(retry.is_forced_retry('GET', status_code=500))

        retry = Retry(total=1, status_forcelist=[418])
        self.assertFalse(retry.is_forced_retry('GET', status_code=400))
        self.assertTrue(retry.is_forced_retry('GET', status_code=418))
Esempio n. 2
0
    def test_status_forcelist(self):
        retry = Retry(status_forcelist=xrange(500,600))
        self.assertFalse(retry.is_forced_retry('GET', status_code=200))
        self.assertFalse(retry.is_forced_retry('GET', status_code=400))
        self.assertTrue(retry.is_forced_retry('GET', status_code=500))

        retry = Retry(total=1, status_forcelist=[418])
        self.assertFalse(retry.is_forced_retry('GET', status_code=400))
        self.assertTrue(retry.is_forced_retry('GET', status_code=418))
Esempio n. 3
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)
        self.assertTrue(retry.is_forced_retry('GET', status_code=500))
        self.assertTrue(retry.is_forced_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_forced_retry('GET', status_code=500))
        self.assertTrue(retry.is_forced_retry('POST', status_code=500))
Esempio n. 4
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)
        self.assertTrue(retry.is_forced_retry('GET', status_code=500))
        self.assertTrue(retry.is_forced_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_forced_retry('GET', status_code=500))
        self.assertTrue(retry.is_forced_retry('POST', status_code=500))
Esempio n. 5
0
    def test_status_forcelist(self):
        retry = Retry(status_forcelist=xrange(500,600))
        self.assertFalse(retry.is_forced_retry('GET', status_code=200))
        self.assertFalse(retry.is_forced_retry('GET', status_code=400))
        self.assertTrue(retry.is_forced_retry('GET', status_code=500))

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

        # String status codes are not matched.
        retry = Retry(total=1, status_forcelist=['418'])
        self.assertFalse(retry.is_forced_retry('GET', status_code=418))
Esempio n. 6
0
    def test_status_forcelist(self):
        retry = Retry(status_forcelist=xrange(500, 600))
        self.assertFalse(retry.is_forced_retry('GET', status_code=200))
        self.assertFalse(retry.is_forced_retry('GET', status_code=400))
        self.assertTrue(retry.is_forced_retry('GET', status_code=500))

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

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