mirror of https://github.com/eyhc1/rendercv.git
tests: update
This commit is contained in:
parent
321e634679
commit
ed9b7f7b09
|
@ -285,6 +285,10 @@ def rendercv_filled_curriculum_vitae_data_model(
|
|||
dm.SocialNetwork(network="Orcid", username="0000-0000-0000-0000"),
|
||||
dm.SocialNetwork(network="Mastodon", username="@johndoe@example"),
|
||||
dm.SocialNetwork(network="Twitter", username="johndoe"),
|
||||
dm.SocialNetwork(network="StackOverflow", username="12323/johndoe"),
|
||||
dm.SocialNetwork(network="GitLab", username="johndoe"),
|
||||
dm.SocialNetwork(network="ResearchGate", username="johndoe"),
|
||||
dm.SocialNetwork(network="YouTube", username="@johndoe"),
|
||||
],
|
||||
sections={
|
||||
"Text Entries": [text_entry, text_entry, text_entry],
|
||||
|
|
|
@ -286,8 +286,8 @@ def test_render_command_with_different_output_path_for_each_file(
|
|||
def test_render_command_with_custom_png_path_multiple_pages(tmp_path):
|
||||
# create a new input file (for a CV with multiple pages) in the temporary directory:
|
||||
os.chdir(tmp_path)
|
||||
runner.invoke(cli.app, ["new", "John Doe"])
|
||||
input_file_path = tmp_path / "John_Doe_CV.yaml"
|
||||
runner.invoke(cli.app, ["new", "Jahn Doe"])
|
||||
input_file_path = tmp_path / "Jahn_Doe_CV.yaml"
|
||||
|
||||
run_render_command(
|
||||
input_file_path,
|
||||
|
@ -370,11 +370,11 @@ def test_render_command_with_invalid_arguments(
|
|||
def test_new_command(tmp_path):
|
||||
# change the current working directory to the temporary directory:
|
||||
os.chdir(tmp_path)
|
||||
runner.invoke(cli.app, ["new", "John Doe"])
|
||||
runner.invoke(cli.app, ["new", "Jahn Doe"])
|
||||
|
||||
markdown_source_files_path = tmp_path / "markdown"
|
||||
theme_source_files_path = tmp_path / "classic"
|
||||
input_file_path = tmp_path / "John_Doe_CV.yaml"
|
||||
input_file_path = tmp_path / "Jahn_Doe_CV.yaml"
|
||||
|
||||
assert markdown_source_files_path.exists()
|
||||
assert theme_source_files_path.exists()
|
||||
|
@ -385,7 +385,7 @@ def test_new_command_with_invalid_theme(tmp_path):
|
|||
# change the current working directory to the temporary directory:
|
||||
os.chdir(tmp_path)
|
||||
|
||||
result = runner.invoke(cli.app, ["new", "John Doe", "--theme", "invalid_theme"])
|
||||
result = runner.invoke(cli.app, ["new", "Jahn Doe", "--theme", "invalid_theme"])
|
||||
|
||||
assert "The theme should be one of the following" in result.stdout
|
||||
|
||||
|
@ -400,7 +400,7 @@ def test_new_command_with_invalid_theme(tmp_path):
|
|||
def test_new_command_with_dont_create_files(tmp_path, option, folder_name):
|
||||
# change the current working directory to the temporary directory:
|
||||
os.chdir(tmp_path)
|
||||
runner.invoke(cli.app, ["new", "John Doe", option])
|
||||
runner.invoke(cli.app, ["new", "Jahn Doe", option])
|
||||
|
||||
source_files_path = tmp_path / folder_name
|
||||
|
||||
|
@ -414,7 +414,7 @@ def test_new_command_with_only_input_file(tmp_path):
|
|||
cli.app,
|
||||
[
|
||||
"new",
|
||||
"John Doe",
|
||||
"Jahn Doe",
|
||||
"--dont-create-markdown-source-files",
|
||||
"--dont-create-theme-source-files",
|
||||
],
|
||||
|
@ -422,13 +422,35 @@ def test_new_command_with_only_input_file(tmp_path):
|
|||
|
||||
markdown_source_files_path = tmp_path / "markdown"
|
||||
theme_source_files_path = tmp_path / "classic"
|
||||
input_file_path = tmp_path / "John_Doe_CV.yaml"
|
||||
input_file_path = tmp_path / "Jahn_Doe_CV.yaml"
|
||||
|
||||
assert not markdown_source_files_path.exists()
|
||||
assert not theme_source_files_path.exists()
|
||||
assert input_file_path.exists()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"file_or_folder_name",
|
||||
[
|
||||
"John_Doe_CV.yaml",
|
||||
"markdown",
|
||||
"classic",
|
||||
],
|
||||
)
|
||||
def test_new_command_with_existing_files(tmp_path, file_or_folder_name):
|
||||
# change the current working directory to the temporary directory:
|
||||
os.chdir(tmp_path)
|
||||
|
||||
if file_or_folder_name == "Jahn_Doe_CV.yaml":
|
||||
(tmp_path / file_or_folder_name).touch()
|
||||
else:
|
||||
(tmp_path / file_or_folder_name).mkdir()
|
||||
|
||||
result = runner.invoke(cli.app, ["new", "Jahn Doe"])
|
||||
|
||||
assert "already exists!" in result.stdout
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"based_on",
|
||||
dm.available_themes,
|
||||
|
|
|
@ -410,6 +410,10 @@ def test_invalid_doi(publication_entry, doi):
|
|||
("Mastodon", "invalidmastodon"),
|
||||
("Mastodon", "@inva@l@id"),
|
||||
("Mastodon", "@invalid@ne<>twork.com"),
|
||||
("StackOverflow", "invalidusername"),
|
||||
("StackOverflow", "invalidusername//"),
|
||||
("StackOverflow", "invalidusername/invalid"),
|
||||
("YouTube", "invalidusername"),
|
||||
],
|
||||
)
|
||||
def test_invalid_social_networks(network, username):
|
||||
|
@ -431,6 +435,21 @@ def test_invalid_social_networks(network, username):
|
|||
"4567/myusername",
|
||||
"https://stackoverflow.com/users/4567/myusername",
|
||||
),
|
||||
(
|
||||
"GitLab",
|
||||
"myusername",
|
||||
"https://gitlab.com/myusername",
|
||||
),
|
||||
(
|
||||
"ResearchGate",
|
||||
"myusername",
|
||||
"https://researchgate.net/profile/myusername",
|
||||
),
|
||||
(
|
||||
"YouTube",
|
||||
"@myusername",
|
||||
"https://youtube.com/@myusername",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_social_network_url(network, username, expected_url):
|
||||
|
@ -662,26 +681,50 @@ def test_locale_catalog():
|
|||
|
||||
assert dm.locale_catalog == data_model.locale_catalog.model_dump()
|
||||
|
||||
# reset the locale catalog
|
||||
dm.locale_catalog = {
|
||||
"month": "month",
|
||||
"months": "months",
|
||||
"year": "year",
|
||||
"years": "years",
|
||||
"present": "present",
|
||||
"to": "to",
|
||||
"abbreviations_for_months": [
|
||||
"Jan.",
|
||||
"Feb.",
|
||||
"Mar.",
|
||||
"Apr.",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"Aug.",
|
||||
"Sept.",
|
||||
"Oct.",
|
||||
"Nov.",
|
||||
"Dec.",
|
||||
|
||||
def test_if_local_catalog_resets():
|
||||
data_model = dm.get_a_sample_data_model("John Doe")
|
||||
|
||||
data_model.locale_catalog = dm.LocaleCatalog(
|
||||
month="a",
|
||||
)
|
||||
|
||||
assert dm.locale_catalog["month"] == "a"
|
||||
|
||||
data_model = dm.get_a_sample_data_model("John Doe")
|
||||
|
||||
assert dm.locale_catalog["month"] == "month"
|
||||
|
||||
|
||||
def test_dictionary_to_yaml():
|
||||
input_dictionary = {
|
||||
"test_list": [
|
||||
"a",
|
||||
"b",
|
||||
"c",
|
||||
],
|
||||
"test_dict": {
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
},
|
||||
}
|
||||
yaml_string = dm.dictionary_to_yaml(input_dictionary)
|
||||
|
||||
# load the yaml string
|
||||
yaml_object = ruamel.yaml.YAML()
|
||||
output_dictionary = yaml_object.load(yaml_string)
|
||||
|
||||
assert input_dictionary == output_dictionary
|
||||
|
||||
|
||||
def test_create_a_sample_yaml_input_file(tmp_path):
|
||||
input_file_path = tmp_path / "input.yaml"
|
||||
yaml_contents = dm.create_a_sample_yaml_input_file(input_file_path)
|
||||
|
||||
assert input_file_path.exists()
|
||||
assert yaml_contents == input_file_path.read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def test_default_input_file_doesnt_have_local_catalog():
|
||||
yaml_contents = dm.create_a_sample_yaml_input_file()
|
||||
assert "locale_catalog" not in yaml_contents
|
||||
|
|
Loading…
Reference in New Issue