278
279
(optionally decorated with 'readonly+'). BzrServerFactory can
279
280
determine the original --directory from that transport.
282
# URLs always include the trailing slash, and get_base_path returns it
283
base_dir = osutils.abspath('/a/b/c') + '/'
284
base_url = urlutils.local_path_to_url(base_dir) + '/'
281
285
# Define a fake 'protocol' to capture the transport that cmd_serve
282
286
# passes to serve_bzr.
283
287
def capture_transport(transport, host, port, inet):
284
288
self.bzr_serve_transport = transport
285
289
cmd = builtins.cmd_serve()
287
cmd.run(directory='/a/b/c', protocol=capture_transport)
291
cmd.run(directory=base_dir, protocol=capture_transport)
288
292
server_maker = BzrServerFactory()
289
293
self.assertEqual(
290
'readonly+file:///a/b/c/', self.bzr_serve_transport.base)
294
'readonly+%s' % base_url, self.bzr_serve_transport.base)
291
295
self.assertEqual(
292
u'/a/b/c/', server_maker.get_base_path(self.bzr_serve_transport))
296
base_dir, server_maker.get_base_path(self.bzr_serve_transport))
294
cmd.run(directory='/a/b/c', protocol=capture_transport,
298
cmd.run(directory=base_dir, protocol=capture_transport,
295
299
allow_writes=True)
296
300
server_maker = BzrServerFactory()
297
self.assertEqual('file:///a/b/c/', self.bzr_serve_transport.base)
299
u'/a/b/c/', server_maker.get_base_path(self.bzr_serve_transport))
301
self.assertEqual(base_url, self.bzr_serve_transport.base)
302
self.assertEqual(base_dir,
303
server_maker.get_base_path(self.bzr_serve_transport))