[MERGE] Better infrastructure for dealing with 'bad request' responses from a smart server

Andrew Bennetts andrew at canonical.com
Wed Apr 9 14:17:18 BST 2008


John Arbash Meinel wrote:
[...]
>
>
> I'm not 100% sure about some of the test case changes, namely this one:
>
> @@ -536,23 +563,7 @@
> ~         advisory anyway (a transport could be read-write, but then the
> ~         underlying filesystem could be readonly anyway).
> ~         """
> - -        client = FakeClient([(
> - -            ('error', "Generic bzr smart protocol error: "
> - -                      "bad request 'Transport.is_readonly'"), '')])
> - -        transport = RemoteTransport('bzr://example.com/', medium=False,
> - -                                    _client=client)
> - -        self.assertEqual(False, transport.is_readonly())
> - -        self.assertEqual(
> - -            [('call', 'Transport.is_readonly', ())],
> - -            client._calls)
> - -
> - -    def test_error_from_old_0_11_server(self):
> - -        """Same as test_error_from_old_server, but with the slightly different
> - -        error message from bzr 0.11 servers.
> - -        """
> - -        client = FakeClient([(
> - -            ('error', "Generic bzr smart protocol error: "
> - -                      "bad request u'Transport.is_readonly'"), '')])
> +        client = FakeClient([(('unknown verb', 'Transport.is_readonly'), '')])
> ~         transport = RemoteTransport('bzr://example.com/', medium=False,
> ~                                     _client=client)
> ~         self.assertEqual(False, transport.is_readonly())
>
>
> But as I'm not 100% sure what you are doing, I would trust your knowledge first.

The RemoteTransport object is no longer responsible for having logic to cope
with both the error from 0.11 and >0.11 servers, because that's handled by
protocol implementation.  All RemoteTransport (and other Remote* classes that
use _SmartClient) need to do is catch UnknownSmartMethod.  So there's no need
for two different tests here.

Instead, that patch added tests for the two variants of the error in
test_smart_protocol, because it's now the protocol that needs to know about both
variants.

-Andrew.




More information about the bazaar mailing list