From c693015a56b37f8ba580ec9baa986f89512f718d Mon Sep 17 00:00:00 2001 From: Trenton Holmes <797416+stumpylog@users.noreply.github.com> Date: Wed, 24 Jan 2024 21:04:36 -0800 Subject: [PATCH] Adds screenshot testing --- tests/test_convert_chromium_screenshots.py | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_convert_chromium_screenshots.py b/tests/test_convert_chromium_screenshots.py index 1ac6151..f831cb6 100644 --- a/tests/test_convert_chromium_screenshots.py +++ b/tests/test_convert_chromium_screenshots.py @@ -5,6 +5,7 @@ from httpx import codes from gotenberg_client import GotenbergClient +from tests.conftest import SAMPLE_DIR from tests.conftest import SAVE_DIR from tests.conftest import SAVE_OUTPUTS @@ -123,3 +124,26 @@ def test_status_codes_empty(self, client: GotenbergClient): assert resp.headers["Content-Type"] == "image/png" if SAVE_OUTPUTS: (SAVE_DIR / "test_screenshot_optimize_quality.png").write_bytes(resp.content) + + +class TestChromiumScreenshotsFromMarkdown: + def test_markdown_screenshot(self, client: GotenbergClient): + test_file = SAMPLE_DIR / "basic.html" + md_files = [SAMPLE_DIR / "markdown1.md", SAMPLE_DIR / "markdown2.md"] + + with client.chromium.screenshot_markdown() as route: + resp = route.index(test_file).resources(md_files).run_with_retry() + assert resp.status_code == codes.OK + assert "Content-Type" in resp.headers + assert resp.headers["Content-Type"] == "image/png" + + +class TestChromiumScreenshotsFromHtml: + def test_markdown_screenshot(self, client: GotenbergClient): + test_file = SAMPLE_DIR / "basic.html" + + with client.chromium.screenshot_html() as route: + resp = route.index(test_file).run_with_retry() + assert resp.status_code == codes.OK + assert "Content-Type" in resp.headers + assert resp.headers["Content-Type"] == "image/png"