MCPcopy
hub / github.com/scrapy/scrapy / test_get_images

Method test_get_images

tests/test_pipeline_images.py:156–177  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

154 next(self.pipeline.get_images(response=resp3, request=req, info=object()))
155
156 def test_get_images(self):
157 self.pipeline.min_width = 0
158 self.pipeline.min_height = 0
159 self.pipeline.thumbs = {"small": (20, 20)}
160
161 orig_im, buf = _create_image("JPEG", "RGB", (50, 50), (0, 0, 0))
162 _, orig_thumb_buf = _create_image("JPEG", "RGB", (20, 20), (0, 0, 0))
163 resp = Response(url="https://dev.mydeco.com/mydeco.gif", body=buf.getvalue())
164 req = Request(url="https://dev.mydeco.com/mydeco.gif")
165
166 get_images_gen = self.pipeline.get_images(
167 response=resp, request=req, info=object()
168 )
169
170 path, new_im, new_buf = next(get_images_gen)
171 assert path == "full/3fd165099d8e71b8a48b2683946e64dbfad8b52d.jpg"
172 assert orig_im.copy() == new_im
173 assert buf.getvalue() == new_buf.getvalue()
174
175 thumb_path, _, thumb_buf = next(get_images_gen)
176 assert thumb_path == "thumbs/small/3fd165099d8e71b8a48b2683946e64dbfad8b52d.jpg"
177 assert orig_thumb_buf.getvalue() == thumb_buf.getvalue()
178
179 def test_get_transposed_images(self):
180 orig_im = Image.new("RGB", (2, 2), (0, 0, 0))

Callers

nothing calls this directly

Calls 5

ResponseClass · 0.90
RequestClass · 0.90
_create_imageFunction · 0.85
get_imagesMethod · 0.80
copyMethod · 0.45

Tested by

no test coverage detected