Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_download_stream(self):
self.client.write('foo', 'hello')
with temppath() as tpath:
stdout = sys.stdout
try:
with open(tpath, 'wb') as writer:
sys.stdout = writer
main(
['download', 'foo', '-', '--silent', '--threads', '1'],
self.client
)
finally:
sys.stdout = stdout
with open(tpath) as reader:
eq_(reader.read(), 'hello')
def test_upload_force(self):
self.client.write('bar', 'hey')
main(
['upload', self.dpath, 'bar', '--silent', '--threads', '1', '--force'],
self.client
)
with temppath() as tpath:
self.client.download('bar', tpath)
self._dircmp(tpath)
def test_download_force(self):
self.client.write('foo', 'hey')
with temppath() as tpath:
with open(tpath, 'w'):
pass
main(
['download', 'foo', tpath, '--silent', '--force', '--threads', '1'],
self.client
)
with open(tpath) as reader:
eq_(reader.read(), 'hey')
def test_upload_overwrite(self):
self.client.write('bar', 'hey')
main(
['upload', self.dpath, 'bar', '--silent', '--threads', '1'],
self.client
)
def test_download_stream_multiple_files(self):
self.client.upload('foo', self.dpath)
main(
['download', 'foo', '-', '--silent', '--threads', '1'],
self.client
)
def test_upload_append(self):
with temppath() as tpath:
with open(tpath, 'w') as writer:
writer.write('hey')
main(['upload', tpath, 'bar', '--silent', '--threads', '1'], self.client)
main(
['upload', tpath, 'bar', '--silent', '--threads', '1', '--append'],
self.client
)
with self.client.read('bar') as reader:
eq_(reader.read(), b'heyhey')
def test_upload(self):
main(
['upload', self.dpath, 'bar', '--silent', '--threads', '1'],
self.client
)
with temppath() as tpath:
self.client.download('bar', tpath)
self._dircmp(tpath)
def test_download_overwrite(self):
self.client.upload('foo', self.dpath)
with temppath() as tpath:
with open(tpath, 'w'):
pass
main(
['download', 'foo', tpath, '--silent', '--threads', '1'],
self.client
)
self._dircmp(tpath)
def test_upload_append_folder(self):
with temppath() as tpath:
main(['upload', self.dpath, '--silent', '--append'], self.client)
def test_download(self):
self.client.upload('foo', self.dpath)
with temppath() as tpath:
main(
['download', 'foo', tpath, '--silent', '--threads', '1'],
self.client
)
self._dircmp(tpath)