mirror of https://github.com/eyhc1/rendercv.git
cli: fix relative input file paths (#95)
This commit is contained in:
parent
39e1f3ccec
commit
e739c10d24
|
@ -676,7 +676,7 @@ def cli_command_render(
|
||||||
"""Generate a $\\LaTeX$ CV from a YAML input file."""
|
"""Generate a $\\LaTeX$ CV from a YAML input file."""
|
||||||
welcome()
|
welcome()
|
||||||
|
|
||||||
input_file_path = pathlib.Path(input_file_name)
|
input_file_path = pathlib.Path(input_file_name).absolute()
|
||||||
output_directory = pathlib.Path.cwd() / output_folder_name
|
output_directory = pathlib.Path.cwd() / output_folder_name
|
||||||
|
|
||||||
# change the current working directory to the input file's directory (because
|
# change the current working directory to the input file's directory (because
|
||||||
|
|
|
@ -3,6 +3,7 @@ import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from datetime import date as Date
|
from datetime import date as Date
|
||||||
|
import pathlib
|
||||||
|
|
||||||
import pydantic
|
import pydantic
|
||||||
import ruamel.yaml
|
import ruamel.yaml
|
||||||
|
@ -240,6 +241,34 @@ def test_render_command(tmp_path, input_file_path):
|
||||||
assert "Your CV is rendered!" in result.stdout
|
assert "Your CV is rendered!" in result.stdout
|
||||||
|
|
||||||
|
|
||||||
|
def test_render_command_with_relative_input_file_path(tmp_path, input_file_path):
|
||||||
|
new_folder = tmp_path / "another_folder"
|
||||||
|
new_folder.mkdir()
|
||||||
|
new_input_file_path = new_folder / input_file_path.name
|
||||||
|
|
||||||
|
shutil.copy(input_file_path, new_input_file_path)
|
||||||
|
|
||||||
|
os.chdir(tmp_path)
|
||||||
|
result = runner.invoke(
|
||||||
|
cli.app, ["render", str(new_input_file_path.relative_to(tmp_path))]
|
||||||
|
)
|
||||||
|
|
||||||
|
output_folder_path = tmp_path / "rendercv_output"
|
||||||
|
pdf_file_path = output_folder_path / "John_Doe_CV.pdf"
|
||||||
|
latex_file_path = output_folder_path / "John_Doe_CV.tex"
|
||||||
|
markdown_file_path = output_folder_path / "John_Doe_CV.md"
|
||||||
|
html_file_path = output_folder_path / "John_Doe_CV_PASTETOGRAMMARLY.html"
|
||||||
|
png_file_path = output_folder_path / "John_Doe_CV_1.png"
|
||||||
|
|
||||||
|
assert output_folder_path.exists()
|
||||||
|
assert pdf_file_path.exists()
|
||||||
|
assert latex_file_path.exists()
|
||||||
|
assert markdown_file_path.exists()
|
||||||
|
assert html_file_path.exists()
|
||||||
|
assert png_file_path.exists()
|
||||||
|
assert "Your CV is rendered!" in result.stdout
|
||||||
|
|
||||||
|
|
||||||
def test_render_command_with_different_output_path(input_file_path, tmp_path):
|
def test_render_command_with_different_output_path(input_file_path, tmp_path):
|
||||||
result = run_render_command(
|
result = run_render_command(
|
||||||
input_file_path,
|
input_file_path,
|
||||||
|
|
Loading…
Reference in New Issue