Skip to content

Commit

Permalink
Adds screenshot testing
Browse files Browse the repository at this point in the history
  • Loading branch information
stumpylog committed Feb 29, 2024
1 parent c3d08b6 commit d418b29
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/test_convert_chromium_screenshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"

0 comments on commit d418b29

Please sign in to comment.