aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrett Smith <brettcsmith@brettcsmith.org>2012-03-20 22:30:57 -0400
committerBrett Smith <brettcsmith@brettcsmith.org>2012-03-20 22:30:57 -0400
commitc0e87ec9d2ff79c98372fe802ac64e35d7e30853 (patch)
tree521258977cdc50f1f26cbd64052af18a36dd6fdf
parent77445d13adbceab08681d77d736c5226a6cbf4db (diff)
downloadmediagoblin-c0e87ec9d2ff79c98372fe802ac64e35d7e30853.tar.lz
mediagoblin-c0e87ec9d2ff79c98372fe802ac64e35d7e30853.tar.xz
mediagoblin-c0e87ec9d2ff79c98372fe802ac64e35d7e30853.zip
Refactor normal upload tests.
This is nice because it means we do *all* the normal sanity tests for *all* the normal uploads. check_url() can be used in other tests too.
-rw-r--r--mediagoblin/tests/test_submission.py44
1 files changed, 17 insertions, 27 deletions
diff --git a/mediagoblin/tests/test_submission.py b/mediagoblin/tests/test_submission.py
index 65c3bac7..70093b58 100644
--- a/mediagoblin/tests/test_submission.py
+++ b/mediagoblin/tests/test_submission.py
@@ -89,37 +89,27 @@ class TestSubmission:
response, form = self.do_post({'title': 'test title'}, *FORM_CONTEXT)
assert form.file.errors == [u'You must provide a file.']
-
- def test_normal_uploads(self):
- # Test JPG
- # --------
- response, context = self.do_post({'title': 'Normal upload 1'},
- do_follow=True,
- **self.upload_data(GOOD_JPG))
- assert_equal(
- urlparse.urlsplit(response.location)[2],
- '/u/chris/')
- assert template.TEMPLATE_TEST_CONTEXT.has_key(
- 'mediagoblin/user_pages/user.html')
-
+ def check_url(self, response, path):
+ assert_equal(urlparse.urlsplit(response.location)[2], path)
+
+ def check_normal_upload(self, title, filename):
+ response, context = self.do_post({'title': title}, do_follow=True,
+ **self.upload_data(filename))
+ self.check_url(response, '/u/{0}/'.format(self.test_user.username))
+ assert_true(context.has_key('mediagoblin/user_pages/user.html'))
# Make sure the media view is at least reachable, logged in...
- self.test_app.get('/u/chris/m/normal-upload-1/')
+ url = '/u/{0}/m/{1}/'.format(self.test_user.username,
+ title.lower().replace(' ', '-'))
+ self.test_app.get(url)
# ... and logged out too.
self.logout()
- self.test_app.get('/u/chris/m/normal-upload-1/')
- # Log back in for the remaining tests.
- self.login()
+ self.test_app.get(url)
- # Test PNG
- # --------
- response, context = self.do_post({'title': 'Normal upload 2'},
- do_follow=True,
- **self.upload_data(GOOD_PNG))
- assert_equal(
- urlparse.urlsplit(response.location)[2],
- '/u/chris/')
- assert template.TEMPLATE_TEST_CONTEXT.has_key(
- 'mediagoblin/user_pages/user.html')
+ def test_normal_jpg(self):
+ self.check_normal_upload('Normal upload 1', GOOD_JPG)
+
+ def test_normal_png(self):
+ self.check_normal_upload('Normal upload 2', GOOD_PNG)
def check_media(self, request, find_data, count=None):
media = request.db.MediaEntry.find(find_data)