1"""VM-free gate for corpus/default-font: OneNote 2010 reads the editor's new text and title
2in the Default font, colour included, as the quick styles it writes itself."""
3
4import pathlib
5import unittest
6import xml.etree.ElementTree as ElementTree
7
8ROOT = pathlib.Path(__file__).resolve().parents[1] / "corpus" / "default-font"
9ONE = "{http://schemas.microsoft.com/office/onenote/2010/onenote}"
10
11
12class DefaultFont(unittest.TestCase):
13 def test_cold_read_keeps_the_default_font_styles(self):
14 page = ElementTree.parse(ROOT / "cold" / "page.xml").getroot()
15 styles = {
16 style.get("index"): (
17 style.get("name"),
18 style.get("font"),
19 style.get("fontSize"),
20 style.get("fontColor"),
21 )
22 for style in page.iter(ONE + "QuickStyleDef")
23 }
24 self.assertIn(("PageTitle", "Georgia", "17.0", "#0070C0"), styles.values())
25 bodies = [
26 element
27 for outline in page.iter(ONE + "Outline")
28 for element in outline.iter(ONE + "OE")
29 ]
30 self.assertEqual(len(bodies), 2)
31 for body in bodies:
32 self.assertEqual(styles[body.get("quickStyleIndex")], ("p", "Georgia", "14.0", "#0070C0"))
33 self.assertIsNone(body.find(ONE + "T").get("style"))
34
35
36if __name__ == "__main__":
37 unittest.main()