From f3d4929638b6bb6dbf2788a0ea1df1e57ed9b542 Mon Sep 17 00:00:00 2001 From: J0J0 Todos Date: Fri, 21 Apr 2023 19:51:09 +0200 Subject: [PATCH] Fix embedart -u test names and shorten second and third test a little by providing -y cli flag. Enough to test with interactive input once. Move all 3 tests to the very bottom of the test class. --- test/test_embedart.py | 70 +++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/test/test_embedart.py b/test/test_embedart.py index 222fc36fa..814340e17 100644 --- a/test/test_embedart.py +++ b/test/test_embedart.py @@ -75,42 +75,6 @@ class EmbedartCliTest(TestHelper, FetchImageHelper): mediafile = MediaFile(syspath(item.path)) self.assertEqual(mediafile.images[0].data, self.image_data) - def test_embed_art_from_url_with_yes_input(self): - self._setup_data() - album = self.add_album_fixture() - item = album.items()[0] - self.mock_response('http://example.com/test.jpg', 'image/jpeg') - self.io.addinput('y') - self.run_command('embedart', '-u', 'http://example.com/test.jpg') - mediafile = MediaFile(syspath(item.path)) - self.assertEqual( - mediafile.images[0].data, - self.IMAGEHEADER.get('image/jpeg').ljust(32, b'\x00') - ) - - def test_embed_art_png_from_file_with_yes_input(self): - self._setup_data() - album = self.add_album_fixture() - item = album.items()[0] - self.mock_response('http://example.com/test.png', 'image/png') - self.io.addinput('y') - self.run_command('embedart', '-u', 'http://example.com/test.png') - mediafile = MediaFile(syspath(item.path)) - self.assertEqual( - mediafile.images[0].data, - self.IMAGEHEADER.get('image/png').ljust(32, b'\x00')) - - # test embedart with url that does not have a valid image - def test_embed_art_from_url_with_yes_input_not_image(self): - self._setup_data() - album = self.add_album_fixture() - item = album.items()[0] - self.mock_response('http://example.com/test.txt', 'text/html') - self.io.addinput('y') - self.run_command('embedart', '-u', 'http://example.com/test.txt') - mediafile = MediaFile(syspath(item.path)) - self.assertFalse(mediafile.images) - def test_embed_art_from_file_with_no_input(self): self._setup_data() album = self.add_album_fixture() @@ -253,6 +217,40 @@ class EmbedartCliTest(TestHelper, FetchImageHelper): mediafile = MediaFile(syspath(item.path)) self.assertEqual(mediafile.images[0].data, self.image_data) + def test_embed_art_from_url_with_yes_input(self): + self._setup_data() + album = self.add_album_fixture() + item = album.items()[0] + self.mock_response('http://example.com/test.jpg', 'image/jpeg') + self.io.addinput('y') + self.run_command('embedart', '-u', 'http://example.com/test.jpg') + mediafile = MediaFile(syspath(item.path)) + self.assertEqual( + mediafile.images[0].data, + self.IMAGEHEADER.get('image/jpeg').ljust(32, b'\x00') + ) + + def test_embed_art_from_url_png(self): + self._setup_data() + album = self.add_album_fixture() + item = album.items()[0] + self.mock_response('http://example.com/test.png', 'image/png') + self.run_command('embedart', '-y', '-u', 'http://example.com/test.png') + mediafile = MediaFile(syspath(item.path)) + self.assertEqual( + mediafile.images[0].data, + self.IMAGEHEADER.get('image/png').ljust(32, b'\x00') + ) + + def test_embed_art_from_url_not_image(self): + self._setup_data() + album = self.add_album_fixture() + item = album.items()[0] + self.mock_response('http://example.com/test.txt', 'text/html') + self.run_command('embedart', '-y', '-u', 'http://example.com/test.txt') + mediafile = MediaFile(syspath(item.path)) + self.assertFalse(mediafile.images) + class DummyArtResizer(ArtResizer): """An `ArtResizer` which pretends that ImageMagick is available, and has