<s> """<STR_LIT>""" <EOL> from __future__ import division , absolute_import , print_function <EOL> import os <EOL> import shutil <EOL> import responses <EOL> from mock import patch <EOL> from test import _common <EOL> from test . _common import unittest <EOL> from beetsplug import fetchart <EOL> from beets . autotag import AlbumInfo , AlbumMatch <EOL> from beets import config <EOL> from beets import library <EOL> from beets import importer <EOL> from beets import logging <EOL> from beets import util <EOL> from beets . util . artresizer import ArtResizer , WEBPROXY <EOL> from beets . util import confit <EOL> logger = logging . getLogger ( '<STR_LIT>' ) <EOL> class UseThePlugin ( _common . TestCase ) : <EOL> def setUp ( self ) : <EOL> super ( UseThePlugin , self ) . setUp ( ) <EOL> self . plugin = fetchart . FetchArtPlugin ( ) <EOL> class FetchImageTest ( UseThePlugin ) : <EOL> URL = '<STR_LIT>' <EOL> @ responses . activate <EOL> def run ( self , * args , ** kwargs ) : <EOL> super ( FetchImageTest , self ) . run ( * args , ** kwargs ) <EOL> def mock_response ( self , content_type ) : <EOL> responses . add ( responses . GET , self . URL , <EOL> content_type = content_type ) <EOL> def setUp ( self ) : <EOL> super ( FetchImageTest , self ) . setUp ( ) <EOL> self . dpath = os . path . join ( self . temp_dir , '<STR_LIT>' ) <EOL> self . source = fetchart . RemoteArtSource ( logger , self . plugin . config ) <EOL> self . extra = { '<STR_LIT>' : <NUM_LIT:0> } <EOL> def test_invalid_type_returns_none ( self ) : <EOL> self . mock_response ( '<STR_LIT>' ) <EOL> candidate = fetchart . Candidate ( logger , url = self . URL ) <EOL> self . source . fetch_image ( candidate , self . extra ) <EOL> self . assertEqual ( candidate . path , None ) <EOL> def test_jpeg_type_returns_path ( self ) : <EOL> self . mock_response ( '<STR_LIT>' ) <EOL> candidate = fetchart . Candidate ( logger , url = self . URL ) <EOL> self . source . fetch_image ( candidate , self . extra ) <EOL> self . assertNotEqual ( candidate . path , None ) <EOL> class FSArtTest ( UseThePlugin ) : <EOL> def setUp ( self ) : <EOL> super ( FSArtTest , self ) . setUp ( ) <EOL> self . dpath = os . path . join ( self . temp_dir , '<STR_LIT>' ) <EOL> os . mkdir ( self . dpath ) <EOL> self . source = fetchart . FileSystem ( logger , self . plugin . config ) <EOL> self . extra = { '<STR_LIT>' : False , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , ) , <EOL> '<STR_LIT>' : [ self . dpath ] } <EOL> def test_finds_jpg_in_directory ( self ) : <EOL> _common . touch ( os . path . join ( self . dpath , '<STR_LIT>' ) ) <EOL> candidate = next ( self . source . get ( None , self . extra ) ) <EOL> self . assertEqual ( candidate . path , os . path . join ( self . dpath , '<STR_LIT>' ) ) <EOL> def test_appropriately_named_file_takes_precedence ( self ) : <EOL> _common . touch ( os . path . join ( self . dpath , '<STR_LIT>' ) ) <EOL> _common . touch ( os . path . join ( self . dpath , '<STR_LIT>' ) ) <EOL> candidate = next ( self . source . get ( None , self . extra ) ) <EOL> self . assertEqual ( candidate . path , os . path . join ( self . dpath , '<STR_LIT>' ) ) <EOL> def test_non_image_file_not_identified ( self ) : <EOL> _common . touch ( os . path . join ( self . dpath , '<STR_LIT>' ) ) <EOL> with self . assertRaises ( StopIteration ) : <EOL> next ( self . source . get ( None , self . extra ) ) <EOL> def test_cautious_skips_fallback ( self ) : <EOL> _common . touch ( os . path . join ( self . dpath , '<STR_LIT>' ) ) <EOL> self . extra [ '<STR_LIT>' ] = True <EOL> with self . assertRaises ( StopIteration ) : <EOL> next ( self . source . get ( None , self . extra ) ) <EOL> def test_empty_dir ( self ) : <EOL> with self . assertRaises ( StopIteration ) : <EOL> next ( self . source . get ( None , self . extra ) ) <EOL> def test_precedence_amongst_correct_files ( self ) : <EOL> images = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> paths = [ os . path . join ( self . dpath , i ) for i in images ] <EOL> for p in paths : <EOL> _common . touch ( p ) <EOL> self . extra [ '<STR_LIT>' ] = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> candidates = [ candidate . path for candidate in <EOL> self . source . get ( None , self . extra ) ] <EOL> self . assertEqual ( candidates , paths ) <EOL> class CombinedTest ( UseThePlugin ) : <EOL> ASIN = '<STR_LIT>' <EOL> MBID = '<STR_LIT>' <EOL> AMAZON_URL = '<STR_LIT>' . format ( ASIN ) <EOL> AAO_URL = '<STR_LIT>' . format ( ASIN ) <EOL> CAA_URL = '<STR_LIT>' . format ( MBID ) <EOL> def setUp ( self ) : <EOL> super ( CombinedTest , self ) . setUp ( ) <EOL> self . dpath = os . path . join ( self . temp_dir , '<STR_LIT>' ) <EOL> os . mkdir ( self . dpath ) <EOL> @ responses . activate <EOL> def run ( self , * args , ** kwargs ) : <EOL> super ( CombinedTest , self ) . run ( * args , ** kwargs ) <EOL> def mock_response ( self , url , content_type = '<STR_LIT>' ) : <EOL> responses . add ( responses . GET , url , content_type = content_type ) <EOL> def test_main_interface_returns_amazon_art ( self ) : <EOL> self . mock_response ( self . AMAZON_URL ) <EOL> album = _common . Bag ( asin = self . ASIN ) <EOL> candidate = self . plugin . art_for_album ( album , None ) <EOL> self . assertIsNotNone ( candidate ) <EOL> def test_main_interface_returns_none_for_missing_asin_and_path ( self ) : <EOL> album = _common . Bag ( ) <EOL> candidate = self . plugin . art_for_album ( album , None ) <EOL> self . assertIsNone ( candidate ) <EOL> def test_main_interface_gives_precedence_to_fs_art ( self ) : <EOL> _common . touch ( os . path . join ( self . dpath , '<STR_LIT>' ) ) <EOL> self . mock_response ( self . AMAZON_URL ) <EOL> album = _common . Bag ( asin = self . ASIN ) <EOL> candidate = self . plugin . art_for_album ( album , [ self . dpath ] ) <EOL> self . assertIsNotNone ( candidate ) <EOL> self . assertEqual ( candidate . path , os . path . join ( self . dpath , '<STR_LIT>' ) ) <EOL> def test_main_interface_falls_back_to_amazon ( self ) : <EOL> self . mock_response ( self . AMAZON_URL ) <EOL> album = _common . Bag ( asin = self . ASIN ) <EOL> candidate = self . plugin . art_for_album ( album , [ self . dpath ] ) <EOL> self . assertIsNotNone ( candidate ) <EOL> self . assertFalse ( candidate . path . startswith ( self . dpath ) ) <EOL> def test_main_interface_tries_amazon_before_aao ( self ) : <EOL> self . mock_response ( self . AMAZON_URL ) <EOL> album = _common . Bag ( asin = self . ASIN ) <EOL> self . plugin . art_for_album ( album , [ self . dpath ] ) <EOL> self . assertEqual ( len ( responses . calls ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( responses . calls [ <NUM_LIT:0> ] . request . url , self . AMAZON_URL ) <EOL> def test_main_interface_falls_back_to_aao ( self ) : <EOL> self . mock_response ( self . AMAZON_URL , content_type = '<STR_LIT>' ) <EOL> album = _common . Bag ( asin = self . ASIN ) <EOL> self . plugin . art_for_album ( album , [ self . dpath ] ) <EOL> self . assertEqual ( responses . calls [ - <NUM_LIT:1> ] . request . url , self . AAO_URL ) <EOL> def test_main_interface_uses_caa_when_mbid_available ( self ) : <EOL> self . mock_response ( self . CAA_URL ) <EOL> album = _common . Bag ( mb_albumid = self . MBID , asin = self . ASIN ) <EOL> candidate = self . plugin . art_for_album ( album , None ) <EOL> self . assertIsNotNone ( candidate ) <EOL> self . assertEqual ( len ( responses . calls ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( responses . calls [ <NUM_LIT:0> ] . request . url , self . CAA_URL ) <EOL> def test_local_only_does_not_access_network ( self ) : <EOL> album = _common . Bag ( mb_albumid = self . MBID , asin = self . ASIN ) <EOL> self . plugin . art_for_album ( album , None , local_only = True ) <EOL> self . assertEqual ( len ( responses . calls ) , <NUM_LIT:0> ) <EOL> def test_local_only_gets_fs_image ( self ) : <EOL> _common . touch ( os . path . join ( self . dpath , '<STR_LIT>' ) ) <EOL> album = _common . Bag ( mb_albumid = self . MBID , asin = self . ASIN ) <EOL> candidate = self . plugin . art_for_album ( album , [ self . dpath ] , <EOL> local_only = True ) <EOL> self . assertIsNotNone ( candidate ) <EOL> self . assertEqual ( candidate . path , os . path . join ( self . dpath , '<STR_LIT>' ) ) <EOL> self . assertEqual ( len ( responses . calls ) , <NUM_LIT:0> ) <EOL> class AAOTest ( UseThePlugin ) : <EOL> ASIN = '<STR_LIT>' <EOL> AAO_URL = '<STR_LIT>' . format ( ASIN ) <EOL> def setUp ( self ) : <EOL> super ( AAOTest , self ) . setUp ( ) <EOL> self . source = fetchart . AlbumArtOrg ( logger , self . plugin . config ) <EOL> self . extra = dict ( ) <EOL> @ responses . activate <EOL> def run ( self , * args , ** kwargs ) : <EOL> super ( AAOTest , self ) . run ( * args , ** kwargs ) <EOL> def mock_response ( self , url , body ) : <EOL> responses . add ( responses . GET , url , body = body , content_type = '<STR_LIT>' , <EOL> match_querystring = True ) <EOL> def test_aao_scraper_finds_image ( self ) : <EOL> body = b"""<STR_LIT>""" <EOL> self . mock_response ( self . AAO_URL , body ) <EOL> album = _common . Bag ( asin = self . ASIN ) <EOL> candidate = next ( self . source . get ( album , self . extra ) ) <EOL> self . assertEqual ( candidate . url , '<STR_LIT>' ) <EOL> def test_aao_scraper_returns_no_result_when_no_image_present ( self ) : <EOL> self . mock_response ( self . AAO_URL , b'<STR_LIT>' ) <EOL> album = _common . Bag ( asin = self . ASIN ) <EOL> with self . assertRaises ( StopIteration ) : <EOL> next ( self . source . get ( album , self . extra ) ) <EOL> class GoogleImageTest ( UseThePlugin ) : <EOL> def setUp ( self ) : <EOL> super ( GoogleImageTest , self ) . setUp ( ) <EOL> self . source = fetchart . GoogleImages ( logger , self . plugin . config ) <EOL> self . extra = dict ( ) <EOL> @ responses . activate <EOL> def run ( self , * args , ** kwargs ) : <EOL> super ( GoogleImageTest , self ) . run ( * args , ** kwargs ) <EOL> def mock_response ( self , url , json ) : <EOL> responses . add ( responses . GET , url , body = json , <EOL> content_type = '<STR_LIT:application/json>' ) <EOL> def test_google_art_finds_image ( self ) : <EOL> album = _common . Bag ( albumartist = "<STR_LIT>" , album = "<STR_LIT>" ) <EOL> json = b'<STR_LIT>' <EOL> self . mock_response ( fetchart . GoogleImages . URL , json ) <EOL> candidate = next ( self . source . get ( album , self . extra ) ) <EOL> self . assertEqual ( candidate . url , '<STR_LIT>' ) <EOL> def test_google_art_returns_no_result_when_error_received ( self ) : <EOL> album = _common . Bag ( albumartist = "<STR_LIT>" , album = "<STR_LIT>" ) <EOL> json = b'<STR_LIT>' <EOL> self . mock_response ( fetchart . GoogleImages . URL , json ) <EOL> with self . assertRaises ( StopIteration ) : <EOL> next ( self . source . get ( album , self . extra ) ) <EOL> def test_google_art_returns_no_result_with_malformed_response ( self ) : <EOL> album = _common . Bag ( albumartist = "<STR_LIT>" , album = "<STR_LIT>" ) <EOL> json = b"""<STR_LIT>""" <EOL> self . mock_response ( fetchart . GoogleImages . URL , json ) <EOL> with self . assertRaises ( StopIteration ) : <EOL> next ( self . source . get ( album , self . extra ) ) <EOL> class FanartTVTest ( UseThePlugin ) : <EOL> RESPONSE_MULTIPLE = u"""<STR_LIT>""" <EOL> RESPONSE_NO_ART = u"""<STR_LIT>""" <EOL> RESPONSE_ERROR = u"""<STR_LIT>""" <EOL> RESPONSE_MALFORMED = u"<STR_LIT>" <EOL> def setUp ( self ) : <EOL> super ( FanartTVTest , self ) . setUp ( ) <EOL> self . source = fetchart . FanartTV ( logger , self . plugin . config ) <EOL> self . extra = dict ( ) <EOL> @ responses . activate <EOL> def run ( self , * args , ** kwargs ) : <EOL> super ( FanartTVTest , self ) . run ( * args , ** kwargs ) <EOL> def mock_response ( self , url , json ) : <EOL> responses . add ( responses . GET , url , body = json , <EOL> content_type = '<STR_LIT:application/json>' ) <EOL> def test_fanarttv_finds_image ( self ) : <EOL> album = _common . Bag ( mb_releasegroupid = u'<STR_LIT>' ) <EOL> self . mock_response ( fetchart . FanartTV . API_ALBUMS + u'<STR_LIT>' , <EOL> self . RESPONSE_MULTIPLE ) <EOL> candidate = next ( self . source . get ( album , self . extra ) ) <EOL> self . assertEqual ( candidate . url , '<STR_LIT>' ) <EOL> def test_fanarttv_returns_no_result_when_error_received ( self ) : <EOL> album = _common . Bag ( mb_releasegroupid = u'<STR_LIT>' ) <EOL> self . mock_response ( fetchart . FanartTV . API_ALBUMS + u'<STR_LIT>' , <EOL> self . RESPONSE_ERROR ) <EOL> with self . assertRaises ( StopIteration ) : <EOL> next ( self . source . get ( album , self . extra ) ) <EOL> def test_fanarttv_returns_no_result_with_malformed_response ( self ) : <EOL> album = _common . Bag ( mb_releasegroupid = u'<STR_LIT>' ) <EOL> self . mock_response ( fetchart . FanartTV . API_ALBUMS + u'<STR_LIT>' , <EOL> self . RESPONSE_MALFORMED ) <EOL> with self . assertRaises ( StopIteration ) : <EOL> next ( self . source . get ( album , self . extra ) ) <EOL> def test_fanarttv_only_other_images ( self ) : <EOL> album = _common . Bag ( mb_releasegroupid = u'<STR_LIT>' ) <EOL> self . mock_response ( fetchart . FanartTV . API_ALBUMS + u'<STR_LIT>' , <EOL> self . RESPONSE_NO_ART ) <EOL> with self . assertRaises ( StopIteration ) : <EOL> next ( self . source . get ( album , self . extra ) ) <EOL> @ _common . slow_test ( ) <EOL> class ArtImporterTest ( UseThePlugin ) : <EOL> def setUp ( self ) : <EOL> super ( ArtImporterTest , self ) . setUp ( ) <EOL> self . art_file = os . path . join ( self . temp_dir , '<STR_LIT>' ) <EOL> _common . touch ( self . art_file ) <EOL> self . old_afa = self . plugin . art_for_album <EOL> self . afa_response = fetchart . Candidate ( logger , path = self . art_file ) <EOL> def art_for_album ( i , p , local_only = False ) : <EOL> return self . afa_response <EOL> self . plugin . art_for_album = art_for_album <EOL> self . libpath = os . path . join ( self . temp_dir , '<STR_LIT>' ) <EOL> self . libdir = os . path . join ( self . temp_dir , '<STR_LIT>' ) <EOL> os . mkdir ( self . libdir ) <EOL> os . mkdir ( os . path . join ( self . libdir , '<STR_LIT>' ) ) <EOL> itempath = os . path . join ( self . libdir , '<STR_LIT>' , '<STR_LIT>' ) <EOL> shutil . copyfile ( os . path . join ( _common . RSRC , '<STR_LIT>' ) , itempath ) <EOL> self . lib = library . Library ( self . libpath ) <EOL> self . i = _common . item ( ) <EOL> self . i . path = itempath <EOL> self . album = self . lib . add_album ( [ self . i ] ) <EOL> self . lib . _connection ( ) . commit ( ) <EOL> self . session = _common . import_session ( self . lib ) <EOL> self . task = importer . ImportTask ( None , None , [ self . i ] ) <EOL> self . task . is_album = True <EOL> self . task . album = self . album <EOL> info = AlbumInfo ( <EOL> album = u'<STR_LIT>' , <EOL> album_id = u'<STR_LIT>' , <EOL> artist = u'<STR_LIT>' , <EOL> artist_id = u'<STR_LIT>' , <EOL> tracks = [ ] , <EOL> ) <EOL> self . task . set_choice ( AlbumMatch ( <NUM_LIT:0> , info , { } , set ( ) , set ( ) ) ) <EOL> def tearDown ( self ) : <EOL> self . lib . _connection ( ) . close ( ) <EOL> super ( ArtImporterTest , self ) . tearDown ( ) <EOL> self . plugin . art_for_album = self . old_afa <EOL> def _fetch_art ( self , should_exist ) : <EOL> """<STR_LIT>""" <EOL> self . plugin . fetch_art ( self . session , self . task ) <EOL> self . plugin . assign_art ( self . session , self . task ) <EOL> artpath = self . lib . albums ( ) [ <NUM_LIT:0> ] . artpath <EOL> if should_exist : <EOL> self . assertEqual ( <EOL> artpath , <EOL> os . path . join ( os . path . dirname ( self . i . path ) , '<STR_LIT>' ) <EOL> ) <EOL> self . assertExists ( artpath ) <EOL> else : <EOL> self . assertEqual ( artpath , None ) <EOL> return artpath <EOL> def test_fetch_art ( self ) : <EOL> assert not self . lib . albums ( ) [ <NUM_LIT:0> ] . artpath <EOL> self . _fetch_art ( True ) <EOL> def test_art_not_found ( self ) : <EOL> self . afa_response = None <EOL> self . _fetch_art ( False ) <EOL> def test_no_art_for_singleton ( self ) : <EOL> self . task . is_album = False <EOL> self . _fetch_art ( False ) <EOL> def test_leave_original_file_in_place ( self ) : <EOL> self . _fetch_art ( True ) <EOL> self . assertExists ( self . art_file ) <EOL> def test_delete_original_file ( self ) : <EOL> self . plugin . src_removed = True <EOL> self . _fetch_art ( True ) <EOL> self . assertNotExists ( self . art_file ) <EOL> def test_do_not_delete_original_if_already_in_place ( self ) : <EOL> artdest = os . path . join ( os . path . dirname ( self . i . path ) , '<STR_LIT>' ) <EOL> shutil . copyfile ( self . art_file , artdest ) <EOL> self . afa_response = fetchart . Candidate ( logger , path = artdest ) <EOL> self . _fetch_art ( True ) <EOL> def test_fetch_art_if_imported_file_deleted ( self ) : <EOL> self . _fetch_art ( True ) <EOL> util . remove ( self . album . artpath ) <EOL> self . plugin . batch_fetch_art ( self . lib , self . lib . albums ( ) , force = False ) <EOL> self . assertExists ( self . album . artpath ) <EOL> class ArtForAlbumTest ( UseThePlugin ) : <EOL> """<STR_LIT>""" <EOL> IMG_225x225 = os . path . join ( _common . RSRC , '<STR_LIT>' ) <EOL> IMG_348x348 = os . path . join ( _common . RSRC , '<STR_LIT>' ) <EOL> IMG_500x490 = os . path . join ( _common . RSRC , '<STR_LIT>' ) <EOL> def setUp ( self ) : <EOL> super ( ArtForAlbumTest , self ) . setUp ( ) <EOL> self . old_fs_source_get = fetchart . FileSystem . get <EOL> def fs_source_get ( _self , album , extra ) : <EOL> if extra [ '<STR_LIT>' ] : <EOL> yield fetchart . Candidate ( logger , path = self . image_file ) <EOL> fetchart . FileSystem . get = fs_source_get <EOL> self . album = _common . Bag ( ) <EOL> def tearDown ( self ) : <EOL> fetchart . FileSystem . get = self . old_fs_source_get <EOL> super ( ArtForAlbumTest , self ) . tearDown ( ) <EOL> def _assertImageIsValidArt ( self , image_file , should_exist ) : <EOL> self . assertExists ( image_file ) <EOL> self . image_file = image_file <EOL> candidate = self . plugin . art_for_album ( self . album , [ '<STR_LIT>' ] , True ) <EOL> if should_exist : <EOL> self . assertNotEqual ( candidate , None ) <EOL> self . assertEqual ( candidate . path , self . image_file ) <EOL> self . assertExists ( candidate . path ) <EOL> else : <EOL> self . assertIsNone ( candidate ) <EOL> def _assertImageResized ( self , image_file , should_resize ) : <EOL> self . image_file = image_file <EOL> with patch . object ( ArtResizer . shared , '<STR_LIT>' ) as mock_resize : <EOL> self . plugin . art_for_album ( self . album , [ '<STR_LIT>' ] , True ) <EOL> self . assertEqual ( mock_resize . called , should_resize ) <EOL> def _require_backend ( self ) : <EOL> """<STR_LIT>""" <EOL> if ArtResizer . shared . method [ <NUM_LIT:0> ] == WEBPROXY : <EOL> self . skipTest ( u"<STR_LIT>" ) <EOL> def test_respect_minwidth ( self ) : <EOL> self . _require_backend ( ) <EOL> self . plugin . minwidth = <NUM_LIT> <EOL> self . _assertImageIsValidArt ( self . IMG_225x225 , False ) <EOL> self . _assertImageIsValidArt ( self . IMG_348x348 , True ) <EOL> def test_respect_enforce_ratio_yes ( self ) : <EOL> self . _require_backend ( ) <EOL> self . plugin . enforce_ratio = True <EOL> self . _assertImageIsValidArt ( self . IMG_500x490 , False ) <EOL> self . _assertImageIsValidArt ( self . IMG_225x225 , True ) <EOL> def test_respect_enforce_ratio_no ( self ) : <EOL> self . plugin . enforce_ratio = False <EOL> self . _assertImageIsValidArt ( self . IMG_500x490 , True ) <EOL> def test_respect_enforce_ratio_px_above ( self ) : <EOL> self . plugin . enforce_ratio = True <EOL> self . plugin . margin_px = <NUM_LIT:5> <EOL> self . _assertImageIsValidArt ( self . IMG_500x490 , False ) <EOL> def test_respect_enforce_ratio_px_below ( self ) : <EOL> self . plugin . enforce_ratio = True <EOL> self . plugin . margin_px = <NUM_LIT:15> <EOL> self . _assertImageIsValidArt ( self . IMG_500x490 , True ) <EOL> def test_respect_enforce_ratio_percent_above ( self ) : <EOL> self . plugin . enforce_ratio = True <EOL> self . plugin . margin_percent = ( <NUM_LIT> - <NUM_LIT> ) / <NUM_LIT> * <NUM_LIT:0.5> <EOL> self . _assertImageIsValidArt ( self . IMG_500x490 , False ) <EOL> def test_respect_enforce_ratio_percent_below ( self ) : <EOL> self . plugin . enforce_ratio = True <EOL> self . plugin . margin_percent = ( <NUM_LIT> - <NUM_LIT> ) / <NUM_LIT> * <NUM_LIT> <EOL> self . _assertImageIsValidArt ( self . IMG_500x490 , True ) <EOL> def test_resize_if_necessary ( self ) : <EOL> self . _require_backend ( ) <EOL> self . plugin . maxwidth = <NUM_LIT> <EOL> self . _assertImageResized ( self . IMG_225x225 , False ) <EOL> self . _assertImageResized ( self . IMG_348x348 , True ) <EOL> class DeprecatedConfigTest ( _common . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> super ( DeprecatedConfigTest , self ) . setUp ( ) <EOL> config [ '<STR_LIT>' ] [ '<STR_LIT>' ] = True <EOL> self . plugin = fetchart . FetchArtPlugin ( ) <EOL> def test_moves_filesystem_to_end ( self ) : <EOL> self . assertEqual ( type ( self . plugin . sources [ - <NUM_LIT:1> ] ) , fetchart . FileSystem ) <EOL> class EnforceRatioConfigTest ( _common . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def _load_with_config ( self , values , should_raise ) : <EOL> if should_raise : <EOL> for v in values : <EOL> config [ '<STR_LIT>' ] [ '<STR_LIT>' ] = v <EOL> with self . assertRaises ( confit . ConfigValueError ) : <EOL> fetchart . FetchArtPlugin ( ) <EOL> else : <EOL> for v in values : <EOL> config [ '<STR_LIT>' ] [ '<STR_LIT>' ] = v <EOL> fetchart . FetchArtPlugin ( ) <EOL> def test_px ( self ) : <EOL> self . _load_with_config ( u'<STR_LIT>' . split ( ) , False ) <EOL> self . _load_with_config ( u'<STR_LIT>' . split ( ) , True ) <EOL> def test_percent ( self ) : <EOL> self . _load_with_config ( u'<STR_LIT>' . split ( ) , False ) <EOL> self . _load_with_config ( u'<STR_LIT>' . split ( ) , True ) <EOL> def suite ( ) : <EOL> return unittest . TestLoader ( ) . loadTestsFromName ( __name__ ) <EOL> if __name__ == b'<STR_LIT:__main__>' : <EOL> unittest . main ( defaultTest = '<STR_LIT>' ) </s>
