This commit is contained in:
csj
2026-09-16 21:02:44 +08:00
parent 7fea2063aa
commit 45b6f693d6
11 changed files with 320 additions and 86 deletions
+34 -6
View File
@@ -34,21 +34,49 @@ class ExportTests(unittest.TestCase):
destination = self.root / 'test.pptx'
export_ppt(self.state, destination, True)
deck = Presentation(destination)
self.assertEqual(len(deck.slides), 3)
self.assertEqual(deck.slide_width, 1280 * 12700)
self.assertTrue(any('实物照片' in shape.text for shape in deck.slides[2].shapes if shape.has_text_frame))
self.assertEqual(len(deck.slides), 1)
self.assertEqual(deck.slide_width, 720 * 12700)
self.assertEqual(deck.slide_height, 960 * 12700)
self.assertTrue(any('实物照片' in shape.text for shape in deck.slides[0].shapes if shape.has_text_frame))
def test_travel_category_excludes_photo(self):
def test_travel_category_also_reserves_photo_area(self):
self.state['matches'][0]['category'] = '交通'
destination = self.root / 'test.pptx'
export_ppt(self.state, destination, False)
self.assertEqual(len(Presentation(destination).slides), 2)
deck = Presentation(destination)
self.assertEqual(len(deck.slides), 1)
self.assertTrue(any(shape.name == 'manual-photo-area' for shape in deck.slides[0].shapes))
def test_complex_payment_pagination(self):
self.state['matches'][0]['payments'] *= 5
destination = self.root / 'test.pptx'
export_ppt(self.state, destination, True)
self.assertEqual(len(Presentation(destination).slides), 5)
self.assertEqual(len(Presentation(destination).slides), 3)
def test_ppt_layouts_are_portrait_and_reserve_photo_page(self):
scenarios = []
single = copy.deepcopy(self.state['matches'][0])
scenarios.append(single)
one_invoice_many_payments = copy.deepcopy(single)
one_invoice_many_payments['payments'] *= 3
scenarios.append(one_invoice_many_payments)
many_invoices_many_payments = copy.deepcopy(single)
many_invoices_many_payments['invoices'] *= 2
many_invoices_many_payments['payments'] *= 2
scenarios.append(many_invoices_many_payments)
for index, match in enumerate(scenarios):
destination = self.root / f'layout-{index}.pptx'
export_ppt(dict(matches=[match]), destination, True)
deck = Presentation(destination)
self.assertEqual(deck.slide_width, 720 * 12700)
self.assertEqual(deck.slide_height, 960 * 12700)
self.assertGreaterEqual(len(deck.slides), 1)
self.assertTrue(any(
any('实物照片粘贴区' in shape.text for shape in slide.shapes if shape.has_text_frame)
for slide in deck.slides
))
self.assertEqual(sum(shape.name.startswith('payment-') for slide in deck.slides for shape in slide.shapes),
len(match['payments']))
def test_expense_template_values_and_formulas(self):
destination = self.root / 'expense.xlsx'