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"}])
def _create_empty_report(self, report_request): report = ReportEntriesModel() if 'name' in report_request: report.set_title("Result for report " + report_request['name']) else: report.set_title("Result for report.") now = datetime.now() report.set_report_date( str(datetime.date(now)) +", " + str(now.hour) + ":" + str(now.minute) ) return report