MCPcopy
hub / github.com/epinna/tplmap / test_upload

Method test_upload

tests/basetest.py:135–165  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

133 self.assertEqual('', obj.read('/dev/null'))
134
135 def test_upload(self):
136
137 obj, data = self._get_detection_obj_data(self.url % '')
138 self.assertEqual(data, self.expected_data)
139
140 if not EXTRA_UPLOAD:
141 return
142
143 remote_temp_path = '/tmp/tplmap_%s.tmp' % rand.randstr_n(10)
144 # Send long binary
145 data = open('/bin/ls', 'rb').read()
146 obj.write(data, remote_temp_path)
147 self.assertEqual(obj.md5(remote_temp_path), strings.md5(data))
148 obj.execute('rm %s' % (remote_temp_path))
149
150 remote_temp_path = '/tmp/tplmap_%s.tmp' % rand.randstr_n(10)
151 # Send short ASCII data, without removing it
152 data = 'SHORT ASCII DATA'
153 obj.write(data, remote_temp_path)
154 self.assertEqual(obj.md5(remote_temp_path), strings.md5(data))
155
156 # Try to append data without --force-overwrite and re-check the previous md5
157 obj.write('APPENDED DATA', remote_temp_path)
158 self.assertEqual(obj.md5(remote_temp_path), strings.md5(data))
159
160 # Now set --force-overwrite and rewrite new data on the same file
161 obj.channel.args['force_overwrite'] = True
162 data = 'NEW DATA'
163 obj.write(data, remote_temp_path)
164 self.assertEqual(obj.md5(remote_temp_path), strings.md5(data))
165 obj.execute('rm %s' % (remote_temp_path))
166
167 def test_upload_blind(self):
168

Callers

nothing calls this directly

Calls 5

readMethod · 0.80
writeMethod · 0.80
md5Method · 0.80
executeMethod · 0.80

Tested by

no test coverage detected