Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark troublesome encodings with xfail #44

Merged
merged 2 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion django_large_image/rest/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def thumbnail(self, request: Request, pk: int = None, fmt: str = 'png') -> HttpR
encoding = tilesource.format_to_encoding(fmt)
width = int(self.get_query_param(request, 'max_width', 256))
height = int(self.get_query_param(request, 'max_height', 256))
source = self.get_tile_source(request, pk)
source = self.get_tile_source(request, pk, encoding=encoding)
thumb_data, mime_type = source.getThumbnail(encoding=encoding, width=width, height=height)
Comment on lines -38 to 39
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@manthey, should we open an image with the same encoding as we are requesting for the thumbnail? Or should this not matter? What do you recommend?

return HttpResponse(thumb_data, content_type=mime_type)

Expand Down
12 changes: 12 additions & 0 deletions project/example/core/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,25 @@
from pytest_factoryboy import register
from rest_framework.test import APIClient

from django_large_image.tilesource import get_formats

from .factories import ImageFileFactory, S3ImageFileFactory, UserFactory

register(UserFactory)
register(ImageFileFactory)
register(S3ImageFileFactory)


def get_format_params():
fmts = []
for fmt in get_formats():
if fmt in ['pcx', 'eps', 'mpo', 'palm', 'pdf', 'xbm']:
fmts.append(pytest.param(fmt, marks=pytest.mark.xfail))
else:
fmts.append(fmt)
return fmts


@pytest.fixture
def api_client() -> APIClient:
return APIClient()
Expand Down
8 changes: 5 additions & 3 deletions project/example/core/tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
import pytest
from rest_framework import status

from django_large_image.tilesource import get_formats, get_mime_type
from django_large_image.tilesource import get_mime_type

from .conftest import get_format_params


@pytest.mark.django_db(transaction=True)
@pytest.mark.parametrize('format', get_formats())
@pytest.mark.parametrize('format', get_format_params())
def test_thumbnail(authenticated_api_client, image_file_geotiff, format):
response = authenticated_api_client.get(
f'/api/image-file/{image_file_geotiff.pk}/data/thumbnail.{format}'
Expand Down Expand Up @@ -65,7 +67,7 @@ def test_pixel(authenticated_api_client, image_file_geotiff):


@pytest.mark.django_db(transaction=True)
@pytest.mark.parametrize('format', get_formats())
@pytest.mark.parametrize('format', get_format_params())
def test_region_pixel(authenticated_api_client, image_file_geotiff, ome_image, format):
response = authenticated_api_client.get(
f'/api/image-file/{image_file_geotiff.pk}/data/region.{format}?left=0&right=10&bottom=10&top=0&units=pixels'
Expand Down
6 changes: 4 additions & 2 deletions project/example/core/tests/test_tiles.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import pytest
from rest_framework import status

from django_large_image.tilesource import get_formats, get_mime_type
from django_large_image.tilesource import get_mime_type

from .conftest import get_format_params


@pytest.mark.django_db(transaction=True)
Expand All @@ -23,7 +25,7 @@ def test_tile(authenticated_api_client, image_file_geotiff):


@pytest.mark.django_db(transaction=True)
@pytest.mark.parametrize('format', get_formats())
@pytest.mark.parametrize('format', get_format_params())
def test_tile_formats(authenticated_api_client, image_file_geotiff, format):
response = authenticated_api_client.get(
f'/api/image-file/{image_file_geotiff.pk}/tiles/1/0/0.{format}?projection=EPSG:3857'
Expand Down