/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_transport_implementations.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-09-15 01:31:27 UTC
  • mfrom: (1910.15.11 extra transport tests)
  • Revision ID: pqm@pqm.ubuntu.com-20060915013127-9c6755fb4c48456e
(Andrew Bennetts, Robert Collins, Martin Pool) Ensure consistent behaviour at the root of transports for clone/abspath.

Show diffs side-by-side

added added

removed removed

Lines of Context:
144
144
                             t.put, 'b', StringIO('file-like\ncontents\n'))
145
145
        self.check_transport_contents('file-like\ncontents\n', t, 'b')
146
146
 
 
147
        self.assertRaises(NoSuchFile,
 
148
                          t.put, 'path/doesnt/exist/c', StringIO('contents'))
 
149
 
147
150
    def test_put_bytes(self):
148
151
        t = self.get_transport()
149
152
 
400
403
        self.check_transport_contents('diff\ncontents for\na\n', t, 'a')
401
404
        self.check_transport_contents('another contents\nfor d\n', t, 'd')
402
405
 
 
406
    def test_put_permissions(self):
 
407
        t = self.get_transport()
 
408
 
 
409
        if t.is_readonly():
 
410
            return
 
411
        if not t._can_roundtrip_unix_modebits():
 
412
            # Can't roundtrip, so no need to run this test
 
413
            return
 
414
        self.applyDeprecated(zero_eleven, t.put, 'mode644',
 
415
                             StringIO('test text\n'), mode=0644)
 
416
        self.assertTransportMode(t, 'mode644', 0644)
 
417
        self.applyDeprecated(zero_eleven, t.put, 'mode666',
 
418
                             StringIO('test text\n'), mode=0666)
 
419
        self.assertTransportMode(t, 'mode666', 0666)
 
420
        self.applyDeprecated(zero_eleven, t.put, 'mode600',
 
421
                             StringIO('test text\n'), mode=0600)
 
422
        self.assertTransportMode(t, 'mode600', 0600)
 
423
        # Yes, you can put a file such that it becomes readonly
 
424
        self.applyDeprecated(zero_eleven, t.put, 'mode400',
 
425
                             StringIO('test text\n'), mode=0400)
 
426
        self.assertTransportMode(t, 'mode400', 0400)
 
427
        self.applyDeprecated(zero_eleven, t.put_multi,
 
428
                             [('mmode644', StringIO('text\n'))], mode=0644)
 
429
        self.assertTransportMode(t, 'mmode644', 0644)
 
430
 
 
431
        # The default permissions should be based on the current umask
 
432
        umask = osutils.get_umask()
 
433
        self.applyDeprecated(zero_eleven, t.put, 'nomode',
 
434
                             StringIO('test text\n'), mode=None)
 
435
        self.assertTransportMode(t, 'nomode', 0666 & ~umask)
 
436
        
403
437
    def test_mkdir(self):
404
438
        t = self.get_transport()
405
439
 
998
1032
        self.failUnless(t2.has('d'))
999
1033
        self.failUnless(t3.has('b/d'))
1000
1034
 
 
1035
    def test_clone_to_root(self):
 
1036
        orig_transport = self.get_transport()
 
1037
        # Repeatedly go up to a parent directory until we're at the root
 
1038
        # directory of this transport
 
1039
        root_transport = orig_transport
 
1040
        while root_transport.clone("..").base != root_transport.base:
 
1041
            root_transport = root_transport.clone("..")
 
1042
 
 
1043
        # Cloning to "/" should take us to exactly the same location.
 
1044
        self.assertEqual(root_transport.base, orig_transport.clone("/").base)
 
1045
 
 
1046
        # At the root, the URL must still end with / as its a directory
 
1047
        self.assertEqual(root_transport.base[-1], '/')
 
1048
 
 
1049
    def test_clone_from_root(self):
 
1050
        """At the root, cloning to a simple dir should just do string append."""
 
1051
        orig_transport = self.get_transport()
 
1052
        root_transport = orig_transport.clone('/')
 
1053
        self.assertEqual(root_transport.base + '.bzr/',
 
1054
            root_transport.clone('.bzr').base)
 
1055
 
 
1056
    def test_base_url(self):
 
1057
        t = self.get_transport()
 
1058
        self.assertEqual('/', t.base[-1])
 
1059
 
1001
1060
    def test_relpath(self):
1002
1061
        t = self.get_transport()
1003
1062
        self.assertEqual('', t.relpath(t.base))
1031
1090
        self.assertEqual(transport.base + 'relpath',
1032
1091
                         transport.abspath('relpath'))
1033
1092
 
 
1093
        # This should work without raising an error.
 
1094
        transport.abspath("/")
 
1095
 
 
1096
        # the abspath of "/" and "/foo/.." should result in the same location
 
1097
        self.assertEqual(transport.abspath("/"), transport.abspath("/foo/.."))
 
1098
 
1034
1099
    def test_local_abspath(self):
1035
1100
        transport = self.get_transport()
1036
1101
        try:
1208
1273
        self.assertEqual(d[1], (9, '9'))
1209
1274
        self.assertEqual(d[2], (0, '0'))
1210
1275
        self.assertEqual(d[3], (3, '34'))
 
1276