def test_add_version(self, monkeypatch, changelog): monkeypatch.setattr(writer.BaseWriter, "_add_version", mock.Mock()) w = writer.BaseWriter(changelog) w.add_version("0.0.0") assert w._add_version.call_args == mock.call("0.0.0")
def test_base_methods_not_implemented(self, changelog): w = writer.BaseWriter(changelog) with pytest.raises(NotImplementedError): w._add_section_header("header") with pytest.raises(NotImplementedError): w._add_section_line("description", "issue_ref") with pytest.raises(NotImplementedError): w._add_version("0.0.0")
def test_add_section(self, monkeypatch, changelog): monkeypatch.setattr(writer.BaseWriter, "_add_section_header", mock.Mock()) monkeypatch.setattr(writer.BaseWriter, "_add_section_line", mock.Mock()) w = writer.BaseWriter(changelog) w.add_section("header", {"1": "line1", "2": "line2", "3": "line3"}) assert w._add_section_header.call_args == mock.call("header") assert w._add_section_line.call_args_list == [ mock.call("line1", "1"), mock.call("line2", "2"), mock.call("line3", "3"), ]
def test_init_stores_existing_changelog(self, changelog): changelog.write_text(""" ## 0.0.1 ### header - line1 - line2 - line3 """) w = writer.BaseWriter(changelog) assert w.existing == [ "## 0.0.1", "", "### header", "", "- line1", "- line2", "- line3", "", ]
def test_content_as_str(self, changelog): w = writer.BaseWriter(changelog) w.content = ["line1", "line2", "line3"] assert str(w) == "line1\nline2\nline3"
def test_init_no_existing_entries(self, changelog): w = writer.BaseWriter(changelog) assert w.existing == []
def test_init_dry_run(self, changelog): w = writer.BaseWriter(changelog, dry_run=True) assert w.content == [] assert w.dry_run is True
def test_init(self, changelog): w = writer.BaseWriter(changelog) assert w.content == [] assert w.dry_run is False