mirror of https://github.com/eyhc1/rendercv.git
tests: increase coverage
This commit is contained in:
parent
e3c30139a7
commit
7c6856a7e1
|
@ -141,4 +141,4 @@ source = ['rendercv']
|
|||
relative_files = true
|
||||
|
||||
# don't include jinja templates in the coverage report:
|
||||
omit = ["*.j2.*"]
|
||||
omit = ["*.j2.*", "rendercv/__main__.py"]
|
||||
|
|
|
@ -41,6 +41,11 @@ def test_error():
|
|||
cli.error("This is an error message.")
|
||||
|
||||
|
||||
def test_error_without_text():
|
||||
with pytest.raises(typer.Exit):
|
||||
cli.error()
|
||||
|
||||
|
||||
def test_information():
|
||||
cli.information("This is an information message.")
|
||||
|
||||
|
@ -102,6 +107,14 @@ def test_get_error_message_and_location_and_value_from_a_custom_error():
|
|||
"end_date": "INVALID END DATE",
|
||||
},
|
||||
),
|
||||
(
|
||||
dm.ExperienceEntry,
|
||||
{
|
||||
"company": "CERN",
|
||||
"position": "Researcher",
|
||||
"highlights": "This is not a list.",
|
||||
},
|
||||
),
|
||||
(
|
||||
dm.PublicationEntry,
|
||||
{
|
||||
|
@ -139,6 +152,15 @@ def test_get_error_message_and_location_and_value_from_a_custom_error():
|
|||
},
|
||||
},
|
||||
),
|
||||
(
|
||||
dm.RenderCVDataModel,
|
||||
{
|
||||
"cv": {
|
||||
"name": "John Doe",
|
||||
},
|
||||
"design": {"theme": "UPPERCASE"},
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_handle_validation_error(data_model_class, invalid_model):
|
||||
|
|
|
@ -170,6 +170,12 @@ def test_read_input_file_invalid_file(tmp_path):
|
|||
dm.read_input_file(invalid_file_path)
|
||||
|
||||
|
||||
def test_read_input_file_that_doesnt_exist(tmp_path):
|
||||
non_existent_file_path = tmp_path / "non_existent_file.yaml"
|
||||
with pytest.raises(FileNotFoundError):
|
||||
dm.read_input_file(non_existent_file_path)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"theme",
|
||||
dm.available_themes,
|
||||
|
@ -645,7 +651,7 @@ def test_custom_theme_with_broken_init_file(tmp_path, testdata_directory_path):
|
|||
custom_theme_path = tmp_path / "dummytheme"
|
||||
shutil.copytree(reference_custom_theme_path, custom_theme_path, dirs_exist_ok=True)
|
||||
|
||||
# remove the __init__.py file:
|
||||
# overwrite the __init__.py file (syntax error)
|
||||
init_file = custom_theme_path / "__init__.py"
|
||||
init_file.write_text("invalid python code", encoding="utf-8")
|
||||
|
||||
|
@ -658,6 +664,19 @@ def test_custom_theme_with_broken_init_file(tmp_path, testdata_directory_path):
|
|||
}
|
||||
)
|
||||
|
||||
# overwrite the __init__.py file (import error)
|
||||
init_file = custom_theme_path / "__init__.py"
|
||||
init_file.write_text("from ... import test", encoding="utf-8")
|
||||
|
||||
os.chdir(tmp_path)
|
||||
with pytest.raises(pydantic.ValidationError):
|
||||
dm.RenderCVDataModel(
|
||||
**{ # type: ignore
|
||||
"cv": {"name": "John Doe"},
|
||||
"design": {"theme": "dummytheme"},
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def test_locale_catalog():
|
||||
data_model = dm.get_a_sample_data_model("John Doe")
|
||||
|
|
Loading…
Reference in New Issue