Beispiel #1
0
class TestReportEntriesModel(unittest.TestCase):

    def setUp(self):
        self.model = ReportEntriesModel()

    def test_to_json_empty_with_title_and_date(self):
        self.model.set_title("Demo")
        self.model.set_report_date("Demo date")
        json = self.model.json()
        self.assertEqual(json, {'title': "Demo", 'report_date': "Demo date"})

    def test_to_json_empty_with_defailt_title_and_date(self):
        json = self.model.json()
        self.assertEqual(json, {'title': "No title", 'report_date': "No date"})

    def test_to_json_with_thead_and_blog(self):
        thread = ThreadModel({'title':"Demo T"})
        blog = BlogEntry({'title': "Demo B"})
        self.model.add_entry("1", thread)
        self.model.add_entry("2", blog)

        json = self.model.json()
        #self.assertEqual(json, {'title': "", 'report_date': ""})
        self.assertEqual(json['1'], [{'title': "Demo T"}])
        self.assertEqual(json['2'], [{'title': "Demo B"}])
Beispiel #2
0
def transtale_report_into_threads(report_query, report):
    new_report = ReportEntriesModel()
    for kword in report_query['keywords']:
        for thread in report[kword]:
            new_report.add_entry(kword, ThreadModel(thread))
    return new_report