1"""VM-free gate for corpus/section-color: OneNote 2010 reads each section the app coloured, None
2included, and the notebook's colour as its own menus set them."""
3
4import pathlib
5import unittest
6import xml.etree.ElementTree as ElementTree
7
8ROOT = pathlib.Path(__file__).resolve().parents[1] / "corpus" / "section-color"
9ONE = "{http://schemas.microsoft.com/office/onenote/2010/onenote}"
10
11
12class SectionColor(unittest.TestCase):
13 def test_cold_read_keeps_every_colour(self):
14 menu = [
15 line.rsplit(" ", 1)
16 for line in (ROOT / "native" / "colors.txt").read_text().splitlines()
17 ]
18 hierarchy = ElementTree.parse(ROOT / "cold" / "read" / "hierarchy.xml").getroot()
19 notebook = next(hierarchy.iter(ONE + "Notebook"))
20 self.assertEqual(notebook.get("color"), "#4DBCCA")
21 sections = {
22 section.get("name"): section.get("color")
23 for section in notebook.iter(ONE + "Section")
24 }
25 self.assertEqual(sections.pop("New Section 1"), "#8AA8E4")
26 self.assertEqual(sections, dict(menu))
27
28
29if __name__ == "__main__":
30 unittest.main()