Skip to content

Commit

Permalink
Add test for _burn_overlay hack
Browse files Browse the repository at this point in the history
  • Loading branch information
djhoese committed May 27, 2020
1 parent e73308f commit 85d9a06
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions trollimage/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -2004,3 +2004,22 @@ def dummy_fun(pil_obj, *args, **kwargs):
self.assertEqual(dummy_args, [({}, ), {}])
res.data.data.compute()
self.assertEqual(dummy_args, [(OrderedDict(), 'Hey', 'Jude'), {'chorus': "La lala lalalala"}])

# Test HACK for _burn_overlay
dummy_args = [(OrderedDict(), ), {}]

def _burn_overlay(pil_obj, *args, **kwargs):
dummy_args[0] = args
dummy_args[1] = kwargs
return pil_obj

img = xrimage.XRImage(data)
with mock.patch.object(xrimage, "PILImage") as pi:
pil_img = mock.MagicMock()
pi.fromarray = mock.Mock(wraps=lambda *args, **kwargs: pil_img)
res = img.apply_pil(_burn_overlay, 'RGB')
# check that the pil image generation is delayed
pi.fromarray.assert_not_called()
# make it happen
res.data.data.compute()
pil_img.convert.assert_called_with('RGB')

0 comments on commit 85d9a06

Please sign in to comment.