aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsk Solem <askh@opera.com>2009-11-11 19:06:09 +0100
committerAsk Solem <askh@opera.com>2009-11-11 19:06:09 +0100
commit664e5be33310e182751c9c6a1561f0b5317ebde6 (patch)
tree0d3b5c44ea06053e9c6fa1cc343d135a13baed6d
parent53e8165b77f4686353a78a77a089a9bef3620387 (diff)
parentdb86053e5b5f767988fe91b991078d54cb59c7d3 (diff)
downloadchishop-664e5be33310e182751c9c6a1561f0b5317ebde6.tar.bz2
chishop-664e5be33310e182751c9c6a1561f0b5317ebde6.tar.xz
chishop-664e5be33310e182751c9c6a1561f0b5317ebde6.zip
Merge branch 'brosner/master'
Conflicts: djangopypi/views.py
-rw-r--r--djangopypi/tests.py12
-rw-r--r--djangopypi/views.py6
2 files changed, 14 insertions, 4 deletions
diff --git a/djangopypi/tests.py b/djangopypi/tests.py
index c6ebce2..2d8c305 100644
--- a/djangopypi/tests.py
+++ b/djangopypi/tests.py
@@ -1,6 +1,6 @@
1import unittest 1import unittest
2import StringIO 2import StringIO
3from djangopypi.views import parse_weird_post_data 3from djangopypi.views import parse_distutils_request
4 4
5def create_post_data(action): 5def create_post_data(action):
6 data = { 6 data = {
@@ -67,12 +67,20 @@ def create_request(data):
67 return body.getvalue() 67 return body.getvalue()
68 68
69 69
70class MockRequest(object):
71
72 def __init__(self, raw_post_data):
73 self.raw_post_data = raw_post_data
74 self.META = {}
75
76
70class TestParseWeirdPostData(unittest.TestCase): 77class TestParseWeirdPostData(unittest.TestCase):
71 78
72 def test_weird_post_data(self): 79 def test_weird_post_data(self):
73 data = create_post_data("submit") 80 data = create_post_data("submit")
74 raw_post_data = create_request(data) 81 raw_post_data = create_request(data)
75 post, files = parse_weird_post_data(raw_post_data) 82 post, files = parse_distutils_request(MockRequest(raw_post_data))
83 print("post: %s files: %s" % (post, files))
76 self.assertTrue(post) 84 self.assertTrue(post)
77 85
78 for key in post.keys(): 86 for key in post.keys():
diff --git a/djangopypi/views.py b/djangopypi/views.py
index 597598f..5fc2fec 100644
--- a/djangopypi/views.py
+++ b/djangopypi/views.py
@@ -15,12 +15,14 @@ from django.utils.datastructures import MultiValueDict
15from django.utils.translation import ugettext_lazy as _ 15from django.utils.translation import ugettext_lazy as _
16from django.core.files.uploadedfile import SimpleUploadedFile 16from django.core.files.uploadedfile import SimpleUploadedFile
17from django.contrib.auth import authenticate, login 17from django.contrib.auth import authenticate, login
18
18from registration.backends import get_backend 19from registration.backends import get_backend
19from registration.forms import RegistrationForm 20from registration.forms import RegistrationForm
20 21
21from djangopypi.models import Project, Classifier, Release, UPLOAD_TO 22from djangopypi.models import Project, Classifier, Release, UPLOAD_TO
22from djangopypi.forms import ProjectForm, ReleaseForm 23from djangopypi.forms import ProjectForm, ReleaseForm
23from djangopypi.http import HttpResponseNotImplemented, HttpResponseUnauthorized 24from djangopypi.http import HttpResponseUnauthorized
25from djangopypi.http import HttpResponseNotImplemented
24from djangopypi.utils import decode_fs 26from djangopypi.utils import decode_fs
25 27
26 28
@@ -142,7 +144,7 @@ ACTIONS = {
142 144
143def simple(request, template_name="djangopypi/simple.html"): 145def simple(request, template_name="djangopypi/simple.html"):
144 if request.method == "POST": 146 if request.method == "POST":
145 post_data, files = parse_distutils_request(request.raw_post_data) 147 post_data, files = parse_distutils_request(request)
146 action_name = post_data.get(":action") 148 action_name = post_data.get(":action")
147 if action_name not in ACTIONS: 149 if action_name not in ACTIONS:
148 return HttpResponseNotImplemented( 150 return HttpResponseNotImplemented(