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