Started BasicFileStorage tests. test_basic_storage__resolve_filepath() done.
Also switched to using assert_raises, which is only sane!
This commit is contained in:
parent
e579cf544d
commit
17e7093e4b
@ -15,6 +15,11 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
import os
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
from nose.tools import assert_raises
|
||||||
|
|
||||||
from mediagoblin import storage
|
from mediagoblin import storage
|
||||||
|
|
||||||
|
|
||||||
@ -31,11 +36,50 @@ def test_clean_listy_filepath():
|
|||||||
assert storage.clean_listy_filepath(
|
assert storage.clean_listy_filepath(
|
||||||
['../../../etc/', 'passwd']) == expected
|
['../../../etc/', 'passwd']) == expected
|
||||||
|
|
||||||
try:
|
assert_raises(
|
||||||
storage.clean_listy_filepath(
|
storage.InvalidFilepath,
|
||||||
['../../', 'linooks.jpg'])
|
storage.clean_listy_filepath,
|
||||||
except storage.InvalidFilepath:
|
['../../', 'linooks.jpg'])
|
||||||
# Yes, this error should be raise
|
|
||||||
pass
|
|
||||||
else:
|
##########################
|
||||||
assert "success" == "failboat"
|
# Basic file storage tests
|
||||||
|
##########################
|
||||||
|
|
||||||
|
def get_tmp_filestorage(mount_url=None):
|
||||||
|
tmpdir = tempfile.mkdtemp()
|
||||||
|
this_storage = storage.BasicFileStorage(tmpdir, mount_url)
|
||||||
|
return tmpdir, this_storage
|
||||||
|
|
||||||
|
|
||||||
|
def test_basic_storage__resolve_filepath():
|
||||||
|
tmpdir, this_storage = get_tmp_filestorage()
|
||||||
|
|
||||||
|
result = this_storage._resolve_filepath(['dir1', 'dir2', 'filename.jpg'])
|
||||||
|
assert result == os.path.join(
|
||||||
|
tmpdir, 'dir1/dir2/filename.jpg')
|
||||||
|
|
||||||
|
result = this_storage._resolve_filepath(['../../etc/', 'passwd'])
|
||||||
|
assert result == os.path.join(
|
||||||
|
tmpdir, 'etc/passwd')
|
||||||
|
|
||||||
|
assert_raises(
|
||||||
|
storage.InvalidFilepath,
|
||||||
|
this_storage._resolve_filepath,
|
||||||
|
['../../', 'etc', 'passwd'])
|
||||||
|
|
||||||
|
|
||||||
|
def test_basic_storage_file_exists():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def test_basic_storage_get_file():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def test_basic_storage_delete_file():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def test_basic_storage_url_for_file():
|
||||||
|
pass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user