aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tests
diff options
context:
space:
mode:
Diffstat (limited to 'mediagoblin/tests')
-rw-r--r--mediagoblin/tests/test_mgoblin_app.ini10
-rw-r--r--mediagoblin/tests/test_storage.py21
-rw-r--r--mediagoblin/tests/test_submission.py59
3 files changed, 52 insertions, 38 deletions
diff --git a/mediagoblin/tests/test_mgoblin_app.ini b/mediagoblin/tests/test_mgoblin_app.ini
index 7716e9ca..0109d751 100644
--- a/mediagoblin/tests/test_mgoblin_app.ini
+++ b/mediagoblin/tests/test_mgoblin_app.ini
@@ -1,7 +1,4 @@
[mediagoblin]
-queuestore_base_dir = %(here)s/test_user_dev/media/queue
-publicstore_base_dir = %(here)s/test_user_dev/media/public
-publicstore_base_url = /mgoblin_media/
direct_remote_path = /mgoblin_static/
email_sender_address = "notice@mediagoblin.example.org"
email_debug_mode = true
@@ -15,5 +12,12 @@ tags_max_length = 50
# mediagoblin.init.celery.from_celery
celery_setup_elsewhere = true
+[storage:publicstore]
+base_dir = %(here)s/test_user_dev/media/public
+base_url = /mgoblin_media/
+
+[storage:queuestore]
+queuestore_base_dir = %(here)s/test_user_dev/media/queue
+
[celery]
celery_always_eager = true
diff --git a/mediagoblin/tests/test_storage.py b/mediagoblin/tests/test_storage.py
index 1800c29d..45cb35c1 100644
--- a/mediagoblin/tests/test_storage.py
+++ b/mediagoblin/tests/test_storage.py
@@ -60,23 +60,20 @@ class FakeRemoteStorage(storage.BasicFileStorage):
def test_storage_system_from_config():
this_storage = storage.storage_system_from_config(
- {'somestorage_base_url': 'http://example.org/moodia/',
- 'somestorage_base_dir': '/tmp/',
- 'somestorage_garbage_arg': 'garbage_arg',
- 'garbage_arg': 'trash'},
- 'somestorage')
+ {'base_url': 'http://example.org/moodia/',
+ 'base_dir': '/tmp/',
+ 'garbage_arg': 'garbage_arg',
+ 'garbage_arg': 'trash'})
assert this_storage.base_url == 'http://example.org/moodia/'
assert this_storage.base_dir == '/tmp/'
assert this_storage.__class__ is storage.BasicFileStorage
this_storage = storage.storage_system_from_config(
- {'somestorage_foobie': 'eiboof',
- 'somestorage_blech': 'hcelb',
- 'somestorage_garbage_arg': 'garbage_arg',
- 'garbage_arg': 'trash',
- 'somestorage_storage_class':
- 'mediagoblin.tests.test_storage:FakeStorageSystem'},
- 'somestorage')
+ {'foobie': 'eiboof',
+ 'blech': 'hcelb',
+ 'garbage_arg': 'garbage_arg',
+ 'storage_class':
+ 'mediagoblin.tests.test_storage:FakeStorageSystem'})
assert this_storage.foobie == 'eiboof'
assert this_storage.blech == 'hcelb'
assert this_storage.__class__ is FakeStorageSystem
diff --git a/mediagoblin/tests/test_submission.py b/mediagoblin/tests/test_submission.py
index a7248255..9ae129cd 100644
--- a/mediagoblin/tests/test_submission.py
+++ b/mediagoblin/tests/test_submission.py
@@ -156,7 +156,7 @@ class TestSubmission:
util.clear_test_template_context()
response = self.test_app.post(
'/submit/', {
- 'title': 'Malicious Upload 2'
+ 'title': 'Malicious Upload 1'
}, upload_files=[(
'file', EVIL_FILE)])
@@ -164,33 +164,46 @@ class TestSubmission:
form = context['submit_form']
assert form.file.errors == ['The file doesn\'t seem to be an image!']
- # NOTE: The following 2 tests will fail. These can be uncommented
- # after http://bugs.foocorp.net/issues/324 is resolved and
- # bad files are handled properly.
+ # NOTE: The following 2 tests will ultimately fail, but they
+ # *will* pass the initial form submission step. Instead,
+ # they'll be caught as failures during the processing step.
# Test non-supported file with .jpg extension
# -------------------------------------------
- #util.clear_test_template_context()
- #response = self.test_app.post(
- # '/submit/', {
- # 'title': 'Malicious Upload 2'
- # }, upload_files=[(
- # 'file', EVIL_JPG)])
+ util.clear_test_template_context()
+ response = self.test_app.post(
+ '/submit/', {
+ 'title': 'Malicious Upload 2'
+ }, upload_files=[(
+ 'file', EVIL_JPG)])
+ response.follow()
+ assert_equal(
+ urlparse.urlsplit(response.location)[2],
+ '/u/chris/')
- #context = util.TEMPLATE_TEST_CONTEXT['mediagoblin/submit/start.html']
- #form = context['submit_form']
- #assert form.file.errors == ['The file doesn\'t seem to be an image!']
+ entry = mg_globals.database.MediaEntry.find_one(
+ {'title': 'Malicious Upload 2'})
+ assert_equal(entry['state'], 'failed')
+ assert_equal(
+ entry['fail_error'],
+ u'mediagoblin.process_media.errors:BadMediaFail')
# Test non-supported file with .png extension
# -------------------------------------------
- #util.clear_test_template_context()
- #response = self.test_app.post(
- # '/submit/', {
- # 'title': 'Malicious Upload 3'
- # }, upload_files=[(
- # 'file', EVIL_PNG)])
-
- #context = util.TEMPLATE_TEST_CONTEXT['mediagoblin/submit/start.html']
- #form = context['submit_form']
- #assert form.file.errors == ['The file doesn\'t seem to be an image!']
+ util.clear_test_template_context()
+ response = self.test_app.post(
+ '/submit/', {
+ 'title': 'Malicious Upload 3'
+ }, upload_files=[(
+ 'file', EVIL_PNG)])
+ response.follow()
+ assert_equal(
+ urlparse.urlsplit(response.location)[2],
+ '/u/chris/')
+ entry = mg_globals.database.MediaEntry.find_one(
+ {'title': 'Malicious Upload 3'})
+ assert_equal(entry['state'], 'failed')
+ assert_equal(
+ entry['fail_error'],
+ u'mediagoblin.process_media.errors:BadMediaFail')