diff options
author | Brad Warren <bmw@eff.org> | 2017-01-26 02:08:01 +0300 |
---|---|---|
committer | Brad Warren <bmw@eff.org> | 2017-01-26 02:08:01 +0300 |
commit | 46d9809fa1a99caf2027e181dc39c70ebc5944a0 (patch) | |
tree | 9ff4961b572f8b1e1a73d51becc1d5971e2bfcea /acme | |
parent | a5da551965bf78cd5394c5cafb10e1893bbd132b (diff) |
add test_post_failed_retry
Diffstat (limited to 'acme')
-rw-r--r-- | acme/acme/client_test.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/acme/acme/client_test.py b/acme/acme/client_test.py index 62555939c..5c9e44a2f 100644 --- a/acme/acme/client_test.py +++ b/acme/acme/client_test.py @@ -642,7 +642,9 @@ class ClientNetworkWithMockedResponseTest(unittest.TestCase): self.wrapped_obj = mock.MagicMock() self.content_type = mock.sentinel.content_type - self.all_nonces = [jose.b64encode(b'Nonce'), jose.b64encode(b'Nonce2')] + self.all_nonces = [ + jose.b64encode(b'Nonce'), + jose.b64encode(b'Nonce2'), jose.b64encode(b'Nonce3')] self.available_nonces = self.all_nonces[:] def send_request(*args, **kwargs): @@ -690,7 +692,7 @@ class ClientNetworkWithMockedResponseTest(unittest.TestCase): self.net._wrap_in_jws.assert_called_once_with( self.obj, jose.b64decode(self.all_nonces.pop())) - assert not self.available_nonces + self.available_nonces = [] self.assertRaises(errors.MissingNonce, self.net.post, 'uri', self.obj, content_type=self.content_type) self.net._wrap_in_jws.assert_called_with( @@ -706,6 +708,15 @@ class ClientNetworkWithMockedResponseTest(unittest.TestCase): self.assertRaises(errors.BadNonce, self.net.post, 'uri', self.obj, content_type=self.content_type) + def test_post_failed_retry(self): + check_response = mock.MagicMock() + check_response.side_effect = messages.Error.with_code('badNonce') + + # pylint: disable=protected-access + self.net._check_response = check_response + self.assertRaises(messages.Error, self.net.post, 'uri', + self.obj, content_type=self.content_type) + def test_head_get_post_error_passthrough(self): self.send_request.side_effect = requests.exceptions.RequestException for method in self.net.head, self.net.get: |