1"""VM-free gate for corpus/recycle-purge: OneNote 2010 reads a recycle bin Snowbound purged
2as empty, without repairing it."""
3
4import pathlib
5import unittest
6import xml.etree.ElementTree as ElementTree
7
8ROOT = pathlib.Path(__file__).resolve().parents[1] / "corpus" / "recycle-purge"
9ONE = "{http://schemas.microsoft.com/office/onenote/2010/onenote}"
10
11
12class RecyclePurge(unittest.TestCase):
13 def test_cold_read_finds_the_bin_empty(self):
14 notebook = ElementTree.parse(ROOT / "cold" / "hierarchy.xml").getroot()
15 bin_ = next(
16 group
17 for group in notebook.iter(ONE + "SectionGroup")
18 if group.get("isRecycleBin") == "true"
19 )
20 sections = list(bin_.iter(ONE + "Section"))
21 self.assertEqual([section.get("name") for section in sections], ["Deleted Pages"])
22 self.assertEqual(list(sections[0].iter(ONE + "Page")), [])
23 kept = [section.get("name") for section in notebook.findall(ONE + "Section")]
24 self.assertEqual(kept, ["New Section 1"])
25 self.assertFalse((ROOT / "candidate" / "OneNote_RecycleBin" / "Old.one").exists())
26
27
28if __name__ == "__main__":
29 unittest.main()