Esempio n. 1
0
 def test_get_keyword(self):
     expected = ['Asylum Games', 'Banjooli', 'Mutinies', 'Polis']
     rm = ReportModel(Reports.asylum)
     keywords = rm.getKeywords()
     #print keywords
     self.assertEqual(len(expected), len(keywords))
     self.assertEqual(expected, keywords)
Esempio n. 2
0
 def test_get_keyword_dont_return_special_keys(self):
     expected = ['Polis', 'Banjooli', 'Mutinies', 'Asylum Games']
     report = {'Asylum Games':[], 'Banjooli':[], 'Mutinies':[], 'Polis':[], 'title':"", 'report_date':""}
     rm = ReportModel(report)
     keywords = rm.getKeywords()
     print keywords
     self.assertEqual(len(expected), len(keywords))
     self.assertEqual(expected, keywords)
Esempio n. 3
0
    def _generateStats(self, report_request, report_json):
        result = ReportStats()
        report_obj = ReportModel(report_json)
        for key in report_request['keywords']:
            for thread_obj in report_obj.threads_in(key):
                result.inc_threads()
                result.inc_msgs( thread_obj.msg_count() )

        return result
Esempio n. 4
0
    def generateStats(self, reportDescription, report_json):
        count = 0
        report_obj = ReportModel(report_json)
        for key in reportDescription['keywords']:
            count += report_obj.count_entries_in(key)

        result = Text(u"Resultados encontrados: " + str(count))
        #result.addText(u"Mensajes encontrados: " + str(msgs))
        return result
Esempio n. 5
0
    def generateStats(self, reportDescription, report_json):
        threads = 0
        msgs = 0
        report_obj = ReportModel(report_json)
        for key in reportDescription['keywords']:
            for thread_obj in report_obj.threads_in(key):
                threads += 1
                msgs += thread_obj.msg_count()

        result = Text(u"Asuntos encontrados: " + str(threads))
        result.addText(u"Mensajes encontrados: " + str(msgs))
        return result
Esempio n. 6
0
 def _filter_threads_using_year(self, reportDescription, report, year):
     """ Previous method filter messages of a thread.
         this method filters therads in a report.
         Don't word modifyng directy the report so I retorn the JSon again
     """
     year_int = int(year)
     query = ReportQueryModel(reportDescription)
     report_obj = ReportModel(report)
     for kword in query.keywords():
         threats = list()
         for threadobj in report_obj.threads_in(kword):
             #print kword, ":", threadobj.year_last_msg(), ", ", year_int, threadobj.link()
             if threadobj.year_last_msg() > year_int:
                 threats.append(threadobj.json())
         report_obj.set_threads_to(kword, threats)
     return report_obj.json()
Esempio n. 7
0
 def test_json_is_the_same_that_creation(self):
     rm = ReportModel(Reports.asylum)
     self.assertEqual(Reports.asylum, rm.json())