151
151
if t.is_readonly():
153
self.assertEqual(t.put_multi([('a', StringIO('new\ncontents for\na\n')),
154
('d', StringIO('contents\nfor d\n'))]),
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'))]
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')
162
t.put_multi(iter([('a', StringIO('diff\ncontents for\na\n')),
163
('d', StringIO('another contents\nfor d\n'))])),
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'))])
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')
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'))
185
190
def test_put_bytes(self):
186
191
t = self.get_transport()
209
214
if not t._can_roundtrip_unix_modebits():
210
215
# Can't roundtrip, so no need to run this test
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)
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)
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)
229
240
def test_put_bytes_permissions(self):