~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_transport.py

  • Committer: Neil Santos
  • Date: 2010-02-25 03:23:48 UTC
  • mto: (5080.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5081.
  • Revision ID: neil_santos@users.sourceforge.net-20100225032348-pi4bes9ehqjg394c
Added default link() and symlink() methods to Transport.
Added implementation of link() and symlink() methods to LocalTransport.
Added implementation of symlink() method to SFTPTransport.
Added corresponding tests (symlink() fails for SFTPTransport for some reason; possibly a Paramiko bug?).
Committing in preparation for push and eventual merge proposal to mainline bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1083
1083
        subdir.stat('./file')
1084
1084
        subdir.stat('.')
1085
1085
 
 
1086
    def test_link(self):
 
1087
        from stat import ST_NLINK
 
1088
 
 
1089
        t = self.get_transport()
 
1090
 
 
1091
        source_name = "original_target"
 
1092
        link_name = "target_link"
 
1093
 
 
1094
        self.build_tree([source_name], transport=t)
 
1095
 
 
1096
        try:
 
1097
            link_result = t.link(source_name, link_name)
 
1098
            self.failUnless(link_result)
 
1099
 
 
1100
            self.failUnless(t.has(source_name))
 
1101
            self.failUnless(t.has(link_name))
 
1102
 
 
1103
            st = t.stat(link_name)
 
1104
            self.failUnlessEqual(st[ST_NLINK], 2)
 
1105
        except TransportNotPossible:
 
1106
            # This transport doesn't do hardlinks
 
1107
            return
 
1108
 
 
1109
    def test_symlink(self):
 
1110
        from stat import S_ISLNK
 
1111
 
 
1112
        t = self.get_transport()
 
1113
 
 
1114
        source_name = "original_target"
 
1115
        link_name = "target_link"
 
1116
 
 
1117
        self.build_tree([source_name], transport=t)
 
1118
 
 
1119
        try:
 
1120
            link_result = t.symlink(source_name, link_name)
 
1121
            self.failUnless(link_result)
 
1122
 
 
1123
            self.failUnless(t.has(source_name))
 
1124
            self.failUnless(t.has(link_name))
 
1125
 
 
1126
            st = t.stat(link_name)
 
1127
            self.failUnless(S_ISLNK(st.st_mode))
 
1128
        except TransportNotPossible:
 
1129
            # This transport doesn't do hardlinks
 
1130
            return
 
1131
 
1086
1132
    def test_list_dir(self):
1087
1133
        # TODO: Test list_dir, just try once, and if it throws, stop testing
1088
1134
        t = self.get_transport()