def test_merge_stats_no_empty(self): stats_acum = ReportStats() stats_acum.inc_threads() stats_acum.inc_msgs(3) stats_acum.inc_blogs(3) stats = ReportStats() stats.inc_threads() stats.inc_msgs(2) stats.inc_blogs(4) stats_acum.merge(stats) self.assertEqual(str(stats_acum), "2, 5, 7") self.assertEqual(str(stats), "1, 2, 4")
def build_report(self, report_request, report_obj, stats): """ This mehtods search for ocurrences of the key words y reporr reest in the information from PlanetaLudico blogs and tores them in report updatind stats object """ report_result = self._report_builder.build_report(report_request) new_stats = ReportStats() for keyword in report_request['keywords']: #print report_result[keyword] for entry in report_result[keyword]: report_obj.add_entry(keyword, BlogEntry(entry)) new_stats.inc_blogs(len(report_result[keyword])) # Merge stats stats.merge(new_stats)
def test_blog_increment(self): stats = ReportStats() stats.inc_blogs() self.assertEqual(stats.json(), {'threads': '0', 'msgs': '0', 'blogs': '1'}) stats.inc_blogs(2) self.assertEqual(stats.json(), {'threads': '0', 'msgs': '0', 'blogs': '3'})