1
This commit is contained in:
1 parent
2ea1a79bda
commit
85425483c0
50 files changed
+6468
-1854
No files matched your search
@@ -0,0 +1,30 @@
|
||||
"""Ambiguous mutating HTTP responses must trigger reconciliation, not a fresh entry."""
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||
import live
|
||||
|
||||
|
||||
class UncertainResponseTests(unittest.TestCase):
|
||||
def request(self, method, status, body):
|
||||
response = mock.Mock(status=status, will_close=True)
|
||||
response.read.return_value = body
|
||||
response.getheader.return_value = 'close'
|
||||
connection = mock.Mock()
|
||||
connection.getresponse.return_value = response
|
||||
with mock.patch.object(live, '_take', return_value=(connection, False)):
|
||||
with self.assertRaises(live.LiveError) as error:
|
||||
live._http(method, 'https://exchange.invalid/order')
|
||||
return error.exception
|
||||
|
||||
def test_server_error_on_submit_is_uncertain(self):
|
||||
self.assertTrue(self.request('POST', 503, b'unavailable').sent)
|
||||
self.assertTrue(self.request('DELETE', 500, b'error').sent)
|
||||
self.assertFalse(self.request('GET', 503, b'unavailable').sent)
|
||||
self.assertFalse(self.request('POST', 400, b'rejected').sent)
|
||||
|
||||
def test_unreadable_success_response_is_uncertain(self):
|
||||
self.assertTrue(self.request('POST', 200, b'{truncated').sent)
|
||||
Reference in new issue
Block a user