Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Add tests for WEBP output
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvkb committed Apr 8, 2022
1 parent 9ee8d4f commit 32868e6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions api/test/audio_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
stats,
thumb,
thumb_compression,
thumb_webp,
)

import pytest
Expand Down Expand Up @@ -78,5 +79,9 @@ def test_audio_thumb_compression(audio_fixture):
thumb_compression(audio_fixture)


def test_audio_thumb_webp(audio_fixture):
thumb_webp(audio_fixture)


def test_audio_report(audio_fixture):
report("audio", audio_fixture)
5 changes: 5 additions & 0 deletions api/test/image_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
stats,
thumb,
thumb_compression,
thumb_webp,
)
from urllib.parse import urlencode

Expand Down Expand Up @@ -77,6 +78,10 @@ def test_image_thumb_compression(image_fixture):
thumb_compression(image_fixture)


def test_image_thumb_webp(image_fixture):
thumb_webp(image_fixture)


def test_audio_report(image_fixture):
report("images", image_fixture)

Expand Down
11 changes: 11 additions & 0 deletions api/test/media_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,17 @@ def thumb_compression(fixture):
assert compressed_size < actual_size


def thumb_webp(fixture):
thumbnail_url = fixture["results"][0]["thumbnail"]

thumbnail_response = requests.get(thumbnail_url, headers={"Accept": "image/*,*/*"})
assert thumbnail_response.headers["Content-Type"] != "image/webp"
thumbnail_response = requests.get(
thumbnail_url, headers={"Accept": "image/webp,image/*,*/*"}
)
assert thumbnail_response.headers["Content-Type"] == "image/webp"


def report(media_type, fixture):
test_id = fixture["results"][0]["id"]
response = requests.post(
Expand Down

0 comments on commit 32868e6

Please sign in to comment.