diff --git a/tests/test_org.py b/tests/test_org.py index 61b1b2e..96e0181 100644 --- a/tests/test_org.py +++ b/tests/test_org.py @@ -866,7 +866,47 @@ class TestSerde(unittest.TestCase): self.assertEqual(dumps(doc), orig) - def test_update_reparse(self): + def test_update_reparse_same_structure(self): + with open(os.path.join(DIR, "01-simple.org")) as f: + doc = load(f) + + hl = doc.getTopHeadlines()[0] + ex = HL( + "First level", + props=[ + ("ID", "01-simple-first-level-id"), + ("CREATED", DT(2020, 1, 1, 1, 1)), + ], + content=" First level content\n", + children=[ + HL( + "Second level", + props=[("ID", "01-simple-second-level-id")], + content="\n Second level content\n", + children=[ + HL( + "Third level", + props=[("ID", "01-simple-third-level-id")], + content="\n Third level content\n", + ) + ], + ) + ], + ) + + # Ground check + ex.assert_matches(self, hl) + + # Update + lines = list(doc.dump_headline(hl, recursive=False)) + assert lines[0].startswith('* ') # Title, skip it + content = '\n'.join(lines[1:]) + hl.update_raw_contents(content) + + # Check after update + ex.assert_matches(self, hl, accept_trailing_whitespace_changes=True) + + def test_update_reparse_same_values(self): with open(os.path.join(DIR, "13-update-reparse-test.org")) as f: doc = load(f)