From 8563f729e84d2225577fff6c0848cee4eedf0c71 Mon Sep 17 00:00:00 2001 From: Sina Atalay <79940989+sinaatalay@users.noreply.github.com> Date: Wed, 10 Dec 2025 18:06:21 +0300 Subject: [PATCH] Fix render command issue (#543) --- .../cli/render_command/render_command.py | 6 +- src/rendercv/schema/rendercv_model_builder.py | 6 +- .../cli/render_command/test_render_command.py | 82 +++++++++++++++++++ 3 files changed, 88 insertions(+), 6 deletions(-) diff --git a/src/rendercv/cli/render_command/render_command.py b/src/rendercv/cli/render_command/render_command.py index ad2d4b9f..a02dc65d 100644 --- a/src/rendercv/cli/render_command/render_command.py +++ b/src/rendercv/cli/render_command/render_command.py @@ -185,9 +185,9 @@ def cli_command_render( extra_data_model_override_arguments: typer.Context = None, # pyright: ignore[reportArgumentType] ): arguments: BuildRendercvModelArguments = { - "design_file_path_or_contents": design, - "locale_file_path_or_contents": locale, - "settings_file_path_or_contents": settings, + "design_file_path_or_contents": pathlib.Path(design) if design else None, + "locale_file_path_or_contents": pathlib.Path(locale) if locale else None, + "settings_file_path_or_contents": pathlib.Path(settings) if settings else None, "typst_path": typst_path, "pdf_path": pdf_path, "markdown_path": markdown_path, diff --git a/src/rendercv/schema/rendercv_model_builder.py b/src/rendercv/schema/rendercv_model_builder.py index b59c57a3..b9f81103 100644 --- a/src/rendercv/schema/rendercv_model_builder.py +++ b/src/rendercv/schema/rendercv_model_builder.py @@ -67,9 +67,9 @@ def build_rendercv_dictionary( "settings": kwargs.get("settings_file_path_or_contents"), } - for key, path in yaml_overlays.items(): - if path: - input_dict[key] = read_yaml(path)[key] + for key, path_or_contents in yaml_overlays.items(): + if path_or_contents: + input_dict[key] = read_yaml(path_or_contents)[key] # Optional render-command overrides render_overrides: dict[str, pathlib.Path | str | bool | None] = { diff --git a/tests/cli/render_command/test_render_command.py b/tests/cli/render_command/test_render_command.py index e88cd4fc..d3feebb1 100644 --- a/tests/cli/render_command/test_render_command.py +++ b/tests/cli/render_command/test_render_command.py @@ -142,3 +142,85 @@ class TestCliCommandRender: mock_watcher.assert_called_once() call_args = mock_watcher.call_args assert call_args[0][0] == sample_cv_with_templates.absolute() + + def test_uses_custom_design_file( + self, sample_cv_with_templates, default_arguments, tmp_path + ): + os.chdir(sample_cv_with_templates.parent) + + # Create a custom design file with specific color settings + design_file = tmp_path / "custom_design.yaml" + design_file.write_text( + "design:\n" + " theme: classic\n" + " colors:\n" + " name: rgb(255, 0, 0)\n" # Red color for verification + ) + + cli_command_render( + input_file_name=str(sample_cv_with_templates), + **{**default_arguments, "design": str(design_file)}, + ) + + # Verify output was generated successfully + rendercv_output = sample_cv_with_templates.parent / "rendercv_output" + typst_file = rendercv_output / "John_Doe_CV.typ" + assert typst_file.exists() + + # Verify the custom design was used by checking for the red color + typst_content = typst_file.read_text() + assert "colors-name: rgb(255, 0, 0)" in typst_content + + def test_uses_custom_locale_file( + self, sample_cv_with_templates, default_arguments, tmp_path + ): + os.chdir(sample_cv_with_templates.parent) + + # Create a custom locale file + locale_file = tmp_path / "custom_locale.yaml" + locale_file.write_text( + "locale:\n" + " language: turkish\n" + " month_abbreviations:\n" + " - Oca\n" + " - Şub\n" + " - Mar\n" + " - Nis\n" + " - May\n" + " - Haz\n" + " - Tem\n" + " - Ağu\n" + " - Eyl\n" + " - Eki\n" + " - Kas\n" + " - Ara\n" + ) + + cli_command_render( + input_file_name=str(sample_cv_with_templates), + **{**default_arguments, "locale": str(locale_file)}, + ) + + # Verify output was generated successfully + rendercv_output = sample_cv_with_templates.parent / "rendercv_output" + assert (rendercv_output / "John_Doe_CV.pdf").exists() + assert (rendercv_output / "John_Doe_CV.typ").exists() + + def test_uses_custom_settings_file( + self, sample_cv_with_templates, default_arguments, tmp_path + ): + os.chdir(sample_cv_with_templates.parent) + + # Create a custom settings file with a specific date + settings_file = tmp_path / "custom_settings.yaml" + settings_file.write_text("settings:\n current_date: '2024-01-15'\n") + + cli_command_render( + input_file_name=str(sample_cv_with_templates), + **{**default_arguments, "settings": str(settings_file)}, + ) + + # Verify output was generated successfully + rendercv_output = sample_cv_with_templates.parent / "rendercv_output" + assert (rendercv_output / "John_Doe_CV.pdf").exists() + assert (rendercv_output / "John_Doe_CV.typ").exists()