132
132
t = self.get_transport()
134
134
if t.is_readonly():
135
self.assertRaises(TransportNotPossible,
136
t.put, 'a', StringIO('some text for a\n'))
139
t.put('a', StringIO('some text for a\n'))
140
self.failUnless(t.has('a'))
141
self.check_transport_contents('some text for a\n', t, 'a')
142
# Make sure 'has' is updated
143
self.assertEqual(list(t.has_multi(['a', 'b', 'c', 'd', 'e'])),
144
[True, False, False, False, False])
145
# Put also replaces contents
137
deprecation_msg = '%s.%s.%s was deprecated in version 0.11.' % (
138
t.put.im_class.__module__, t.put.im_class.__name__,
140
self.callDeprecated([deprecation_msg],
141
t.put, 'a', 'string\ncontents\n')
142
self.check_transport_contents('string\ncontents\n', t, 'a')
144
self.callDeprecated([deprecation_msg],
145
t.put, 'b', StringIO('file-like\ncontents\n'))
146
self.check_transport_contents('file-like\ncontents\n', t, 'b')
148
def test_put_multi(self):
149
t = self.get_transport()
146
153
self.assertEqual(t.put_multi([('a', StringIO('new\ncontents for\na\n')),
147
154
('d', StringIO('contents\nfor d\n'))]),
149
self.assertEqual(list(t.has_multi(['a', 'b', 'c', 'd', 'e'])),
150
[True, False, False, True, False])
156
self.assertEqual(list(t.has_multi(['a', 'b', 'c', 'd'])),
157
[True, False, False, True])
151
158
self.check_transport_contents('new\ncontents for\na\n', t, 'a')
152
159
self.check_transport_contents('contents\nfor d\n', t, 'd')
158
165
self.check_transport_contents('diff\ncontents for\na\n', t, 'a')
159
166
self.check_transport_contents('another contents\nfor d\n', t, 'd')
168
def test_put_file(self):
169
t = self.get_transport()
172
self.assertRaises(TransportNotPossible,
173
t.put_file, 'a', StringIO('some text for a\n'))
176
t.put_file('a', StringIO('some text for a\n'))
177
self.failUnless(t.has('a'))
178
self.check_transport_contents('some text for a\n', t, 'a')
179
# Put also replaces contents
180
t.put_file('a', StringIO('new\ncontents for\na\n'))
181
self.check_transport_contents('new\ncontents for\na\n', t, 'a')
161
182
self.assertRaises(NoSuchFile,
162
183
t.put, 'path/doesnt/exist/c', StringIO('contents'))