PEP8 and pyflakes fixes for customercare.

This commit is contained in:
Fred Wenzel 2010-11-19 12:57:32 -08:00
Родитель 7158f9c7fe
Коммит 9c9515e2b2
4 изменённых файлов: 33 добавлений и 19 удалений

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

@ -29,8 +29,8 @@ def collect_tweets():
"""Collect new tweets about Firefox."""
search_options = {
'q': 'firefox',
'rpp': settings.CC_TWEETS_PERPAGE, # Items per page.
'result_type': 'recent', # Retrieve tweets by date.
'rpp': settings.CC_TWEETS_PERPAGE, # Items per page.
'result_type': 'recent', # Retrieve tweets by date.
}
# If we already have some tweets, collect nothing older than what we have.

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

@ -6,6 +6,7 @@
"locale": "en",
"tweet_id": 25308717656,
"raw_json": "{\"iso_language_code\": \"en\", \"text\": \"Kudos to Brizzly - the application is much less buggy lately. No more double tweet boxes. No more extra UI garbage on my Firefox window.\", \"created_at\": \"Thu, 23 Sep 2010 13:52:40 +0000\", \"profile_image_url\": \"http://a1.twimg.com/profile_images/876200349/tool-belt_Logo_normal.jpg\", \"source\": \"<a href="http://www.brizzly.com" rel="nofollow">Brizzly</a>\", \"from_user\": \"rossgk\", \"from_user_id\": 150857, \"to_user_id\": null, \"geo\": null, \"id\": 25308717656, \"metadata\": {\"result_type\": \"recent\"}}",
"reply_to": null,
"created": "2010-09-23 13:52:40"
}
},
@ -16,6 +17,7 @@
"locale": "en",
"tweet_id": 25308845620,
"raw_json": "{\"iso_language_code\": \"en\", \"text\": \"Firefox\\u3000chrome\\u306b\\u4e57\\u308a\\u63db\\u3048\\u308b\\u304b\\u601d\\u6848\\u4e2d #firefox\", \"created_at\": \"Thu, 23 Sep 2010 13:54:12 +0000\", \"profile_image_url\": \"http://a1.twimg.com/profile_images/1041604705/188292_8256_normal.jpg\", \"source\": \"<a href="http://www.echofon.com/" rel="nofollow">Echofon</a>\", \"from_user\": \"ikd_fine\", \"from_user_id\": 129866568, \"to_user_id\": null, \"geo\": null, \"id\": 25308845620, \"metadata\": {\"result_type\": \"recent\"}}",
"reply_to": null,
"created": "2010-09-23 13:54:12"
}
},
@ -26,6 +28,7 @@
"locale": "en",
"tweet_id": 25308851981,
"raw_json": "{\"iso_language_code\": \"en\", \"text\": \"We're noticing a lot of #Flash Errors in #Firefox in the last few days. Including the AS3 Scroll Bars on my site. Too many updates FTL.\", \"created_at\": \"Thu, 23 Sep 2010 13:54:17 +0000\", \"profile_image_url\": \"http://a3.twimg.com/profile_images/1037516415/IA_100x100_avtr_normal.png\", \"source\": \"<a href="http://twitter.com/">web</a>\", \"from_user\": \"runtime_iA\", \"from_user_id\": 130011759, \"to_user_id\": null, \"geo\": null, \"id\": 25308851981, \"metadata\": {\"result_type\": \"recent\"}}",
"reply_to": null,
"created": "2010-09-23 13:54:17"
}
},
@ -36,6 +39,7 @@
"locale": "en",
"tweet_id": 25308865789,
"raw_json": "{\"iso_language_code\": \"en\", \"text\": \"Ok so it looks good in chrome, firefox and safari. \\nIt even seems to look ok in IE. (163 visitors to MDN using IE last month)\", \"created_at\": \"Thu, 23 Sep 2010 13:54:27 +0000\", \"profile_image_url\": \"http://a0.twimg.com/profile_images/533310872/twitterscotty_normal.jpg\", \"source\": \"<a href="http://kiwi-app.net" rel="nofollow">kiwi</a>\", \"from_user\": \"macdevnet\", \"from_user_id\": 28772, \"to_user_id\": null, \"geo\": null, \"id\": 25308865789, \"metadata\": {\"result_type\": \"recent\"}}",
"reply_to": null,
"created": "2010-09-23 13:54:27"
}
},
@ -46,6 +50,7 @@
"locale": "en",
"tweet_id": 25308906635,
"raw_json": "{\"iso_language_code\": \"en\", \"text\": \"I'm still partial to Firefox, but IE9 Beta is FAST!\", \"created_at\": \"Thu, 23 Sep 2010 13:54:56 +0000\", \"profile_image_url\": \"http://a2.twimg.com/profile_images/1120347326/cole_normal.jpg\", \"source\": \"<a href="http://www.tweetdeck.com" rel="nofollow">TweetDeck</a>\", \"from_user\": \"Kid_Zer0\", \"from_user_id\": 130442244, \"to_user_id\": null, \"geo\": null, \"id\": 25308906635, \"metadata\": {\"result_type\": \"recent\"}}",
"reply_to": null,
"created": "2010-09-23 13:54:56"
}
},
@ -56,6 +61,7 @@
"locale": "en",
"tweet_id": 25308913992,
"raw_json": "{\"iso_language_code\": \"en\", \"text\": \"Hey guys...am thinking of switching from IE to Firefox. yay or nay?\", \"created_at\": \"Thu, 23 Sep 2010 13:55:02 +0000\", \"profile_image_url\": \"http://a2.twimg.com/profile_images/151180126/Lucid_normal.jpg\", \"source\": \"<a href="http://twitter.com/">web</a>\", \"from_user\": \"LucidLilith\", \"from_user_id\": 1884444, \"to_user_id\": null, \"geo\": null, \"id\": 25308913992, \"metadata\": {\"result_type\": \"recent\"}}",
"reply_to": null,
"created": "2010-09-23 13:55:02"
}
},
@ -66,6 +72,7 @@
"locale": "en",
"tweet_id": 25309157145,
"raw_json": "{\"iso_language_code\": \"en\", \"text\": \"Just changed my firefox theme for the first time in months and months. I like my new one :)\", \"created_at\": \"Thu, 23 Sep 2010 13:57:58 +0000\", \"profile_image_url\": \"http://a3.twimg.com/profile_images/1093204039/Me_and_claw_normal.jpg\", \"source\": \"<a href="http://twitter.com/">web</a>\", \"from_user\": \"jamesgrant17\", \"from_user_id\": 4403196, \"to_user_id\": null, \"geo\": null, \"id\": 25309157145, \"metadata\": {\"result_type\": \"recent\"}}",
"reply_to": null,
"created": "2010-09-23 13:57:58"
}
},
@ -76,6 +83,7 @@
"locale": "en",
"tweet_id": 25309168521,
"raw_json": "{\"iso_language_code\": \"en\", \"text\": \"Looks like with #Firefox "Tabs on top" & "Hide Menubar" add-ons you can get same amount of browser space that you have in Chrome. Yay!\", \"created_at\": \"Thu, 23 Sep 2010 13:58:06 +0000\", \"profile_image_url\": \"http://a1.twimg.com/profile_images/1117809237/cool_cat_normal.jpg\", \"source\": \"<a href="http://www.tweetdeck.com" rel="nofollow">TweetDeck</a>\", \"from_user\": \"__jimcasey__\", \"from_user_id\": 142651388, \"to_user_id\": null, \"geo\": null, \"id\": 25309168521, \"metadata\": {\"result_type\": \"recent\"}}",
"reply_to": null,
"created": "2010-09-23 13:58:06"
}
},
@ -86,6 +94,7 @@
"locale": "en",
"tweet_id": 25309381333,
"raw_json": "{\"iso_language_code\": \"en\", \"text\": \"On this day in 2002, first public version of Mozilla Firefox ('Phoenix 0.1') is released. Jose Canseco becomes first member of 40-40 club.\", \"created_at\": \"Thu, 23 Sep 2010 14:00:35 +0000\", \"profile_image_url\": \"http://a3.twimg.com/profile_images/407391555/643797910_fgRus-S_normal.jpg\", \"source\": \"<a href="http://www.tweetdeck.com" rel="nofollow">TweetDeck</a>\", \"from_user\": \"jasonboche\", \"from_user_id\": 1644275, \"to_user_id\": null, \"geo\": null, \"id\": 25309381333, \"metadata\": {\"result_type\": \"recent\"}}",
"reply_to": null,
"created": "2010-09-23 14:00:35"
}
}

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

