diff options
author | Aaron Williamson <aaron@copiesofcopies.org> | 2012-01-17 00:59:21 -0500 |
---|---|---|
committer | Aaron Williamson <aaron@copiesofcopies.org> | 2012-01-17 00:59:21 -0500 |
commit | 99a270e95298b248a77b07203ab3921078bd7906 (patch) | |
tree | 34711abf27ab7a614c92842b456bf74ec3d5d5fb /mediagoblin/tests/test_storage.py | |
parent | 25b48323a86a1036112f2f33c889d5d12d5dee9c (diff) | |
parent | 8c7701f9f1653cf4038143cfb7a497ae21edf108 (diff) | |
download | mediagoblin-99a270e95298b248a77b07203ab3921078bd7906.tar.lz mediagoblin-99a270e95298b248a77b07203ab3921078bd7906.tar.xz mediagoblin-99a270e95298b248a77b07203ab3921078bd7906.zip |
Merged changes with upstream
Diffstat (limited to 'mediagoblin/tests/test_storage.py')
-rw-r--r-- | mediagoblin/tests/test_storage.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/mediagoblin/tests/test_storage.py b/mediagoblin/tests/test_storage.py index 46ecb2ec..eab4d032 100644 --- a/mediagoblin/tests/test_storage.py +++ b/mediagoblin/tests/test_storage.py @@ -57,6 +57,10 @@ class FakeRemoteStorage(storage.filestorage.BasicFileStorage): # should force copying to the workbench local_storage = False + def copy_local_to_storage(self, *args, **kwargs): + return storage.StorageInterface.copy_local_to_storage( + self, *args, **kwargs) + def test_storage_system_from_config(): this_storage = storage.storage_system_from_config( @@ -252,3 +256,26 @@ def test_basic_storage_copy_locally(): this_storage.copy_locally(filepath, new_file_dest) assert file(new_file_dest).read() == 'Testing this file' + + +def _test_copy_local_to_storage_works(tmpdir, this_storage): + local_filename = tempfile.mktemp() + with file(local_filename, 'w') as tmpfile: + tmpfile.write('haha') + + this_storage.copy_local_to_storage( + local_filename, ['dir1', 'dir2', 'copiedto.txt']) + + assert file( + os.path.join(tmpdir, 'dir1/dir2/copiedto.txt'), + 'r').read() == 'haha' + + +def test_basic_storage_copy_local_to_storage(): + tmpdir, this_storage = get_tmp_filestorage() + _test_copy_local_to_storage_works(tmpdir, this_storage) + + +def test_general_storage_copy_local_to_storage(): + tmpdir, this_storage = get_tmp_filestorage(fake_remote=True) + _test_copy_local_to_storage_works(tmpdir, this_storage) |