Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
make sure we don't try to delete the field twice (Bug 805149)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarekziade committed Oct 24, 2012
1 parent 17b4d5b commit e339986
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mkt/stats/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def handle_kwargs(q, field, kwargs, join_field=None):
del(kwargs[field])

# We are using the join field to filter so get rid of the plain one.
if join_field:
if join_field and field in kwargs:
del(kwargs[field])

return q
10 changes: 9 additions & 1 deletion mkt/stats/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import amo.tests
from market.models import Refund, Price
from mkt.stats import tasks
from mkt.stats.search import cut
from mkt.stats.search import cut, handle_kwargs
from mkt.inapp_pay.models import InappConfig, InappPayment
from stats.models import Contribution
from users.models import UserProfile
Expand Down Expand Up @@ -509,3 +509,11 @@ def test_basic(self):
eq_(cut(1), Decimal(str(.7)))
eq_(cut(10), Decimal(str(7)))
eq_(cut(33), Decimal(str(23.10)))

def test_remove_kwargs(self):
q = object()
field = 'field'
join_field = 'join'
kwargs = {'field': None}
res = handle_kwargs(q, field, kwargs, join_field)
self.assertEqual(res.children, [('field__in', ['', None])])

0 comments on commit e339986

Please sign in to comment.