@ -1,28 +1,32 @@
from datetime import datetime
import json
import copy
from nose.tools import eq_
from customercare.cron import _filter_tweet
from sumo.tests import TestCase
class TwitterCronTestCase(TestCase):
tweet_json = """{
"profile_image_url":"http://a3.twimg.com/profile_images/688562959/jspeis_gmail.com_852af0c8__1__normal.jpg",
"created_at":"Mon, 25 Oct 2010 18:12:20 +0000",
"from_user":"jspeis",
"metadata": {"result_type":"recent"},
"to_user_id":null,
"text":"giving the Firefox 4 beta a whirl",
"id":28713868836,
"from_user_id":2385258,
"geo":null,
"iso_language_code":"en",
"source":"<a href="http://twitter.com/">web</a>"}
"""
tweet_template = {
"profile_image_url": (
"http://a3.twimg.com/profile_images/688562959/"
"jspeis_gmail.com_852af0c8__1__normal.jpg"),
"created_at": "Mon, 25 Oct 2010 18:12:20 +0000",
"from_user": "jspeis",
"metadata": {
"result_type": "recent",
},
"to_user_id": None,
"text": "giving the Firefox 4 beta a whirl",
"id": 28713868836,
"from_user_id": 2385258,
"geo": None,
"iso_language_code": "en",
"source": "<a href="http://twitter.com/">web</a>"
}
def setUp(self):
self.tweet = json.loads(self.tweet_json)
self.tweet = copy.deepcopy(self.tweet_template)
def test_unfiltered(self):
"""Do not filter tweets without a reason."""

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

@ -105,7 +105,8 @@ def twitter_post(request):
raw_tweet_data = {
'id': status['id'],
'text': status['text'],
'created_at': formatdate(time.mktime(status['created_at'].timetuple())),
'created_at': formatdate(time.mktime(
status['created_at'].timetuple())),
'iso_language_code': author['lang'],
'from_user_id': author['id'],
'from_user': author['screen_name'],