Skip to content

Commit

Permalink
Merge pull request #394 from PyAr/pt-supertarball
Browse files Browse the repository at this point in the history
Added a complete tarball to portuguese cdpedia.
  • Loading branch information
facundobatista authored Jun 20, 2021
2 parents a1ff397 + 03e2bec commit 6748258
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 6 additions & 0 deletions imagtypes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ ay:

# Portuguese
pt:
tarbig: # we aim for 10-20 GB
type: tarball
windows: True
page_limit: 5000000
image_reduction: [10, 20, 60, 10]

beta:
type: tarball
windows: True
Expand Down
14 changes: 8 additions & 6 deletions tests/test_images_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from unittest.mock import patch

import pytest
from PIL import Image

from src.images.download import optimize_png, download, FetchingError, optimize_image

Expand Down Expand Up @@ -139,7 +140,7 @@ def test_download_problems(tmp_path):
assert _download_mock.call_count == 2


def test_optimize_pil_error_open(tmp_path, logs):
def test_optimize_pil_error_unidentified(tmp_path, logs):
tmp_image = tmp_path / "foo.png"
tmp_image.write_text("not really a PNG, this will cause PIL to crash on open")

Expand All @@ -148,10 +149,11 @@ def test_optimize_pil_error_open(tmp_path, logs):
assert msg in logs.debug


def test_optimize_pil_error_save(logs, image_config):
img_path, _ = image_config("foo.png")
with patch('PIL.PngImagePlugin.PngImageFile.save') as mock:
def test_optimize_pil_error_generic(tmp_path, logs):
tmp_image = tmp_path / "foo.png"
tmp_image.write_text("stuff")
with patch.object(Image, 'open') as mock:
mock.side_effect = ValueError("pumba")
optimize_image(str(img_path))
msg = r"PIL optimization failed: ValueError\('pumba'\) when processing '.*/foo.png'"
optimize_image(str(tmp_image))
msg = r"PIL optimization failed: ValueError\('pumba'.*\) when processing '.*foo.png'"
assert msg in logs.debug

0 comments on commit 6748258

Please sign in to comment.