mirror of
https://github.com/rendercv/rendercv.git
synced 2025-12-23 21:47:55 -05:00
add grade field to education entry (#463)
* add grade field to education entry * remove optional and use "| None" * remove optional and use "| None" * update schema
This commit is contained in:
@@ -290,6 +290,7 @@ def return_a_value_for_a_field_type(
|
||||
|
||||
def create_combinations_of_a_model(
|
||||
model: type[data.Entry],
|
||||
ignore_fields: set[str] | None = None,
|
||||
) -> list[data.Entry]:
|
||||
"""Look at the required fields and optional fields of a model and create all
|
||||
possible combinations of them.
|
||||
@@ -305,7 +306,11 @@ def create_combinations_of_a_model(
|
||||
required_fields = {}
|
||||
optional_fields = {}
|
||||
|
||||
ignore_fields = ignore_fields or set()
|
||||
|
||||
for field, field_type in fields.items():
|
||||
if field in ignore_fields:
|
||||
continue
|
||||
value = return_a_value_for_a_field_type(field, field_type)
|
||||
if type(None) in typing.get_args(field_type): # check if a field is optional
|
||||
optional_fields[field] = value
|
||||
@@ -368,7 +373,10 @@ def rendercv_filled_curriculum_vitae_data_model(
|
||||
data.PublicationEntry
|
||||
),
|
||||
"Experience Entries": create_combinations_of_a_model(data.ExperienceEntry),
|
||||
"Education Entries": create_combinations_of_a_model(data.EducationEntry),
|
||||
"Education Entries": create_combinations_of_a_model(
|
||||
data.EducationEntry,
|
||||
ignore_fields={"grade"},
|
||||
),
|
||||
"Normal Entries": create_combinations_of_a_model(data.NormalEntry),
|
||||
"One Line Entries": create_combinations_of_a_model(data.OneLineEntry),
|
||||
"Numbered Entries": create_combinations_of_a_model(data.NumberedEntry),
|
||||
|
||||
@@ -349,6 +349,12 @@ def test_invalid_publication_dates(publication_entry, date):
|
||||
data.PublicationEntry(**publication_entry)
|
||||
|
||||
|
||||
def test_education_entry_grade_field(education_entry):
|
||||
education_entry["grade"] = "GPA: 3.00/4.00"
|
||||
entry = data.EducationEntry(**education_entry)
|
||||
assert entry.grade == "GPA: 3.00/4.00"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("start_date", "end_date", "date"),
|
||||
[
|
||||
|
||||
@@ -710,6 +710,11 @@ def test_are_all_the_theme_files_the_same(theme_name):
|
||||
{},
|
||||
'#link("https://myurl.com")[#strong[#emph[My]]]',
|
||||
),
|
||||
(
|
||||
"**GRADE**",
|
||||
{"GRADE": "GPA: 3.00/4.00"},
|
||||
'#strong[GPA: 3.00/4.00]'
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_input_template_to_typst(
|
||||
|
||||
Reference in New Issue
Block a user