1603
1603
smart_protocol.call_with_body_readv_array(('foo', ), [(1,2),(5,6)])
1604
1604
self.assertEqual(expected_bytes, output.getvalue())
1606
def _test_client_read_response_tuple_raises_UnknownSmartMethod(self,
1609
"error\x01Generic bzr smart protocol error: bad request 'foo'\n")
1610
input = StringIO(server_bytes)
1612
client_medium = medium.SmartSimplePipesClientMedium(input, output)
1613
request = client_medium.get_request()
1614
smart_protocol = protocol.SmartClientRequestProtocolOne(request)
1615
smart_protocol.call('foo')
1617
errors.UnknownSmartMethod, smart_protocol.read_response_tuple)
1618
# The request has been finished. There is no body to read, and
1619
# attempts to read one will fail.
1621
errors.ReadingCompleted, smart_protocol.read_body_bytes)
1623
def test_client_read_response_tuple_raises_UnknownSmartMethod(self):
1624
"""read_response_tuple raises UnknownSmartMethod if the response says
1625
the server did not recognise the request.
1628
"error\x01Generic bzr smart protocol error: bad request 'foo'\n")
1629
self._test_client_read_response_tuple_raises_UnknownSmartMethod(
1632
def test_client_read_response_tuple_raises_UnknownSmartMethod_0_11(self):
1633
"""read_response_tuple also raises UnknownSmartMethod if the response
1634
from a bzr 0.11 says the server did not recognise the request.
1636
(bzr 0.11 sends a slightly different error message to later versions.)
1639
"error\x01Generic bzr smart protocol error: bad request u'foo'\n")
1640
self._test_client_read_response_tuple_raises_UnknownSmartMethod(
1606
1643
def test_client_read_body_bytes_all(self):
1607
1644
# read_body_bytes should decode the body bytes from the wire into
1932
1969
smart_protocol.read_response_tuple(False)
1933
1970
self.assertEqual(True, smart_protocol.response_status)
1972
def test_client_read_response_tuple_raises_UnknownSmartMethod(self):
1973
"""read_response_tuple raises UnknownSmartMethod if the response is
1974
says the server did not recognise the request.
1977
protocol.RESPONSE_VERSION_TWO +
1979
"error\x01Generic bzr smart protocol error: bad request 'foo'\n")
1980
input = StringIO(server_bytes)
1982
client_medium = medium.SmartSimplePipesClientMedium(input, output)
1983
request = client_medium.get_request()
1984
smart_protocol = protocol.SmartClientRequestProtocolTwo(request)
1985
smart_protocol.call('foo')
1987
errors.UnknownSmartMethod, smart_protocol.read_response_tuple)
1988
self.assertEqual(False, smart_protocol.response_status)
1989
# The request has been finished. There is no body to read, and
1990
# attempts to read one will fail.
1992
errors.ReadingCompleted, smart_protocol.read_body_bytes)
1935
1994
def test_client_read_body_bytes_all(self):
1936
1995
# read_body_bytes should decode the body bytes from the wire into