def test_library_convert_name_not_found(options_gen: Callable) -> None: t = options_gen(name="notNAME") result = csv2docx.convert(t["data"], t["template"], t["name"], t["path"], t["delimiter"]) assert result
def test_library_convert_csv_wrong(options_gen: Callable) -> None: t = options_gen(data="non-existing.csv") result = csv2docx.convert(t["data"], t["template"], t["name"], t["path"], t["delimiter"]) assert result
def test_library_convert_wrong_delimiter(options_gen: Callable) -> None: t = options_gen(delimiter=",") with pytest.warns(UserWarning): result = csv2docx.convert(t["data"], t["template"], t["name"], t["path"], t["delimiter"]) assert result
def test_library_convert_nested_output(options_gen: Callable, tmp_path: Path) -> None: t = options_gen(path=tmp_path / "nested" / "output" / "folder") result = csv2docx.convert(t["data"], t["template"], t["name"], t["path"], t["delimiter"]) assert result
def test_library_convert_output_dir(options_gen: Callable, tmpdir: Path) -> None: """testing py.path.local object as output""" t = options_gen(path=tmpdir) result = csv2docx.convert(t["data"], t["template"], t["name"], t["path"], t["delimiter"]) assert result
def test_empty_csv_rows(tmp_path: Path, mocker: MockerFixture) -> None: """testing behaviour when .csv file has empty rows""" mocker.patch.object(MailMerge, "write") result = csv2docx.convert( "tests/data/example_emptyrow.csv", "tests/data/example.docx", "NAME", str(tmp_path), ";", ) assert result MailMerge.write.not_called()