[extensions-web] upload: Fix upload page, add tests
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] upload: Fix upload page, add tests
- Date: Sat, 3 Mar 2012 20:33:03 +0000 (UTC)
commit 3229b7852f31f52020888637b7a219bc5ab89560
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Sat Mar 3 15:32:54 2012 -0500
upload: Fix upload page, add tests
Turns out that any context manager that queries the database will
cause a transaction_manually view to fail. Par for the course, in
wacky Django land. Fix it by forcing a clean state after we've
rendered the view. Hack hack hack.
sweettooth/extensions/tests.py | 4 ++++
sweettooth/extensions/views.py | 12 +++++++++---
2 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/sweettooth/extensions/tests.py b/sweettooth/extensions/tests.py
index 87f6ce1..3a02e75 100644
--- a/sweettooth/extensions/tests.py
+++ b/sweettooth/extensions/tests.py
@@ -182,6 +182,10 @@ class UploadTest(BasicUserTestCase, TestCase):
gplv2_compliant=True,
tos_compliant=True), follow=True)
+ def test_upload_page_works(self):
+ response = self.client.get(reverse('extensions-upload-file'))
+ self.assertEquals(response.status_code, 200)
+
def test_upload_parsing(self):
response = self.upload_file('SimpleExtension')
extension = models.Extension.objects.get(uuid="test-extension mecheye net")
diff --git a/sweettooth/extensions/views.py b/sweettooth/extensions/views.py
index 6dafb5b..62c7676 100644
--- a/sweettooth/extensions/views.py
+++ b/sweettooth/extensions/views.py
@@ -415,6 +415,12 @@ def upload_file(request):
else:
form = UploadForm()
- return render(request, 'extensions/upload.html', dict(form=form,
- errors=errors,
- extra_debug=extra_debug))
+ # XXX - context managers may dirty the connection, so we need
+ # to force a clean state after this.
+ response = render(request, 'extensions/upload.html', dict(form=form,
+ errors=errors,
+ extra_debug=extra_debug))
+
+ transaction.set_clean()
+
+ return response
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]