mirror of https://github.com/eyhc1/rendercv.git
improve data_models.py tests
This commit is contained in:
parent
4ab6c49f63
commit
4b6d0d1634
|
@ -2,6 +2,7 @@ from datetime import date as Date
|
||||||
import json
|
import json
|
||||||
import pathlib
|
import pathlib
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
import pydantic
|
import pydantic
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -120,8 +121,9 @@ def test_convert_md_to_latex(input_dict, expected_dict):
|
||||||
|
|
||||||
|
|
||||||
def test_read_input_file(input_file_path):
|
def test_read_input_file(input_file_path):
|
||||||
data_model = dm.read_input_file(input_file_path)
|
data_model_latex, data_model_markdown = dm.read_input_file(input_file_path)
|
||||||
assert isinstance(data_model, dm.RenderCVDataModel)
|
assert isinstance(data_model_latex, dm.RenderCVDataModel)
|
||||||
|
assert isinstance(data_model_markdown, dm.RenderCVDataModel)
|
||||||
|
|
||||||
|
|
||||||
def test_read_input_file_not_found():
|
def test_read_input_file_not_found():
|
||||||
|
@ -613,3 +615,23 @@ def test_custom_theme(reference_files_directory_path):
|
||||||
})
|
})
|
||||||
|
|
||||||
assert data_model.design.theme == "dummytheme"
|
assert data_model.design.theme == "dummytheme"
|
||||||
|
|
||||||
|
|
||||||
|
def test_custom_theme_without_init_file(tmp_path, reference_files_directory_path):
|
||||||
|
reference_custom_theme_path = reference_files_directory_path / "dummytheme"
|
||||||
|
|
||||||
|
# copy the directory to tmp_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:
|
||||||
|
init_file = custom_theme_path / "__init__.py"
|
||||||
|
init_file.unlink()
|
||||||
|
|
||||||
|
os.chdir(tmp_path)
|
||||||
|
data_model = dm.RenderCVDataModel(**{ # type: ignore
|
||||||
|
"cv": {"name": "John Doe"},
|
||||||
|
"design": {"theme": "dummytheme"},
|
||||||
|
})
|
||||||
|
|
||||||
|
assert data_model.design.theme == "dummytheme"
|
||||||
|
|
Loading…
Reference in New Issue