tests: update testdata

This commit is contained in:
Sina Atalay 2024-03-12 19:02:06 +01:00
parent 2037483957
commit 912f55550e
22 changed files with 237 additions and 75 deletions

View File

@ -2,6 +2,8 @@ import pathlib
import copy
import typing
import itertools
import os
import filecmp
import jinja2
import pytest
@ -111,7 +113,17 @@ def bullet_entry() -> dict[str, str]:
@pytest.fixture
def text_entry() -> str:
return ("My Text Entry with some **markdown** and [links](https://example.com)!",)
return "My Text Entry with some **markdown** and [links](https://example.com)!"
@pytest.fixture
def rendercv_data_model() -> dm.RenderCVDataModel:
return dm.get_a_sample_data_model()
@pytest.fixture
def rendercv_empty_curriculum_vitae_data_model() -> dm.CurriculumVitae:
return dm.CurriculumVitae(sections={"test": ["test"]})
def return_a_value_for_a_field_type(
@ -265,6 +277,44 @@ def testdata_directory_path(tests_directory_path) -> pathlib.Path:
return tests_directory_path / "testdata"
@pytest.fixture
def run_a_function_and_return_output_and_reference_paths(
tmp_path: pathlib.Path,
testdata_directory_path: pathlib.Path,
request: pytest.FixtureRequest,
) -> typing.Callable:
def function(
function: typing.Callable,
file_name: str,
**kwargs,
):
reference_directory_path = (
testdata_directory_path / request.node.name / file_name
)
reference_file_path = reference_directory_path / file_name
output_file_path = tmp_path / file_name
os.chdir(tmp_path)
function(**kwargs)
# Update the auxiliary files if update_testdata is True
if update_testdata:
# create the reference directory if it does not exist
reference_directory_path.mkdir(parents=True, exist_ok=True)
# remove the reference file if it exists
if reference_file_path.exists():
reference_file_path.unlink()
# copy the output file to the reference directory
output_file_path.copy(reference_file_path)
assert filecmp.cmp(output_file_path, reference_file_path)
return function
@pytest.fixture
def input_file_path(testdata_directory_path) -> pathlib.Path:
return testdata_directory_path / "John_Doe_CV.yaml"

View File

@ -369,7 +369,7 @@ def test_social_network_url(network, username, expected_url):
],
)
def test_get_entry_and_section_type(
entry, expected_entry_type, expected_section_type, request
entry, expected_entry_type, expected_section_type, request: pytest.FixtureRequest
):
entry = request.getfixturevalue(entry)
entry_type, section_type = dm.get_entry_and_section_type(entry)

View File

