예제 #1
0
 def test_append_lines(self):
     body = RecordBody((
         RecordSection("removed", "- removed"),
         RecordSection("added", "- added"),
         RecordSection("fixed", ""),
     ))
     body.append_lines("removed", "\n- new removed")
     assert body.get_section("removed").body == "- removed\n- new removed"
     body.append_lines("added", "\n")
     assert body.get_section("added").body == "- added"
예제 #2
0
 def test_append_to_all(self):
     body = RecordBody((
         RecordSection("removed", "- removed"),
         RecordSection("added", "- added"),
         RecordSection("fixed", ""),
     ))
     body.append_to_all(" postfix")
     assert body.get_section("removed").body == "- removed postfix"
     assert body.get_section("added").body == "- added postfix"
     assert body.get_section("fixed").body == ""
     assert body.get_section("security").body == ""
예제 #3
0
 def test_get_section(self):
     body = RecordBody((
         RecordSection("removed", "- removed"),
         RecordSection("added", "- added"),
         RecordSection("fixed", ""),
     ))
     assert body.get_section("removed").body == "- removed"
     assert body.get_section("added").body == "- added"
     assert body.get_section("fixed").body == ""
     with pytest.raises(ValueError):
         body.get_section("unknown")
예제 #4
0
파일: record.py 프로젝트: vemel/logchange
 def _log_changes(self, old_body: RecordBody) -> None:
     for section_title in SECTION_TITLES:
         old_section = old_body.get_section(section_title)
         new_section = self.body.get_section(section_title)
         if new_section.body == old_section.body:
             continue
         if old_section.is_empty():
             if not new_section.is_empty():
                 self._logger.info(
                     f"{self.name} `{new_section.title}` section added")
         else:
             if new_section.is_empty():
                 self._logger.info(
                     f"{self.name} `{new_section.title}` section deleted")
             else:
                 self._logger.info(
                     f"{self.name} `{new_section.title}` section updated")