~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_transport.py

  • Committer: Andrew Bennetts
  • Date: 2008-04-07 08:17:38 UTC
  • mto: This revision was merged to the branch mainline in revision 3349.
  • Revision ID: andrew.bennetts@canonical.com-20080407081738-yx4c53pvqfif313d
SmartClientRequestProtocol*.read_response_tuple can now raise UnknownSmartMethod.  Callers no longer need to do their own ad hoc unknown smart method error detection.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1603
1603
        smart_protocol.call_with_body_readv_array(('foo', ), [(1,2),(5,6)])
1604
1604
        self.assertEqual(expected_bytes, output.getvalue())
1605
1605
 
1606
 
    def test_client_read_response_tuple_raises_UnknownSmartMethod(self):
1607
 
        """read_response_tuple raises UnknownSmartMethod if the response is
1608
 
        says the server did not recognise the request.
1609
 
        """
 
1606
    def _test_client_read_response_tuple_raises_UnknownSmartMethod(self,
 
1607
            server_bytes):
1610
1608
        server_bytes = (
1611
1609
            "error\x01Generic bzr smart protocol error: bad request 'foo'\n")
1612
1610
        input = StringIO(server_bytes)
1622
1620
        self.assertRaises(
1623
1621
            errors.ReadingCompleted, smart_protocol.read_body_bytes)
1624
1622
 
 
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.
 
1626
        """
 
1627
        server_bytes = (
 
1628
            "error\x01Generic bzr smart protocol error: bad request 'foo'\n")
 
1629
        self._test_client_read_response_tuple_raises_UnknownSmartMethod(
 
1630
            server_bytes)
 
1631
 
 
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.
 
1635
 
 
1636
        (bzr 0.11 sends a slightly different error message to later versions.)
 
1637
        """
 
1638
        server_bytes = (
 
1639
            "error\x01Generic bzr smart protocol error: bad request u'foo'\n")
 
1640
        self._test_client_read_response_tuple_raises_UnknownSmartMethod(
 
1641
            server_bytes)
 
1642
 
1625
1643
    def test_client_read_body_bytes_all(self):
1626
1644
        # read_body_bytes should decode the body bytes from the wire into
1627
1645
        # a response.