Permalink
Browse files

Some cleanups.

  • Loading branch information...
1 parent cb4f309 commit 757cee241f5933bebb839b69622d59371546ce10 @mythmon mythmon committed Oct 30, 2012
Showing with 12 additions and 7 deletions.
  1. +3 −4 apps/api/cron.py
  2. +7 −2 apps/feedback/tests/test_feedback_utils.py
  3. +2 −1 apps/feedback/views.py
View
@@ -2,6 +2,7 @@
import csv
import os.path
import shutil
+import logging
from time import mktime
from django.conf import settings
@@ -39,8 +40,6 @@ def _split_queryset(qs):
start = 0
end = BUCKET_SIZE
while True:
- print start
-
split = qs[start:end]
if split:
yield split
@@ -59,7 +58,7 @@ def export_tsv():
"""
opinions_path = os.path.join(settings.TSV_EXPORT_DIR, 'opinions.tsv.bz2')
opinions_tmp = '%s_exporting' % opinions_path
- print 'Dumping all opinions into TSV file %s.' % opinions_path
+ log.info('Dumping all opinions into TSV file %s.', opinions_path)
opinions = Opinion.objects.order_by('id')
try:
@@ -87,4 +86,4 @@ def export_tsv():
finally:
outfile.close()
shutil.move(opinions_tmp, opinions_path)
- print 'All opinions dumped to disk.'
+ log.info('All opinions dumped to disk.')
@@ -61,7 +61,7 @@ def test_ua_parse():
'Browser-Anonymisierer 48771657', None), # bug 629687
)
- for pattern in patterns:
+ def test_ua_item(pattern):
parsed = ua_parse(pattern[0])
if pattern[1]:
eq_(parsed['browser'], pattern[1])
@@ -70,20 +70,25 @@ def test_ua_parse():
else:
assert parsed is None
+ for pattern in patterns:
+ yield test_ua_item, pattern
+
+
def test_detect_language():
"""Check Accept-Language matching for feedback submission."""
patterns = (
('en-us,en;q=0.7,de;q=0.8', 'en-US'),
('fr-FR,de-DE;q=0.5', 'fr'),
('zh, en-us;q=0.8, en;q=0.6', 'en-US'),
- ('German', ''), # invalid
+ ('German', ''), # invalid
)
for pattern in patterns:
req = http.HttpRequest()
req.META['HTTP_ACCEPT_LANGUAGE'] = pattern[0]
eq_(detect_language(req), pattern[1])
+
def test_smart_truncate():
"""Test text truncation on word boundaries."""
patterns = (
View
@@ -142,7 +142,8 @@ def save_opinion_from_form(request, type, ua, form):
_type=type,
url=form.cleaned_data.get('url') or '',
description=form.cleaned_data['description'],
- user_agent=ua, locale=locale,
+ user_agent=ua,
+ locale=locale,
manufacturer=form.cleaned_data['manufacturer'],
device=form.cleaned_data['device'])
opinion.save()

0 comments on commit 757cee2

Please sign in to comment.