@ -16,6 +16,8 @@ from rendercv import data_models as dm
from .conftest import update_testdata, folder_name_dictionary
def test_latex_file_class(tmp_path, rendercv_data_model, jinja2_environment):
latex_file = r.LaTeXFile(rendercv_data_model, jinja2_environment)
latex_file.get_latex_code()
@ -305,7 +307,7 @@ def test_setup_jinja2_environment():
def test_generate_latex_file(
tmp_path,
testdata_directory_path,
request,
request: pytest.FixtureRequest,
theme_name,
curriculum_vitae_data_model,
):
@ -348,7 +350,7 @@ def test_generate_latex_file(
def test_generate_markdown_file(
tmp_path,
testdata_directory_path,
request,
request: pytest.FixtureRequest,
theme_name,
curriculum_vitae_data_model,
):
@ -473,7 +475,7 @@ def test_copy_theme_files_to_output_directory_custom_theme(
def test_generate_latex_file_and_copy_theme_files(
tmp_path,
testdata_directory_path,
request,
request : pytest.FixtureRequest,
theme_name,
curriculum_vitae_data_model,
):
@ -510,7 +512,7 @@ def test_generate_latex_file_and_copy_theme_files(
@time_machine.travel("2024-01-01")
def test_latex_to_pdf(
tmp_path,
request,
request: pytest.FixtureRequest,
testdata_directory_path,
theme_name,
curriculum_vitae_data_model,
@ -578,7 +580,7 @@ def test_latex_to_pdf_invalid_latex_file():
@time_machine.travel("2024-01-01")
def test_markdown_to_html(
tmp_path,
request,
request: pytest.FixtureRequest,
testdata_directory_path,
theme_name,
curriculum_vitae_data_model,

View File

@ -175,7 +175,7 @@
\advance\csname @rightskip\endcsname 0.2 cm
\advance\rightskip 0.2 cm
Some other \textbf{\textit{ tests, which should be tricky} to parse!}
My Text Entry with some \textbf{markdown} and \href{https://example.com}{links}!
\par\endgroup
@ -186,7 +186,7 @@
\advance\csname @rightskip\endcsname 0.2 cm
\advance\rightskip 0.2 cm
\textbullet \hspace{3pt} This is a bullet entry.
\textbullet \hspace{3pt} My Bullet Entry with some \textbf{markdown} and \href{https://example.com}{links}!
\par\endgroup
@ -195,16 +195,7 @@
\advance\csname @rightskip\endcsname 0.2 cm
\advance\rightskip 0.2 cm
\textbullet \hspace{3pt} My Text Entry with some \textbf{markdown} and \href{https://example.com}{links}!
\par\endgroup
\vspace{0.2 cm}
\begingroup\leftskip=0.2 cm
\advance\csname @rightskip\endcsname 0.2 cm
\advance\rightskip 0.2 cm
\textbullet \hspace{3pt} Some other \textbf{\textit{ tests, which should be tricky} to parse!}
\textbullet \hspace{3pt} My Bullet Entry with some \textbf{markdown} and \href{https://example.com}{links}!
\par\endgroup

View File

@ -85,17 +85,15 @@
\cvline{}{My Text Entry with some \textbf{markdown} and \href{https://example.com}{links}!}
\cvline{}{Some other \textbf{\textit{ tests, which should be tricky} to parse!}}
\cvline{}{My Text Entry with some \textbf{markdown} and \href{https://example.com}{links}!}
\section{Bullet Entries}
\cvlistitem{This is a bullet entry.}
\cvlistitem{My Bullet Entry with some \textbf{markdown} and \href{https://example.com}{links}!}
\cvlistitem{My Text Entry with some \textbf{markdown} and \href{https://example.com}{links}!}
\cvlistitem{Some other \textbf{\textit{ tests, which should be tricky} to parse!}}
\cvlistitem{My Bullet Entry with some \textbf{markdown} and \href{https://example.com}{links}!}

View File

@ -176,18 +176,16 @@
\resumeSubItemWithoutBullet{}{My Text Entry with some \textbf{markdown} and \href{https://example.com}{links}!}
\resumeSubItemWithoutBullet{}{Some other \textbf{\textit{ tests, which should be tricky} to parse!}}
\resumeSubItemWithoutBullet{}{My Text Entry with some \textbf{markdown} and \href{https://example.com}{links}!}
\resumeSubHeadingListEnd
\section{Bullet Entries}
\resumeSubHeadingListStart
\resumeSubItem{}{This is a bullet entry.}
\resumeSubItem{}{My Bullet Entry with some \textbf{markdown} and \href{https://example.com}{links}!}
\resumeSubItem{}{My Text Entry with some \textbf{markdown} and \href{https://example.com}{links}!}
\resumeSubItem{}{Some other \textbf{\textit{ tests, which should be tricky} to parse!}}
\resumeSubItem{}{My Bullet Entry with some \textbf{markdown} and \href{https://example.com}{links}!}
\resumeSubHeadingListEnd

View File

@ -175,7 +175,7 @@
\advance\csname @rightskip\endcsname 0.2 cm
\advance\rightskip 0.2 cm
Some other \textbf{\textit{ tests, which should be tricky} to parse!}
My Text Entry with some \textbf{markdown} and \href{https://example.com}{links}!
\par\endgroup
@ -186,7 +186,7 @@
\advance\csname @rightskip\endcsname 0.2 cm
\advance\rightskip 0.2 cm
\textbullet \hspace{3pt} This is a bullet entry.
\textbullet \hspace{3pt} My Bullet Entry with some \textbf{markdown} and \href{https://example.com}{links}!
\par\endgroup
@ -195,16 +195,7 @@
\advance\csname @rightskip\endcsname 0.2 cm
\advance\rightskip 0.2 cm
\textbullet \hspace{3pt} My Text Entry with some \textbf{markdown} and \href{https://example.com}{links}!
\par\endgroup
\vspace{0.2 cm}
\begingroup\leftskip=0.2 cm
\advance\csname @rightskip\endcsname 0.2 cm
\advance\rightskip 0.2 cm
\textbullet \hspace{3pt} Some other \textbf{\textit{ tests, which should be tricky} to parse!}
\textbullet \hspace{3pt} My Bullet Entry with some \textbf{markdown} and \href{https://example.com}{links}!
\par\endgroup

View File

@ -85,17 +85,15 @@
\cvline{}{My Text Entry with some \textbf{markdown} and \href{https://example.com}{links}!}
\cvline{}{Some other \textbf{\textit{ tests, which should be tricky} to parse!}}
\cvline{}{My Text Entry with some \textbf{markdown} and \href{https://example.com}{links}!}
\section{Bullet Entries}
\cvlistitem{This is a bullet entry.}
\cvlistitem{My Bullet Entry with some \textbf{markdown} and \href{https://example.com}{links}!}
\cvlistitem{My Text Entry with some \textbf{markdown} and \href{https://example.com}{links}!}
\cvlistitem{Some other \textbf{\textit{ tests, which should be tricky} to parse!}}
\cvlistitem{My Bullet Entry with some \textbf{markdown} and \href{https://example.com}{links}!}

View File

@ -176,18 +176,16 @@
\resumeSubItemWithoutBullet{}{My Text Entry with some \textbf{markdown} and \href{https://example.com}{links}!}
\resumeSubItemWithoutBullet{}{Some other \textbf{\textit{ tests, which should be tricky} to parse!}}
\resumeSubItemWithoutBullet{}{My Text Entry with some \textbf{markdown} and \href{https://example.com}{links}!}
\resumeSubHeadingListEnd
\section{Bullet Entries}
\resumeSubHeadingListStart
\resumeSubItem{}{This is a bullet entry.}
\resumeSubItem{}{My Bullet Entry with some \textbf{markdown} and \href{https://example.com}{links}!}
\resumeSubItem{}{My Text Entry with some \textbf{markdown} and \href{https://example.com}{links}!}
\resumeSubItem{}{Some other \textbf{\textit{ tests, which should be tricky} to parse!}}
\resumeSubItem{}{My Bullet Entry with some \textbf{markdown} and \href{https://example.com}{links}!}
\resumeSubHeadingListEnd

View File

@ -18,13 +18,12 @@ My Text Entry with some **markdown** and [links](https://example.com)!
My Text Entry with some **markdown** and [links](https://example.com)!
Some other *** tests, which should be tricky* to parse!**
My Text Entry with some **markdown** and [links](https://example.com)!
# Bullet Entries
- This is a bullet entry.
- My Text Entry with some **markdown** and [links](https://example.com)!
- Some other *** tests, which should be tricky* to parse!**
- My Bullet Entry with some **markdown** and [links](https://example.com)!
- My Bullet Entry with some **markdown** and [links](https://example.com)!
# Publication Entries
## Magneto-Thermal Thin Shell Approximation for 3D Finite Element Analysis of No-Insulation Coils

View File

@ -18,13 +18,12 @@ My Text Entry with some **markdown** and [links](https://example.com)!
My Text Entry with some **markdown** and [links](https://example.com)!
Some other *** tests, which should be tricky* to parse!**
My Text Entry with some **markdown** and [links](https://example.com)!
# Bullet Entries
- This is a bullet entry.
- My Text Entry with some **markdown** and [links](https://example.com)!
- Some other *** tests, which should be tricky* to parse!**
- My Bullet Entry with some **markdown** and [links](https://example.com)!
- My Bullet Entry with some **markdown** and [links](https://example.com)!
# Publication Entries
## Magneto-Thermal Thin Shell Approximation for 3D Finite Element Analysis of No-Insulation Coils

View File

@ -18,13 +18,12 @@ My Text Entry with some **markdown** and [links](https://example.com)!
My Text Entry with some **markdown** and [links](https://example.com)!
Some other *** tests, which should be tricky* to parse!**
My Text Entry with some **markdown** and [links](https://example.com)!
# Bullet Entries
- This is a bullet entry.
- My Text Entry with some **markdown** and [links](https://example.com)!
- Some other *** tests, which should be tricky* to parse!**
- My Bullet Entry with some **markdown** and [links](https://example.com)!
- My Bullet Entry with some **markdown** and [links](https://example.com)!
# Publication Entries
## Magneto-Thermal Thin Shell Approximation for 3D Finite Element Analysis of No-Insulation Coils

View File

@ -0,0 +1,142 @@
\documentclass[10pt, letterpaper]{article}
% Packages:
\usepackage[
ignoreheadfoot, % set margins without considering header and footer
top=2 cm, % seperation between body and page edge from the top
bottom=2 cm, % seperation between body and page edge from the bottom
left=2 cm, % seperation between body and page edge from the left
right=2 cm, % seperation between body and page edge from the right
footskip=1.0 cm, % seperation between body and footer
% showframe % for debugging
]{geometry} % for adjusting page geometry
\usepackage[explicit]{titlesec} % for customizing section titles
\usepackage{tabularx} % for making tables with fixed width columns
\usepackage{array} % tabularx requires this
\usepackage[dvipsnames]{xcolor} % for coloring text
\definecolor{primaryColor}{RGB}{0, 79, 144} % define primary color
\usepackage{enumitem} % for customizing lists
\usepackage{fontawesome5} % for using icons
\usepackage{amsmath} % for math
\usepackage[
pdftitle={None's CV},
pdfauthor={None},
colorlinks=true,
urlcolor=primaryColor
]{hyperref} % for links, metadata and bookmarks
\usepackage[pscoord]{eso-pic} % for floating text on the page
\usepackage{calc} % for calculating lengths
\usepackage{bookmark} % for bookmarks
\usepackage{lastpage} % for getting the total number of pages
\usepackage[default, type1]{sourcesanspro} % for using source sans 3 font
\usepackage{ifthen}
% Some settings:
\pagestyle{empty} % no header or footer
\setcounter{secnumdepth}{0} % no section numbering
\setlength{\parindent}{0pt} % no indentation
\setlength{\topskip}{0pt} % no top skip
\makeatletter
\let\ps@customFooterStyle\ps@plain % Copy the plain style to customFooterStyle
\patchcmd{\ps@customFooterStyle}{\thepage}{
\color{gray}\textit{\small None - Page \thepage{} of \pageref*{LastPage}}
}{}{} % replace number by desired string
\makeatother
\pagestyle{customFooterStyle}
\titleformat{\section}{
% make the font size of the section title large and color it with the primary color
\Large\color{primaryColor}
}{
}{
}{
% print bold title, give 0.15 cm space and draw a line of 0.8 pt thickness
% from the end of the title to the end of the body
\textbf{#1}\hspace{0.15cm}\titlerule[0.8pt]\hspace{-0.1cm}
}[] % section title formatting
\titlespacing{\section}{
% left space:
0pt
}{
% top space:
0.3 cm
}{
% bottom space:
0.2 cm
} % section title spacing
\newcolumntype{L}[1]{
>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}
} % left-aligned fixed width column type
\newcolumntype{R}[1]{
>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}p{#1}
} % right-aligned fixed width column type
\newcolumntype{K}[1]{
>{\let\newline\\\arraybackslash\hspace{0pt}}X
} % justified flexible width column type
\setlength\tabcolsep{-1.5pt} % no space between columns
\newenvironment{highlights}{
\begin{itemize}[
topsep=0pt,
parsep=0.10 cm,
partopsep=0pt,
itemsep=0pt,
after=\vspace{-1\baselineskip},
leftmargin=0.4 cm + 3pt
]
}{
\end{itemize}
} % new environment for highlights
\newenvironment{header}{
\setlength{\topsep}{0pt}\par\kern\topsep\centering\color{primaryColor}\linespread{1.5}
}{
\par\kern\topsep
} % new environment for the header
\newcommand{\placelastupdatedtext}{% \placetextbox{<horizontal pos>}{<vertical pos>}{<stuff>}
\AddToShipoutPictureFG*{% Add <stuff> to current page foreground
\put(
\LenToUnit{\paperwidth-2 cm-0.2 cm+0.05cm},
\LenToUnit{\paperheight-1.0 cm}
){\vtop{{\null}\makebox[0pt][c]{
\small\color{gray}\textit{Last updated in January 2024}\hspace{\widthof{Last updated in January 2024}}
}}}%
}%
}%
% save the original href command in a new command:
\let\hrefWithoutArrow\href
% new command for external links:
\renewcommand{\href}[2]{\hrefWithoutArrow{#1}{\mbox{\ifthenelse{\equal{#2}{}}{ }{#2 }\raisebox{.15ex}{\footnotesize \faExternalLink*}}}}
\let\originalTabularx\tabularx
\let\originalEndTabularx\endtabularx
\renewenvironment{tabularx}{\bgroup\centering\originalTabularx}{\originalEndTabularx\par\egroup}
% For TextEntrys (see https://tex.stackexchange.com/a/600/287984):
\def\changemargin#1#2{\list{}{\rightmargin#2\leftmargin#1\topsep=0pt\itemsep=0pt\parsep=0pt\parskip=0pt\labelwidth=0pt\itemindent=0pt\labelsep=0pt}\item[]}
\let\endchangemargin=\endlist
% Ensure that generate pdf is machine readable/ATS parsable
\pdfgentounicode=1
\begin{document}
\placelastupdatedtext
\section{Test}
\begingroup\leftskip=0.2 cm
\advance\csname @rightskip\endcsname 0.2 cm
\advance\rightskip 0.2 cm
test
\par\endgroup
\end{document}

View File

@ -14,12 +14,11 @@
<h1>Text Entries</h1>
<p>My Text Entry with some <strong>markdown</strong> and <a href="https://example.com">links</a>!</p>
<p>My Text Entry with some <strong>markdown</strong> and <a href="https://example.com">links</a>!</p>
<p>Some other *** tests, which should be tricky<em> to parse!</em>*</p>
<p>My Text Entry with some <strong>markdown</strong> and <a href="https://example.com">links</a>!</p>
<h1>Bullet Entries</h1>
<ul>
<li>This is a bullet entry.</li>
<li>My Text Entry with some <strong>markdown</strong> and <a href="https://example.com">links</a>!</li>
<li>Some other *** tests, which should be tricky<em> to parse!</em>*</li>
<li>My Bullet Entry with some <strong>markdown</strong> and <a href="https://example.com">links</a>!</li>
<li>My Bullet Entry with some <strong>markdown</strong> and <a href="https://example.com">links</a>!</li>
</ul>
<h1>Publication Entries</h1>
<h2>Magneto-Thermal Thin Shell Approximation for 3D Finite Element Analysis of No-Insulation Coils</h2>

View File

@ -14,12 +14,11 @@
<h1>Text Entries</h1>
<p>My Text Entry with some <strong>markdown</strong> and <a href="https://example.com">links</a>!</p>
<p>My Text Entry with some <strong>markdown</strong> and <a href="https://example.com">links</a>!</p>
<p>Some other *** tests, which should be tricky<em> to parse!</em>*</p>
<p>My Text Entry with some <strong>markdown</strong> and <a href="https://example.com">links</a>!</p>
<h1>Bullet Entries</h1>
<ul>
<li>This is a bullet entry.</li>
<li>My Text Entry with some <strong>markdown</strong> and <a href="https://example.com">links</a>!</li>
<li>Some other *** tests, which should be tricky<em> to parse!</em>*</li>
<li>My Bullet Entry with some <strong>markdown</strong> and <a href="https://example.com">links</a>!</li>
<li>My Bullet Entry with some <strong>markdown</strong> and <a href="https://example.com">links</a>!</li>
</ul>
<h1>Publication Entries</h1>
<h2>Magneto-Thermal Thin Shell Approximation for 3D Finite Element Analysis of No-Insulation Coils</h2>

View File

@ -14,12 +14,11 @@
<h1>Text Entries</h1>
<p>My Text Entry with some <strong>markdown</strong> and <a href="https://example.com">links</a>!</p>
<p>My Text Entry with some <strong>markdown</strong> and <a href="https://example.com">links</a>!</p>
<p>Some other *** tests, which should be tricky<em> to parse!</em>*</p>
<p>My Text Entry with some <strong>markdown</strong> and <a href="https://example.com">links</a>!</p>
<h1>Bullet Entries</h1>
<ul>
<li>This is a bullet entry.</li>
<li>My Text Entry with some <strong>markdown</strong> and <a href="https://example.com">links</a>!</li>
<li>Some other *** tests, which should be tricky<em> to parse!</em>*</li>
<li>My Bullet Entry with some <strong>markdown</strong> and <a href="https://example.com">links</a>!</li>
<li>My Bullet Entry with some <strong>markdown</strong> and <a href="https://example.com">links</a>!</li>
</ul>
<h1>Publication Entries</h1>
<h2>Magneto-Thermal Thin Shell Approximation for 3D Finite Element Analysis of No-Insulation Coils</h2>