mirror of
https://github.com/rendercv/rendercv.git
synced 2026-10-24 13:18:50 -04:00
tests: update
This commit is contained in:
1 parent
fca375da0c
commit
5f78c6c74f
5 files changed
+40
-25
No files matched your search
@@ -197,7 +197,7 @@ def generate_entry_figures():
|
||||
latex_file_path = renderer.render_a_latex_file_and_copy_theme_files(
|
||||
data_model, temporary_directory_path
|
||||
)
|
||||
pdf_file_path = renderer.render_pdf_from_latex(latex_file_path)
|
||||
pdf_file_path = renderer.render_a_pdf_from_latex(latex_file_path)
|
||||
|
||||
# Prepare the output directory and file path:
|
||||
output_directory = image_assets_directory / theme
|
||||
|
||||
@@ -39,6 +39,7 @@ def cli_command_render(
|
||||
input_file_name: Annotated[
|
||||
str, typer.Argument(help="Name of the YAML input file.")
|
||||
],
|
||||
extra_data_model_override_argumets: typer.Context,
|
||||
use_local_latex_command: Annotated[
|
||||
Optional[str],
|
||||
typer.Option(
|
||||
@@ -122,7 +123,9 @@ def cli_command_render(
|
||||
help="Don't generate the PNG file.",
|
||||
),
|
||||
] = False,
|
||||
_: Annotated[ # This is a dummy argument for the help message.
|
||||
# This is a dummy argument for the help message for
|
||||
# extra_data_model_override_argumets:
|
||||
_: Annotated[
|
||||
Optional[str],
|
||||
typer.Option(
|
||||
"--YAMLLOCATION",
|
||||
@@ -130,7 +133,6 @@ def cli_command_render(
|
||||
' [cyan bold]--cv.phone "123-456-7890"[/cyan bold].',
|
||||
),
|
||||
] = None,
|
||||
extra_data_model_override_argumets: Optional[typer.Context] = None,
|
||||
):
|
||||
"""Render a CV from a YAML input file."""
|
||||
printer.welcome()
|
||||
@@ -363,7 +365,9 @@ def cli_command_create_theme(
|
||||
)
|
||||
return
|
||||
|
||||
based_on_theme_directory = pathlib.Path(__file__).parent / "themes" / based_on
|
||||
based_on_theme_directory = (
|
||||
pathlib.Path(__file__).parent.parent / "themes" / based_on
|
||||
)
|
||||
based_on_theme_init_file = based_on_theme_directory / "__init__.py"
|
||||
based_on_theme_init_file_contents = based_on_theme_init_file.read_text()
|
||||
|
||||
|
||||
+9
-8
@@ -7,7 +7,7 @@ import os
|
||||
import pathlib
|
||||
import shutil
|
||||
import typing
|
||||
from typing import Optional
|
||||
from typing import Optional, Type
|
||||
|
||||
import jinja2
|
||||
import pydantic
|
||||
@@ -15,9 +15,8 @@ import pydantic_extra_types.phone_numbers as pydantic_phone_numbers
|
||||
import pypdf
|
||||
import pytest
|
||||
|
||||
import rendercv.renderer as renderer
|
||||
import rendercv.renderer.templater as rt
|
||||
from rendercv import data as data
|
||||
from rendercv.renderer import templater
|
||||
from rendercv import data
|
||||
|
||||
# RenderCV is being tested by comparing the output to reference files. Therefore,
|
||||
# reference files should be updated when RenderCV is updated in a way that changes
|
||||
@@ -240,7 +239,7 @@ def return_a_value_for_a_field_type(
|
||||
|
||||
|
||||
def create_combinations_of_a_model(
|
||||
model: pydantic.BaseModel,
|
||||
model: Type[data.Entry],
|
||||
) -> list[pydantic.BaseModel]:
|
||||
"""Look at the required fields and optional fields of a model and create all
|
||||
possible combinations of them.
|
||||
@@ -306,7 +305,9 @@ def rendercv_filled_curriculum_vitae_data_model(
|
||||
sections={
|
||||
"Text Entries": [text_entry, text_entry, text_entry],
|
||||
"Bullet Entries": [bullet_entry, bullet_entry],
|
||||
"Publication Entries": create_combinations_of_a_model(data.PublicationEntry),
|
||||
"Publication Entries": create_combinations_of_a_model(
|
||||
data.PublicationEntry
|
||||
),
|
||||
"Experience Entries": create_combinations_of_a_model(data.ExperienceEntry),
|
||||
"Education Entries": create_combinations_of_a_model(data.EducationEntry),
|
||||
"Normal Entries": create_combinations_of_a_model(data.NormalEntry),
|
||||
@@ -318,7 +319,7 @@ def rendercv_filled_curriculum_vitae_data_model(
|
||||
@pytest.fixture
|
||||
def jinja2_environment() -> jinja2.Environment:
|
||||
"""Return a Jinja2 environment."""
|
||||
return rt.setup_jinja2_environment()
|
||||
return templater.setup_jinja2_environment()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -351,7 +352,7 @@ def specific_testdata_directory_path(testdata_directory_path, request) -> pathli
|
||||
|
||||
def are_these_two_directories_the_same(
|
||||
directory1: pathlib.Path, directory2: pathlib.Path
|
||||
) -> None:
|
||||
) -> bool:
|
||||
"""Check if two directories are the same.
|
||||
|
||||
Args:
|
||||
|
||||
+16
-8
@@ -528,11 +528,12 @@ def test_create_theme_command(tmp_path, input_file_path, based_on):
|
||||
# change the current working directory to the temporary directory:
|
||||
os.chdir(tmp_path)
|
||||
|
||||
runner.invoke(cli.app, ["create-theme", "newtheme", "--based-on", based_on])
|
||||
result = runner.invoke(cli.app, ["create-theme", "newtheme", "--based-on", based_on])
|
||||
|
||||
new_theme_source_files_path = tmp_path / "newtheme"
|
||||
|
||||
assert new_theme_source_files_path.exists()
|
||||
assert (new_theme_source_files_path / "__init__.py").exists()
|
||||
|
||||
# test if the new theme is actually working:
|
||||
input_file_path = shutil.copy(input_file_path, tmp_path)
|
||||
@@ -586,7 +587,9 @@ def test_get_latest_version_number_from_pypi():
|
||||
|
||||
|
||||
def test_if_welcome_prints_new_version_available(monkeypatch):
|
||||
monkeypatch.setattr(utilities, "get_latest_version_number_from_pypi", lambda: "99999")
|
||||
monkeypatch.setattr(
|
||||
utilities, "get_latest_version_number_from_pypi", lambda: "99999"
|
||||
)
|
||||
import contextlib
|
||||
import io
|
||||
|
||||
@@ -598,7 +601,9 @@ def test_if_welcome_prints_new_version_available(monkeypatch):
|
||||
|
||||
|
||||
def test_rendercv_version_when_there_is_a_new_version(monkeypatch):
|
||||
monkeypatch.setattr(cli, "get_latest_version_number_from_pypi", lambda: "99999")
|
||||
monkeypatch.setattr(
|
||||
utilities, "get_latest_version_number_from_pypi", lambda: "99999"
|
||||
)
|
||||
|
||||
result = runner.invoke(cli.app, ["--version"])
|
||||
|
||||
@@ -606,7 +611,9 @@ def test_rendercv_version_when_there_is_a_new_version(monkeypatch):
|
||||
|
||||
|
||||
def test_rendercv_version_when_there_is_not_a_new_version(monkeypatch):
|
||||
monkeypatch.setattr(cli, "get_latest_version_number_from_pypi", lambda: __version__)
|
||||
monkeypatch.setattr(
|
||||
utilities, "get_latest_version_number_from_pypi", lambda: __version__
|
||||
)
|
||||
|
||||
result = runner.invoke(cli.app, ["--version"])
|
||||
|
||||
@@ -614,16 +621,17 @@ def test_rendercv_version_when_there_is_not_a_new_version(monkeypatch):
|
||||
|
||||
|
||||
def test_warn_if_new_version_is_available(monkeypatch):
|
||||
monkeypatch.setattr(cli, "get_latest_version_number_from_pypi", lambda: __version__)
|
||||
monkeypatch.setattr(
|
||||
utilities, "get_latest_version_number_from_pypi", lambda: __version__
|
||||
)
|
||||
|
||||
assert not printer.warn_if_new_version_is_available()
|
||||
|
||||
monkeypatch.setattr(cli, "get_latest_version_number_from_pypi", lambda: "999")
|
||||
monkeypatch.setattr(utilities, "get_latest_version_number_from_pypi", lambda: "999")
|
||||
|
||||
assert printer.warn_if_new_version_is_available()
|
||||
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"key, value",
|
||||
[
|
||||
@@ -676,4 +684,4 @@ def test_set_or_update_a_value_invalid_keys(rendercv_data_model, key, value):
|
||||
)
|
||||
def test_set_or_update_a_value_invalid_values(rendercv_data_model, key, value):
|
||||
with pytest.raises(pydantic.ValidationError):
|
||||
utilities.set_or_update_a_value(rendercv_data_model, key, value)
|
||||
utilities.set_or_update_a_value(rendercv_data_model, key, value)
|
||||
@@ -8,7 +8,7 @@ import jinja2
|
||||
import pytest
|
||||
import time_machine
|
||||
|
||||
from rendercv import data as data
|
||||
from rendercv import data
|
||||
from rendercv import renderer
|
||||
from rendercv.renderer import templater
|
||||
|
||||
@@ -486,7 +486,7 @@ def test_copy_theme_files_to_output_directory_custom_theme(
|
||||
dummytheme_path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# create a txt file called test.txt in the custom theme directory:
|
||||
for entry_type_name in data.available_entry_types:
|
||||
for entry_type_name in data.available_entry_type_names:
|
||||
pathlib.Path(dummytheme_path / f"{entry_type_name}.j2.tex").touch()
|
||||
|
||||
pathlib.Path(dummytheme_path / "Header.j2.tex").touch()
|
||||
@@ -671,7 +671,9 @@ def test_render_an_html_from_markdown(
|
||||
shutil.copy(markdown_source_path, output_directory_path)
|
||||
|
||||
# convert markdown to html
|
||||
renderer.render_an_html_from_markdown(output_directory_path / markdown_file_name)
|
||||
renderer.render_an_html_from_markdown(
|
||||
output_directory_path / markdown_file_name
|
||||
)
|
||||
|
||||
assert run_a_function_and_check_if_output_is_the_same_as_reference(
|
||||
function=render_html_from_markdown,
|
||||
@@ -697,7 +699,7 @@ def test_render_pngs_from_pdf_single_page(
|
||||
|
||||
pdf_path = (
|
||||
reference_file_or_directory_path.parent.parent
|
||||
/ "test_render_pdf_from_latex"
|
||||
/ "test_render_a_pdf_from_latex"
|
||||
/ pdf_file_name
|
||||
)
|
||||
|
||||
@@ -724,7 +726,7 @@ def test_render_pngs_from_pdf(
|
||||
|
||||
pdf_path = (
|
||||
reference_file_or_directory_path.parent.parent
|
||||
/ "test_render_pdf_from_latex"
|
||||
/ "test_render_a_pdf_from_latex"
|
||||
/ pdf_file_name
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user