Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement all relevant unit tests #7

Closed
alexpovel opened this issue Jul 19, 2022 · 3 comments · Fixed by #40
Closed

Implement all relevant unit tests #7

alexpovel opened this issue Jul 19, 2022 · 3 comments · Fixed by #40
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@alexpovel
Copy link
Owner

No description provided.

@alexpovel alexpovel added the enhancement New feature or request label Jul 19, 2022
@alexpovel alexpovel added this to the Initial release milestone Jul 19, 2022
@alexpovel alexpovel self-assigned this Jul 19, 2022
alexpovel added a commit that referenced this issue Jul 26, 2022
@alexpovel
Copy link
Owner Author

After d236893, only some unit tests for the Template class class methods remain:

@classmethod
# A property would be nicer but it's not supported from Python 3.11 on:
# https://docs.python.org/3.11/library/functions.html#classmethod
def subclasses(cls) -> dict[str, type["Template"]]:
return {cls.__name__: cls for cls in cls.__subclasses__()}
@classmethod
def from_model_config(cls, model: ResumeSchema) -> "Template":
try:
theme = THEMES[model.meta.config.theme]
except KeyError as e:
raise ResumeConfigError(f"Unknown theme: {model.meta.config.theme}") from e
try:
translation = TRANSLATIONS[model.meta.config.translation]
except KeyError as e:
raise ResumeConfigError(
f"Unknown translation: {model.meta.config.translation}"
) from e
try:
template = cls.subclasses()[model.meta.config.template]
except KeyError as e:
raise ResumeConfigError(
f"Unknown template: {model.meta.config.template}"
) from e
return template(
model=model,
theme=theme,
translation=translation,
ascii_only=model.meta.config.ascii_only,
)
@classmethod
def from_file(cls, file: Path) -> "Template":
with open(file, "r", encoding="utf8") as f:
contents = json.loads(f.read())
return cls.from_model_config(ResumeSchema(**contents))

@alexpovel
Copy link
Owner Author

Closed by now. The above is covered by integration tests for the CLI, and all sorts of units tests are implemented by now.

@alexpovel
Copy link
Owner Author

Some of the last remaining unit tests added in 476bf58.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant