Skip to content

Commit

Permalink
Image downloader test fixed: #24
Browse files Browse the repository at this point in the history
  • Loading branch information
Artiom N. committed Apr 27, 2024
1 parent a1d14ee commit 8a85980
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions tests/test_image_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ def setup_method(self):
self._image_in_relpath = f'{self._article_images_path.name}/{self._image_filename}'
self._out_image_filepath = self._images_out_path / self._image_filename

self._out_path_maker = OutPathMaker(
article_file_path=self._article_out_path,
article_base_url=str(self._article_base_path),
img_dir_name=self._images_out_path,
img_public_path=Path('images'),
save_hierarchy=False,
)

def teardown_method(self):
self._out_image_filepath.unlink(missing_ok=True)

Expand All @@ -29,16 +37,8 @@ def remove_target_image(self):
yield

def test_local_downloading(self):
out_path_maker = OutPathMaker(
article_file_path=self._article_out_path,
article_base_url=str(self._article_base_path),
img_dir_name=self._images_out_path,
img_public_path=Path('images'),
save_hierarchy=False,
)

image_downloader = ImageDownloader(
out_path_maker=out_path_maker,
out_path_maker=self._out_path_maker,
skip_list=[],
skip_all_errors=False,
download_incorrect_mime_types=True,
Expand All @@ -51,16 +51,8 @@ def test_local_downloading(self):
assert compare_files(self._article_images_path / self._image_filename, self._out_image_filepath)

def test_resizing(self):
out_path_maker = OutPathMaker(
article_file_path=self._article_out_path,
article_base_url=str(self._article_base_path),
img_dir_name=self._images_out_path,
img_public_path=Path('images'),
save_hierarchy=False,
)

image_downloader = ImageDownloader(
out_path_maker=out_path_maker,
out_path_maker=self._out_path_maker,
skip_list=[],
skip_all_errors=False,
download_incorrect_mime_types=True,
Expand All @@ -73,6 +65,6 @@ def test_resizing(self):
image_downloader.download_images([ImageLink(self._image_in_relpath, new_size=(w, h))])

assert not compare_files(self._article_images_path / self._image_filename, self._out_image_filepath)
img = Image.open(self._out_image_filepath)
assert img.width == w
assert img.height == h
with Image.open(self._out_image_filepath) as img:
assert img.width == w
assert img.height == h

0 comments on commit 8a85980

Please sign in to comment.