diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 29c27deb5e7f977054554d605cf54c0aeff158ba..4eab49cb03b4fa81fdbb7831183a512987a6d89c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -72,7 +72,12 @@ stages: - apt install git - apt install -y xvfb # Virtual framebuffer for GL stuff. - pwd - - ls + - add-apt-repository universe + - add-apt-repository ppa:inkscape.dev/stable + - apt-get update + - apt install -y inkscape + - pip install -y Pillow + - pip install -e ./ # - apt install -y swig # build-essential python-dev swig python-pygame # This is for swig. Remove when you go to a conda build system (and see what happens). # - pip install -U -r ../02465students/requirements_pip.txt --no-cache --upgrade # - pip install -U -r ../02465students/requirements_conda.txt --no-cache --upgrade diff --git a/pages/index.html b/pages/index.html new file mode 100644 index 0000000000000000000000000000000000000000..827aeaf1a08e307c4eb55065a5a4732673b6d0c6 --- /dev/null +++ b/pages/index.html @@ -0,0 +1,4 @@ +<html><body> +<h1>Stuff here</h1> + +</body></html> \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 7e386127967d6f5ae0c9be2e433e6b542061de6b..9f3665a9a519d98ad8d1055b0f57ac2ae4213aa4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,3 +8,5 @@ matplotlib pylatexenc beautifulsoup4 PyPDF2 +# These requirements are for the test system. +Pillow \ No newline at end of file diff --git a/tests/expected/index_a.png b/tests/expected/index_a.png new file mode 100644 index 0000000000000000000000000000000000000000..6fb5c787df048ab160ffdeac8b2c7102efbfecf4 Binary files /dev/null and b/tests/expected/index_a.png differ diff --git a/tests/expected/index_b.png b/tests/expected/index_b.png new file mode 100644 index 0000000000000000000000000000000000000000..528492623cffc4d1771567f6178f5610d3883682 Binary files /dev/null and b/tests/expected/index_b.png differ diff --git a/tests/expected/index_front.png b/tests/expected/index_front.png new file mode 100644 index 0000000000000000000000000000000000000000..5a5a57b62a8a2003acf0f47c38a004ca24b27dbe Binary files /dev/null and b/tests/expected/index_front.png differ diff --git a/tests/set_expected_output.py b/tests/set_expected_output.py index 8b137891791fe96927ad78e64b0aad7bded08bdc..4a57084b76bba1365415d37791d13e95875cc293 100644 --- a/tests/set_expected_output.py +++ b/tests/set_expected_output.py @@ -1 +1,16 @@ +import os.path +import shutil +from slider.convert import pdf2png +if __name__ == "__main__": + from test_slider import TestSlider + TestSlider.setUpClass() + if not os.path.isdir("expected"): + os.makedirs("expected") + + shutil.move("automatic/index_a.png", "expected/index_a.png") + pdf2png("automatic/index.pdf", fout="expected/index_front.png", page_to_convert=1) + shutil.move("automatic/index_b.png", "expected/index_b.png") + TestSlider.tearDownClass() + + a = 234 \ No newline at end of file diff --git a/tests/test_images/index_a.png b/tests/test_images/index_a.png new file mode 100644 index 0000000000000000000000000000000000000000..6fb5c787df048ab160ffdeac8b2c7102efbfecf4 Binary files /dev/null and b/tests/test_images/index_a.png differ diff --git a/tests/test_images/index_b.png b/tests/test_images/index_b.png new file mode 100644 index 0000000000000000000000000000000000000000..528492623cffc4d1771567f6178f5610d3883682 Binary files /dev/null and b/tests/test_images/index_b.png differ diff --git a/tests/test_images/index_front.png b/tests/test_images/index_front.png new file mode 100644 index 0000000000000000000000000000000000000000..5a5a57b62a8a2003acf0f47c38a004ca24b27dbe Binary files /dev/null and b/tests/test_images/index_front.png differ diff --git a/tests/test_slider.py b/tests/test_slider.py index f60cbe0d51b42c4e42ae854107d62a048e8da484..ddc4805ca77dfc1dbdb7e221780edc923dd0fbc1 100644 --- a/tests/test_slider.py +++ b/tests/test_slider.py @@ -8,6 +8,9 @@ import os import subprocess from slider.convert import pdf2png from slider.slider_cli import slider_cli +# import sys +# sys.path.append(os.path.dirname(os.path.abspath(__file__)) +"/../src") + def assert_images_equal(image_1: str, image_2: str): img1 = Image.open(image_1) @@ -28,15 +31,21 @@ def assert_images_equal(image_1: str, image_2: str): class TestSlider(TestCase): + @classmethod def tearDownClass(cls) -> None: if os.path.isdir("./automatic"): shutil.rmtree("./automatic") + @classmethod def setUpClass(cls) -> None: # Generate the output files. if os.path.isdir("./automatic"): shutil.rmtree("./automatic") - os.mkdir("automatic") + os.mkdir("automatic") + + if os.path.isdir("./test_images"): + shutil.rmtree("./test_images") + os.mkdir("./test_images") slider_cli("automatic/index.tex", interactive=False) @@ -58,20 +67,18 @@ class TestSlider(TestCase): with open(fn, 'w') as f: f.write(ss) slider_cli("automatic/index.tex", interactive=False) - pdf2png("automatic/index.pdf", fout="automatic/index_b.png", page_to_convert=2) - a = 234 - pass - def test_frontpage(self): - pass + shutil.copyfile("automatic/index_a.png", "test_images/index_a.png") + shutil.copyfile("automatic/index_b.png", "test_images/index_b.png") + pdf2png("automatic/index.pdf", fout="test_images/index_front.png", page_to_convert=1) + shutil.copyfile("automatic/index.pdf", "test_images/index.pdf") def test_second_page_before_compile(self): - pass + assert_images_equal("automatic/index_a.png", "expected/index_a.png") def test_second_page_after_compile(self): - - pass + assert_images_equal("automatic/index_b.png", "expected/index_b.png")