class TestHoroReport(unittest.TestCase): def setUp(self): self.report = HoroReport() self.input = HoroInput() self.input.load('input.xlsx') content = [['Section']] self.report.loadDataSource('AstroReport_Content.xlsx') self.content = self.report.loadContentUsing(self.input.getReport('Sheet1')) def testSanity(self): self.assertEqual(2, len(self.content)) def testLoadSectionCorrectly(self): self.assertEqual(u'Tình yêu', self.content[0]['section_title']) def testLoadParagraph(self): paragraphs = self.content[0]['paragraph'] self.assertEqual(3, len(paragraphs)) self.assertEqual(u'Cung Mọc ở Bạch Dương', paragraphs[0]['title']) def testLoadNonExistParagraph(self): paragraph = self.report.getParagraphFromSource('1.1', '1.3') self.assertEqual('Cannot found', paragraph['title']) def testLoadNonExistSheet(self): paragraph = self.report.getParagraphFromSource('1111', '1,3') self.assertEqual('Cannot found', paragraph['title'])
def testIntegrationGen(self): input = HoroInput() input.load('sample.xlsx') report = HoroReport() report.loadDataSource('AstroReport_Content.xlsx') content = report.loadContentUsing(input.getReport('Sheet1')) doc = HoroDocument() doc.generate(content) doc.save('sample.docx')
def setUp(self): self.input = HoroInput() self.input.load('input.xlsx') self.data = [['Section', u'Tình yêu'], [1.1, 1], [2.1, 3]] self.content = [{'Section': u'Tình yêu'}, {'Paragraph': {'sheet': 1.1, 'value': 1}}]
def setUp(self): self.report = HoroReport() self.input = HoroInput() self.input.load('input.xlsx') content = [['Section']] self.report.loadDataSource('AstroReport_Content.xlsx') self.content = self.report.loadContentUsing(self.input.getReport('Sheet1'))
class TestHoroInput(unittest.TestCase): def setUp(self): self.input = HoroInput() self.input.load('input.xlsx') self.data = [['Section', u'Tình yêu'], [1.1, 1], [2.1, 3]] self.content = [{'Section': u'Tình yêu'}, {'Paragraph': {'sheet': 1.1, 'value': 1}}] def testCleanInput(self): actual = self.input.clean(self.data) self.assertEqual(self.content[0], actual[0]) self.assertDictEqual(self.content[1], actual[1]) def testSanity(self): self.assertEqual(['Sheet1'], self.input.getReportNames()) def testGetParagraphInfo(self): input = self.input.getReport('Sheet1') self.assertEqual('Section', input[0]['type']) self.assertEqual(u'Tình yêu', input[0]['value']) self.assertEqual('Paragraph', input[1]['type']) self.assertDictEqual({'sheet': 1.1, 'value': 1}, input[1]['value'])