This commit is contained in:
Jeff Balogh 2010-04-09 20:36:00 -07:00
Родитель 0b9a494480
Коммит 683faca981
11 изменённых файлов: 25 добавлений и 26 удалений

Просмотреть файл

@ -22,7 +22,7 @@ options.render_to_response = django_to_jinja
sites.render_to_response = django_to_jinja
def jinja_for_django(template_name, context={}, **kw):
def jinja_for_django(template_name, context=None, **kw):
"""
If you want to use some built in logic (or a contrib app) but need to
override the templates to work with Jinja, replace the object's
@ -30,6 +30,8 @@ def jinja_for_django(template_name, context={}, **kw):
template through Django's functions. An example can be found in the users
app.
"""
if context is None:
context = {}
context_instance = kw.pop('context_instance')
request = context_instance['request']
for d in context_instance.dicts:

Просмотреть файл

@ -11,7 +11,8 @@ class TestRedirects(test.TestCase):
def test_utf8(self):
"""Without proper unicode handling this will fail."""
response = self.client.get(u'/api/1.5/search/ツールバー', follow=True)
response = self.client.get(u'/api/1.5/search/ツールバー',
follow=True)
# Sphinx will be off so let's just test that it redirects.
eq_(response.redirect_chain[0][1], 301)

Просмотреть файл

@ -90,10 +90,10 @@ def extract_filters(term, kwargs):
(term, category) = extract_from_query(term, 'category', '\w+', kwargs)
if category and 'app' in kwargs:
if not isinstance(category, int):
if not isinstance(category, int):
category = get_category_id(category, kwargs['app'])
metas['category'] = category
metas['category'] = category
(term, tag) = extract_from_query(term, 'tag', '\w+', kwargs)
@ -496,7 +496,7 @@ class Client(object):
try:
addons.append(Addon.objects.get(pk=key))
except Addon.DoesNotExist:
log.warn(u'%d: Result for %s refers to non-existant '
log.warn(u'%d: Result for %s refers to non-existent '
'addon: %d' % (self.id, term, key))
return ResultSet(addons, min(self.total_found, SPHINX_HARD_LIMIT),

Просмотреть файл

@ -130,11 +130,11 @@ def SearchForm(request):
d = self.cleaned_data
# Set some defaults
if 'appid' not in d or not d['appid']:
if not d.get('appid'):
d['appid'] = request.APP.id
if 'cat' in d:
if d['cat'].find(',') != -1:
if ',' in d['cat']:
(d['atype'], d['cat']) = map(int, d['cat'].split(','))
elif d['cat'] == 'all':
d['cat'] = None
@ -150,7 +150,7 @@ def SearchForm(request):
Does not remove cleaned_data if there are errors.
"""
self._errors = ErrorDict()
if not self.is_bound: # Stop further processing.
if not self.is_bound: # Stop further processing.
return
self.cleaned_data = {}
# If the form is permitted to be empty, and none of the form data
@ -160,7 +160,6 @@ def SearchForm(request):
self._clean_fields()
self._clean_form()
d = request.GET.copy()
return _SearchForm(d)

Просмотреть файл

@ -7,7 +7,7 @@
<div class="listing-header">
<p class="notfound">
{% if settings.DEBUG %}
Consider starting the search deamon!
Consider starting the search daemon!
{% else %}
{{ _('Search is temporarily unavailable.') }}
{% endif %}

Просмотреть файл

@ -8,7 +8,6 @@ import time
import urllib
from django.test import TestCase, client
from django.core.management import call_command
from django.utils import translation
import mock
@ -18,17 +17,15 @@ from mock import Mock
from pyquery import PyQuery as pq
import test_utils
import amo.helpers
import amo
from amo.urlresolvers import reverse
from amo.tests.test_helpers import render
from manage import settings
from search import forms, views
import search.helpers
from search.utils import start_sphinx, stop_sphinx, reindex, convert_version
from search.client import (Client as SearchClient, SearchError,
get_category_id, extract_from_query)
from addons.models import Addon, Category
from applications.models import AppVersion
from tags.models import Tag
@ -45,8 +42,8 @@ def test_convert_version():
return 0
v = ['1.9.0a1pre', '1.9.0a1', '1.9.1.b5', '1.9.1.b5', '1.9.1pre', \
'1.9.1', '1.9.0']
v = ['1.9.0a1pre', '1.9.0a1', '1.9.1.b5', '1.9.1.b5', '1.9.1pre',
'1.9.1', '1.9.0']
eq_(c(v[0], v[1]), -1)
eq_(c(v[1], v[2]), -1)
@ -74,7 +71,7 @@ def test_parse_bad_type():
c.get("/en-US/firefox/api/1.2/search/firebug%20type:dict")
except KeyError:
assert False, ("We should not throw a KeyError just because we had a "
"nonexistant addon type.")
"nonexistent addon type.")
class SphinxTestCase(test_utils.TransactionTestCase):
@ -345,10 +342,13 @@ class FrontendSearchTest(SphinxTestCase):
def test_sort_bad(self):
"Test that a bad sort value won't bring the system down."
resp = self.get_response(sort='yermom')
self.get_response(sort='yermom')
def test_non_existant_tag(self):
"If you are searching for a tag that doesn't exist we shouldn't return any results."
def test_non_existent_tag(self):
"""
If you are searching for a tag that doesn't exist we shouldn't return
any results.
"""
resp = self.get_response(tag='stockholmsyndrome')
doc = pq(resp.content)
eq_(doc('.item').length, 0)

Просмотреть файл

@ -2,7 +2,6 @@ from collections import defaultdict
from datetime import timedelta, datetime
import time
from django import http
from django.http import HttpResponseRedirect
import jingo

Просмотреть файл

@ -1,6 +1,5 @@
from django.contrib.auth.models import User
import access
from .models import UserProfile

Просмотреть файл

@ -41,7 +41,7 @@ class UserDeleteForm(forms.Form):
def __init__(self, *args, **kwargs):
self.request = kwargs.pop('request', None)
return super(UserDeleteForm, self).__init__(*args, **kwargs)
super(UserDeleteForm, self).__init__(*args, **kwargs)
def clean_password(self):
data = self.cleaned_data
@ -118,7 +118,7 @@ class UserEditForm(UserRegisterForm):
def __init__(self, *args, **kwargs):
self.request = kwargs.pop('request', None)
return super(UserEditForm, self).__init__(*args, **kwargs)
super(UserEditForm, self).__init__(*args, **kwargs)
class Meta:
model = models.UserProfile

Просмотреть файл

@ -154,7 +154,6 @@ class TestUserEditForm(UserFormBase):
'password': 'new',
'password2': 'new', }
r = self.client.post('/en-US/firefox/users/edit', data, follow=True)
print r.content
self.assertContains(r, "Profile Updated")

@ -1 +1 @@
Subproject commit 8f71123af68ca5ce3ff1bf75c02e2cebf4905728
Subproject commit 894cbfe05d9acf8a367529cf8ae8fb55b05f3447