def test_totals(self): from crawl import MentionCounter self.api_fixture([ _mention(1315051701, 'english', 'twitter', 'neutral'), _mention(1315051704, 'german', 'twitter', 'positive'), _mention(1315051708, 'english', 'facebook', 'negative'), ]) counter = MentionCounter('python', timedelta(days=1)) bucket = counter.count(date(2011, 9, 3)).values()[0] self.assertEqual(bucket[None], 3)
def test_crawl_one_day_one_call(self): from crawl import MentionCounter self.api_fixture([ _mention(1315051701, 'english', 'twitter', 'neutral'), _mention(1315051704, 'german', 'twitter', 'positive'), _mention(1315051708, 'english', 'facebook', 'negative'), ]) counter = MentionCounter('python', timedelta(days=1)) bucket = counter.count(date(2011, 9, 3)).values()[0] self.assertEqual(bucket['language', 'english'], 2) self.assertEqual(bucket['language', 'german'], 1) self.assertEqual(bucket['generator', 'twitter'], 2) self.assertEqual(bucket['generator', 'facebook'], 1) self.assertEqual(bucket['sentiment', 'negative'], 1) self.assertEqual(bucket['sentiment', 'neutral'], 1) self.assertEqual(bucket['sentiment', 'positive'], 1)