1382
1382
errors.ReadingCompleted, smart_protocol.read_body_bytes)
1385
class TestSmartClientUnicode(tests.TestCase):
1386
"""SmartClient tests for unicode arguments.
1388
Unicode arguments to call_with_body_bytes are not correct (remote method
1389
names, arguments, and bodies must all be expressed as byte strings), but
1390
SmartClient should gracefully reject them, rather than getting into a broken
1391
state that prevents future correct calls from working. That is, it should
1392
be possible to issue more requests on the medium afterwards, rather than
1393
allowing one bad call to call_with_body_bytes to cause later calls to
1394
mysteriously fail with TooManyConcurrentRequests.
1397
def assertCallDoesNotBreakMedium(self, method, args, body):
1398
"""Call a medium with the given method, args and body, then assert that
1399
the medium is left in a sane state, i.e. is capable of allowing further
1402
input = StringIO("\n")
1404
client_medium = medium.SmartSimplePipesClientMedium(input, output)
1405
smart_client = client.SmartClient(client_medium)
1406
self.assertRaises(TypeError,
1407
smart_client.call_with_body_bytes, method, args, body)
1408
self.assertEqual("", output.getvalue())
1409
self.assertEqual(None, client_medium._current_request)
1411
def test_call_with_body_bytes_unicode_method(self):
1412
self.assertCallDoesNotBreakMedium(u'method', ('args',), 'body')
1414
def test_call_with_body_bytes_unicode_args(self):
1415
self.assertCallDoesNotBreakMedium('method', (u'args',), 'body')
1417
def test_call_with_body_bytes_unicode_body(self):
1418
self.assertCallDoesNotBreakMedium('method', ('args',), u'body')
1385
1421
class LengthPrefixedBodyDecoder(tests.TestCase):
1387
1423
# XXX: TODO: make accept_reading_trailer invoke translate_response or