def test_write(self, changelog_md): w = writer.MdWriter(changelog_md) w.add_version("0.0.1") w.add_section("header", {"1": "line1", "2": "line2", "3": "line3"}) w.write() assert changelog_md.read_text() == """# Changelog
def test_add_section_line_with_issue_link(self, changelog_md): w = writer.MdWriter(changelog_md, issue_link="http://url/issues/{issue_ref}") w._add_section_line("line", "1") assert w.content == ["- line [[#1](http://url/issues/1)]"]
def test_write_dry_run_doesnt_write_to_file(self, changelog_md): w = writer.MdWriter(changelog_md, dry_run=True) w.add_version("0.0.1") w.add_section("header", {"1": "line1", "2": "line2", "3": "line3"}) w.write() assert changelog_md.read_text() == """# Changelog\n"""
def test_write_with_existing_content(self, changelog_md): changelog_md.write_text("""# Changelog ## 0.0.1 ### header - line1 - line2 - line3 """) w = writer.MdWriter(changelog_md) w.add_version("0.0.2") w.add_section("header", {"4": "line4", "5": "line5", "6": "line6"}) w.write() assert changelog_md.read_text() == """# Changelog
def test_init_stores_existing_changelog(self, changelog_md): changelog_md.write_text("""# Changelog ## 0.0.1 ### header - line1 - line2 - line3 """) w = writer.MdWriter(changelog_md) assert w.existing == [ "## 0.0.1", "", "### header", "", "- line1", "- line2", "- line3", "", ]
def test_add_section_line(self, changelog_md): w = writer.MdWriter(changelog_md) w._add_section_line("line", "1") assert w.content == ["- line [#1]"]
def test_add_section_header(self, changelog_md): w = writer.MdWriter(changelog_md) w._add_section_header("header") assert w.content == ["### header", ""]
def test_add_version(self, changelog_md): w = writer.MdWriter(changelog_md) w._add_version("0.0.0") assert w.content == ["## 0.0.0", ""]
def test_init_no_existing_entries(self, changelog_md): w = writer.MdWriter(changelog_md) assert w.existing == []
def test_init_dry_run(self, changelog_md): w = writer.MdWriter(changelog_md, dry_run=True) assert w.content == [] assert w.dry_run is True
def test_init(self, changelog_md): w = writer.MdWriter(changelog_md) assert w.content == [] assert w.dry_run is False