diff options
author | Ask Solem <askh@opera.com> | 2009-11-11 19:06:09 +0100 |
---|---|---|
committer | Ask Solem <askh@opera.com> | 2009-11-11 19:06:09 +0100 |
commit | 664e5be33310e182751c9c6a1561f0b5317ebde6 (patch) | |
tree | 0d3b5c44ea06053e9c6fa1cc343d135a13baed6d | |
parent | 53e8165b77f4686353a78a77a089a9bef3620387 (diff) | |
parent | db86053e5b5f767988fe91b991078d54cb59c7d3 (diff) | |
download | chishop-664e5be33310e182751c9c6a1561f0b5317ebde6.tar.bz2 chishop-664e5be33310e182751c9c6a1561f0b5317ebde6.tar.xz chishop-664e5be33310e182751c9c6a1561f0b5317ebde6.zip |
Merge branch 'brosner/master'
Conflicts:
djangopypi/views.py
-rw-r--r-- | djangopypi/tests.py | 12 | ||||
-rw-r--r-- | djangopypi/views.py | 6 |
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 @@ | |||
1 | import unittest | 1 | import unittest |
2 | import StringIO | 2 | import StringIO |
3 | from djangopypi.views import parse_weird_post_data | 3 | from djangopypi.views import parse_distutils_request |
4 | 4 | ||
5 | def create_post_data(action): | 5 | def 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 | ||
70 | class MockRequest(object): | ||
71 | |||
72 | def __init__(self, raw_post_data): | ||
73 | self.raw_post_data = raw_post_data | ||
74 | self.META = {} | ||
75 | |||
76 | |||
70 | class TestParseWeirdPostData(unittest.TestCase): | 77 | class 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 | |||
15 | from django.utils.translation import ugettext_lazy as _ | 15 | from django.utils.translation import ugettext_lazy as _ |
16 | from django.core.files.uploadedfile import SimpleUploadedFile | 16 | from django.core.files.uploadedfile import SimpleUploadedFile |
17 | from django.contrib.auth import authenticate, login | 17 | from django.contrib.auth import authenticate, login |
18 | |||
18 | from registration.backends import get_backend | 19 | from registration.backends import get_backend |
19 | from registration.forms import RegistrationForm | 20 | from registration.forms import RegistrationForm |
20 | 21 | ||
21 | from djangopypi.models import Project, Classifier, Release, UPLOAD_TO | 22 | from djangopypi.models import Project, Classifier, Release, UPLOAD_TO |
22 | from djangopypi.forms import ProjectForm, ReleaseForm | 23 | from djangopypi.forms import ProjectForm, ReleaseForm |
23 | from djangopypi.http import HttpResponseNotImplemented, HttpResponseUnauthorized | 24 | from djangopypi.http import HttpResponseUnauthorized |
25 | from djangopypi.http import HttpResponseNotImplemented | ||
24 | from djangopypi.utils import decode_fs | 26 | from djangopypi.utils import decode_fs |
25 | 27 | ||
26 | 28 | ||
@@ -142,7 +144,7 @@ ACTIONS = { | |||
142 | 144 | ||
143 | def simple(request, template_name="djangopypi/simple.html"): | 145 | def 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( |