diff options
author | vandersonmota <vanderson.mota@gmail.com> | 2009-12-18 17:59:57 -0200 |
---|---|---|
committer | vandersonmota <vanderson.mota@gmail.com> | 2009-12-18 17:59:57 -0200 |
commit | 7ebd1b87ee1d86407ac11e868c255a7613cedda3 (patch) | |
tree | 5ea09b14d328d2b668de703e0e4c430f75db344a | |
parent | ec281fafcaea5348675a205fbd399ad5b19a2180 (diff) | |
download | chishop-7ebd1b87ee1d86407ac11e868c255a7613cedda3.tar.bz2 chishop-7ebd1b87ee1d86407ac11e868c255a7613cedda3.tar.xz chishop-7ebd1b87ee1d86407ac11e868c255a7613cedda3.zip |
testsearch added
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | chishop/templates/djangopypi/search.html | 2 | ||||
-rw-r--r-- | chishop/templates/djangopypi/search_results.html | 4 | ||||
-rw-r--r-- | djangopypi/tests.py | 19 | ||||
-rw-r--r-- | djangopypi/views.py | 14 |
6 files changed, 31 insertions, 12 deletions
@@ -5,6 +5,7 @@ | |||
5 | *.sqlite-journal | 5 | *.sqlite-journal |
6 | settings_local.py | 6 | settings_local.py |
7 | .*.sw[po] | 7 | .*.sw[po] |
8 | *.kpf | ||
8 | dist/ | 9 | dist/ |
9 | *.egg-info | 10 | *.egg-info |
10 | doc/__build/* | 11 | doc/__build/* |
@@ -14,4 +15,4 @@ parts | |||
14 | eggs | 15 | eggs |
15 | bin | 16 | bin |
16 | developer-eggs | 17 | developer-eggs |
17 | downloads \ No newline at end of file | 18 | downloads |
@@ -11,7 +11,6 @@ PyPI feature replication | |||
11 | I'm not sure what the difference between a co-owner and maintainer is, | 11 | I'm not sure what the difference between a co-owner and maintainer is, |
12 | maybe it's just a label. | 12 | maybe it's just a label. |
13 | * Package author admin interface (submit, edit, view) | 13 | * Package author admin interface (submit, edit, view) |
14 | * Search | ||
15 | * Documentation upload | 14 | * Documentation upload |
16 | * Ratings | 15 | * Ratings |
17 | * Random Monty Python quotes :-) | 16 | * Random Monty Python quotes :-) |
diff --git a/chishop/templates/djangopypi/search.html b/chishop/templates/djangopypi/search.html index a5c882c..8269508 100644 --- a/chishop/templates/djangopypi/search.html +++ b/chishop/templates/djangopypi/search.html | |||
@@ -1,4 +1,4 @@ | |||
1 | <form action='search' method='post'> | 1 | <form action='search' method='post'> |
2 | <input type="text" name="search_value" id="search_value"> | 2 | <input type="text" name="search_term" id="search_term"> |
3 | <input type='submit' value=' Search '/> | 3 | <input type='submit' value=' Search '/> |
4 | </form> \ No newline at end of file | 4 | </form> \ No newline at end of file |
diff --git a/chishop/templates/djangopypi/search_results.html b/chishop/templates/djangopypi/search_results.html index c2139ad..dccf61f 100644 --- a/chishop/templates/djangopypi/search_results.html +++ b/chishop/templates/djangopypi/search_results.html | |||
@@ -3,8 +3,8 @@ | |||
3 | {% block bread_crumbs_1 %}›Search{% endblock %} | 3 | {% block bread_crumbs_1 %}›Search{% endblock %} |
4 | 4 | ||
5 | {% block content %} | 5 | {% block content %} |
6 | {% ifnotequal search_value ''%} | 6 | {% ifnotequal search_term ''%} |
7 | <h1>Index of Packages Matching '{{ search_value }}'</h1> | 7 | <h1>Index of Packages Matching '{{ search_term }}'</h1> |
8 | {% else %} | 8 | {% else %} |
9 | <h1>You need to supply a search term.</h1> | 9 | <h1>You need to supply a search term.</h1> |
10 | {% endifnotequal %} | 10 | {% endifnotequal %} |
diff --git a/djangopypi/tests.py b/djangopypi/tests.py index 2d8c305..4da4122 100644 --- a/djangopypi/tests.py +++ b/djangopypi/tests.py | |||
@@ -1,6 +1,10 @@ | |||
1 | import unittest | 1 | import unittest |
2 | import StringIO | 2 | import StringIO |
3 | from djangopypi.views import parse_distutils_request | 3 | from djangopypi.views import parse_distutils_request |
4 | from djangopypi.models import Project, Classifier | ||
5 | from django.test.client import Client | ||
6 | from django.core.urlresolvers import reverse | ||
7 | from django.contrib.auth.models import User | ||
4 | 8 | ||
5 | def create_post_data(action): | 9 | def create_post_data(action): |
6 | data = { | 10 | data = { |
@@ -88,3 +92,18 @@ class TestParseWeirdPostData(unittest.TestCase): | |||
88 | self.assertEquals(data[key], post.getlist(key)) | 92 | self.assertEquals(data[key], post.getlist(key)) |
89 | else: | 93 | else: |
90 | self.assertEquals(post[key], data[key]) | 94 | self.assertEquals(post[key], data[key]) |
95 | |||
96 | class TestSearch(unittest.TestCase): | ||
97 | |||
98 | def setUp(self): | ||
99 | data = create_post_data("submit") | ||
100 | dummy_user = User.objects.create(username='krill', password='12345', | ||
101 | email='krill@opera.com') | ||
102 | Project.objects.create(name=data['name'], license=data['license'], | ||
103 | summary=data["summary"], owner=dummy_user) | ||
104 | |||
105 | |||
106 | def testSearchForPackage(self): | ||
107 | client = Client() | ||
108 | response = client.post(reverse('djangopypi-search'), {'search_term': 'foo'}) | ||
109 | self.assertTrue("The quick brown fox jumps over the lazy dog." in response.content) | ||
diff --git a/djangopypi/views.py b/djangopypi/views.py index 0ac6dbc..7e2d0dc 100644 --- a/djangopypi/views.py +++ b/djangopypi/views.py | |||
@@ -230,27 +230,27 @@ def show_version(request, dist_name, version, | |||
230 | return render_to_response(template_name, context_instance=context) | 230 | return render_to_response(template_name, context_instance=context) |
231 | 231 | ||
232 | def search(request): | 232 | def search(request): |
233 | search_value = '' | 233 | search_term = '' |
234 | if request.method == 'POST': | 234 | if request.method == 'POST': |
235 | search_value = request.POST.get('search_value') | 235 | search_term = request.POST.get('search_term') |
236 | if search_value != '': | 236 | if search_term != '': |
237 | dists = Project.objects.filter(Q(name__contains=search_value) | Q(summary__contains=search_value)) | 237 | dists = Project.objects.filter(Q(name__contains=search_term) | Q(summary__contains=search_term)) |
238 | return render_to_response( | 238 | return render_to_response( |
239 | 'djangopypi/search_results.html', | 239 | 'djangopypi/search_results.html', |
240 | {'dists':dists,'search_value':search_value}, | 240 | {'dists':dists,'search_term':search_term}, |
241 | context_instance = RequestContext(request) | 241 | context_instance = RequestContext(request) |
242 | ) | 242 | ) |
243 | else: | 243 | else: |
244 | dists = Project.objects.all() | 244 | dists = Project.objects.all() |
245 | return render_to_response( | 245 | return render_to_response( |
246 | 'djangopypi/search_results.html', | 246 | 'djangopypi/search_results.html', |
247 | {'search_value':search_value}, | 247 | {'search_term':search_term}, |
248 | context_instance = RequestContext(request) | 248 | context_instance = RequestContext(request) |
249 | ) | 249 | ) |
250 | else: | 250 | else: |
251 | dists = Project.objects.all() | 251 | dists = Project.objects.all() |
252 | return render_to_response( | 252 | return render_to_response( |
253 | 'djangopypi/search_results.html', | 253 | 'djangopypi/search_results.html', |
254 | {'search_value':search_value}, | 254 | {'search_term':search_term}, |
255 | context_instance = RequestContext(request) | 255 | context_instance = RequestContext(request) |
256 | ) \ No newline at end of file | 256 | ) \ No newline at end of file |