/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_transport.py

  • Committer: Andrew Bennetts
  • Date: 2008-03-20 18:14:21 UTC
  • mto: This revision was merged to the branch mainline in revision 3349.
  • Revision ID: andrew.bennetts@canonical.com-20080320181421-91fif114b127aq05
Raise UnknownSmartMethod automatically from read_response_tuple.

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
        """
 
1610
        server_bytes = (
 
1611
            "error\x01Generic bzr smart protocol error: bad request 'foo'\n")
 
1612
        input = StringIO(server_bytes)
 
1613
        output = StringIO()
 
1614
        client_medium = medium.SmartSimplePipesClientMedium(input, output)
 
1615
        request = client_medium.get_request()
 
1616
        smart_protocol = protocol.SmartClientRequestProtocolOne(request)
 
1617
        smart_protocol.call('foo')
 
1618
        self.assertRaises(
 
1619
            errors.UnknownSmartMethod, smart_protocol.read_response_tuple)
 
1620
        # The request has been finished.  There is no body to read, and
 
1621
        # attempts to read one will fail.
 
1622
        self.assertRaises(
 
1623
            errors.ReadingCompleted, smart_protocol.read_body_bytes)
 
1624
 
1606
1625
    def test_client_read_body_bytes_all(self):
1607
1626
        # read_body_bytes should decode the body bytes from the wire into
1608
1627
        # a response.
1932
1951
        smart_protocol.read_response_tuple(False)
1933
1952
        self.assertEqual(True, smart_protocol.response_status)
1934
1953
 
 
1954
    def test_client_read_response_tuple_raises_UnknownSmartMethod(self):
 
1955
        """read_response_tuple raises UnknownSmartMethod if the response is
 
1956
        says the server did not recognise the request.
 
1957
        """
 
1958
        server_bytes = (
 
1959
            protocol.RESPONSE_VERSION_TWO +
 
1960
            "failed\n" +
 
1961
            "error\x01Generic bzr smart protocol error: bad request 'foo'\n")
 
1962
        input = StringIO(server_bytes)
 
1963
        output = StringIO()
 
1964
        client_medium = medium.SmartSimplePipesClientMedium(input, output)
 
1965
        request = client_medium.get_request()
 
1966
        smart_protocol = protocol.SmartClientRequestProtocolTwo(request)
 
1967
        smart_protocol.call('foo')
 
1968
        self.assertRaises(
 
1969
            errors.UnknownSmartMethod, smart_protocol.read_response_tuple)
 
1970
        self.assertEqual(False, smart_protocol.response_status)
 
1971
        # The request has been finished.  There is no body to read, and
 
1972
        # attempts to read one will fail.
 
1973
        self.assertRaises(
 
1974
            errors.ReadingCompleted, smart_protocol.read_body_bytes)
 
1975
 
1935
1976
    def test_client_read_body_bytes_all(self):
1936
1977
        # read_body_bytes should decode the body bytes from the wire into
1937
1978
        # a response.