~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport_implementations.py

  • Committer: John Arbash Meinel
  • Date: 2006-09-05 19:53:21 UTC
  • mto: (1946.2.8 reduce-knit-churn)
  • mto: This revision was merged to the branch mainline in revision 1988.
  • Revision ID: john@arbash-meinel.com-20060905195321-167cc7f7c4b09fa0
Fix the deprecation warnings in the transport tests themselves

Show diffs side-by-side

added added

removed removed

Lines of Context:
150
150
 
151
151
        if t.is_readonly():
152
152
            return
153
 
        self.assertEqual(t.put_multi([('a', StringIO('new\ncontents for\na\n')),
154
 
                                      ('d', StringIO('contents\nfor d\n'))]),
155
 
                         2)
 
153
        deprecation_msg = '%s.%s.%s was deprecated in version 0.11.' % (
 
154
            t.put_multi.im_class.__module__, t.put_multi.im_class.__name__,
 
155
            t.put_multi.__name__)
 
156
        self.assertEqual(2, self.callDeprecated([deprecation_msg],
 
157
            t.put_multi, [('a', StringIO('new\ncontents for\na\n')),
 
158
                          ('d', StringIO('contents\nfor d\n'))]
 
159
            ))
156
160
        self.assertEqual(list(t.has_multi(['a', 'b', 'c', 'd'])),
157
161
                [True, False, False, True])
158
162
        self.check_transport_contents('new\ncontents for\na\n', t, 'a')
159
163
        self.check_transport_contents('contents\nfor d\n', t, 'd')
160
164
 
161
 
        self.assertEqual(
162
 
            t.put_multi(iter([('a', StringIO('diff\ncontents for\na\n')),
163
 
                              ('d', StringIO('another contents\nfor d\n'))])),
164
 
                        2)
 
165
        self.assertEqual(2, self.callDeprecated([deprecation_msg],
 
166
            t.put_multi, iter([('a', StringIO('diff\ncontents for\na\n')),
 
167
                              ('d', StringIO('another contents\nfor d\n'))])
 
168
            ))
165
169
        self.check_transport_contents('diff\ncontents for\na\n', t, 'a')
166
170
        self.check_transport_contents('another contents\nfor d\n', t, 'd')
167
171
 
180
184
        t.put_file('a', StringIO('new\ncontents for\na\n'))
181
185
        self.check_transport_contents('new\ncontents for\na\n', t, 'a')
182
186
        self.assertRaises(NoSuchFile,
183
 
                          t.put, 'path/doesnt/exist/c', StringIO('contents'))
 
187
                          t.put_file, 'path/doesnt/exist/c',
 
188
                              StringIO('contents'))
184
189
 
185
190
    def test_put_bytes(self):
186
191
        t = self.get_transport()
201
206
        self.assertRaises(NoSuchFile,
202
207
                          t.put_bytes, 'path/doesnt/exist/c', 'contents')
203
208
 
204
 
    def test_put_permissions(self):
 
209
    def test_put_file_permissions(self):
205
210
        t = self.get_transport()
206
211
 
207
212
        if t.is_readonly():
209
214
        if not t._can_roundtrip_unix_modebits():
210
215
            # Can't roundtrip, so no need to run this test
211
216
            return
212
 
        t.put('mode644', StringIO('test text\n'), mode=0644)
 
217
        t.put_file('mode644', StringIO('test text\n'), mode=0644)
213
218
        self.assertTransportMode(t, 'mode644', 0644)
214
 
        t.put('mode666', StringIO('test text\n'), mode=0666)
 
219
        t.put_file('mode666', StringIO('test text\n'), mode=0666)
215
220
        self.assertTransportMode(t, 'mode666', 0666)
216
 
        t.put('mode600', StringIO('test text\n'), mode=0600)
 
221
        t.put_file('mode600', StringIO('test text\n'), mode=0600)
217
222
        self.assertTransportMode(t, 'mode600', 0600)
218
223
        # Yes, you can put a file such that it becomes readonly
219
 
        t.put('mode400', StringIO('test text\n'), mode=0400)
 
224
        t.put_file('mode400', StringIO('test text\n'), mode=0400)
220
225
        self.assertTransportMode(t, 'mode400', 0400)
221
 
        t.put_multi([('mmode644', StringIO('text\n'))], mode=0644)
 
226
 
 
227
        # XXX: put_multi is deprecated, so do we really care anymore?
 
228
        deprecation_msg = '%s.%s.%s was deprecated in version 0.11.' % (
 
229
            t.put_multi.im_class.__module__, t.put_multi.im_class.__name__,
 
230
            t.put_multi.__name__)
 
231
        self.callDeprecated([deprecation_msg],
 
232
            t.put_multi, [('mmode644', StringIO('text\n'))], mode=0644)
222
233
        self.assertTransportMode(t, 'mmode644', 0644)
223
234
 
224
235
        # The default permissions should be based on the current umask
225
236
        umask = osutils.get_umask()
226
 
        t.put('nomode', StringIO('test text\n'), mode=None)
 
237
        t.put_file('nomode', StringIO('test text\n'), mode=None)
227
238
        self.assertTransportMode(t, 'nomode', 0666 & ~umask)
228
239
        
229
240
    def test_put_bytes_permissions(self):