Skip to content

Commit

Permalink
Additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adespawn committed Feb 22, 2024
1 parent 822a9c6 commit dbc592a
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/commands/doc/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,62 @@ def test_argument(capsys, create_package):
command.run(args)
out = capsys.readouterr().out
assert "Compilation was successful for all files." in out
assert "pdflatex" in out # In auto mode this command will use pdflatex

logs_exist = False
logs_dir = paths.get_cache_path('doc_logs')
for pattern in command.LOG_PATTERNS:
assert glob.glob(os.path.join(os.getcwd(), 'doc', pattern)) == []
logs_exist = logs_exist | (glob.glob(os.path.join(logs_dir, pattern)) != [])
assert logs_exist

def run_doc(capsys, command_args, expected, not_expected):
"""
Run doc command
"""
parser = configure_parsers()
args = parser.parse_args(command_args)
command = Command()
command.run(args)
out = capsys.readouterr().out
assert "Compilation was successful for all files." in out
assert expected in out
assert not_expected not in out

@pytest.mark.parametrize("create_package", [util.get_ps_doc_package_path()], indirect=True)
def test_ps_images(capsys, create_package):
"""
Test `doc` command with ps images.
"""
run_doc(
capsys=capsys,
command_args=["doc"],
expected="latex to dvi", # In auto mode this command should use latex and dvipdf
not_expected="pdflatex" # and shouldn't use pdflatex for any compilation
)


@pytest.mark.parametrize("create_package", [util.get_ps_doc_package_path()], indirect=True)
def test_compilation_mode(capsys, create_package):
"""
Test `doc` with compilation mode directly specified.
"""
run_doc(
capsys=capsys,
command_args=["doc", "doc/doczad.tex", "--latex-compiler", "pdflatex"],
expected="pdflatex",
not_expected="latex to dvi"
)


@pytest.mark.parametrize("create_package", [util.get_doc_package_path()], indirect=True)
def test_compilation_mode_2(capsys, create_package):
"""
Test `doc` with compilation mode directly specified.
"""
run_doc(
capsys=capsys,
command_args=["doc", "doc/doczad.tex", "--latex-compiler", "latex_dvi"],
expected="latex to dvi",
not_expected="pdflatex"
)
5 changes: 5 additions & 0 deletions tests/packages/doc/doc/doctest.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics{test_image.png}
\end{document}
Binary file added tests/packages/doc/doc/test_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions tests/packages/ps_doc/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
title: Package for testing `doc` command (version with ps images)
time_limit: 1000
memory_limit: 1024
sinol_task_id: doc2
5 changes: 5 additions & 0 deletions tests/packages/ps_doc/doc/doctest.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics{test_image.ps}
\end{document}
4 changes: 4 additions & 0 deletions tests/packages/ps_doc/doc/doczad.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
\documentclass{article}
\begin{document}
Hello World!
\end{document}
Binary file added tests/packages/ps_doc/doc/test_image.ps
Binary file not shown.
Empty file.
Empty file.
7 changes: 7 additions & 0 deletions tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ def get_doc_package_path():
return os.path.join(os.path.dirname(__file__), "packages", "doc")


def get_ps_doc_package_path():
"""
Get path to package for testing `doc` command (version with ps images) (/test/packages/ps_doc)
"""
return os.path.join(os.path.dirname(__file__), "packages", "ps_doc")


def get_long_name_package_path():
"""
Get path to package with long name (/test/packages/long_package_name)
Expand Down

0 comments on commit dbc592a

Please sign in to comment.