215
216
server.tearDown()
219
class FakeNFSDecoratorTests(TestCaseInTempDir):
220
"""NFS decorator specific tests."""
222
def get_nfs_transport(self, url):
223
import bzrlib.transport.fakenfs as fakenfs
224
# connect to url with nfs decoration
225
return fakenfs.FakeNFSTransportDecorator('fakenfs+' + url)
227
def test_local_parameters(self):
228
# the listable, should_cache and is_readonly parameters
229
# are not changed by the fakenfs decorator
230
transport = self.get_nfs_transport('.')
231
self.assertEqual(True, transport.listable())
232
self.assertEqual(False, transport.should_cache())
233
self.assertEqual(False, transport.is_readonly())
235
def test_http_parameters(self):
236
# the listable, should_cache and is_readonly parameters
237
# are not changed by the fakenfs decorator
238
from bzrlib.transport.http import HttpServer
239
# connect to . via http which is not listable
240
server = HttpServer()
243
transport = self.get_nfs_transport(server.get_url())
244
self.assertIsInstance(
245
transport, bzrlib.transport.fakenfs.FakeNFSTransportDecorator)
246
self.assertEqual(False, transport.listable())
247
self.assertEqual(True, transport.should_cache())
248
self.assertEqual(True, transport.is_readonly())
252
def test_fakenfs_server_default(self):
253
# a FakeNFSServer() should bring up a local relpath server for itself
254
import bzrlib.transport.fakenfs as fakenfs
255
server = fakenfs.FakeNFSServer()
258
# the server should be a relpath localhost server
259
self.assertEqual(server.get_url(), 'fakenfs+.')
260
# and we should be able to get a transport for it
261
transport = get_transport(server.get_url())
262
# which must be a FakeNFSTransportDecorator instance.
263
self.assertIsInstance(
264
transport, fakenfs.FakeNFSTransportDecorator)
268
def test_fakenfs_rename_semantics(self):
269
# a FakeNFS transport must mangle the way rename errors occur to
270
# look like NFS problems.
271
transport = self.get_nfs_transport('.')
272
self.build_tree(['from/', 'from/foo', 'to/', 'to/bar'],
274
self.assertRaises(bzrlib.errors.ResourceBusy,
275
transport.rename, 'from', 'to')
218
278
class BadTransportHandler(Transport):
219
279
def __init__(self, base_url):
220
280
raise DependencyNotPresent('some_lib', 'testing missing dependency')