Exemplo n.º 1
0
    def setUp(self):
        super(ArtImporterTest, self).setUp()

        # Mock the album art fetcher to always return our test file.
        self.art_file = os.path.join(self.temp_dir, b'tmpcover.jpg')
        _common.touch(self.art_file)
        self.old_afa = self.plugin.art_for_album
        self.afa_response = fetchart.Candidate(logger, path=self.art_file)

        def art_for_album(i, p, local_only=False):
            return self.afa_response

        self.plugin.art_for_album = art_for_album

        # Test library.
        self.libpath = os.path.join(self.temp_dir, b'tmplib.blb')
        self.libdir = os.path.join(self.temp_dir, b'tmplib')
        os.mkdir(self.libdir)
        os.mkdir(os.path.join(self.libdir, b'album'))
        itempath = os.path.join(self.libdir, b'album', b'test.mp3')
        shutil.copyfile(os.path.join(_common.RSRC, b'full.mp3'), itempath)
        self.lib = library.Library(self.libpath)
        self.i = _common.item()
        self.i.path = itempath
        self.album = self.lib.add_album([self.i])
        self.lib._connection().commit()

        # The import configuration.
        self.session = _common.import_session(self.lib)

        # Import task for the coroutine.
        self.task = importer.ImportTask(None, None, [self.i])
        self.task.is_album = True
        self.task.album = self.album
        info = AlbumInfo(
            album=u'some album',
            album_id=u'albumid',
            artist=u'some artist',
            artist_id=u'artistid',
            tracks=[],
        )
        self.task.set_choice(AlbumMatch(0, info, {}, set(), set()))
Exemplo n.º 2
0
 def setUp(self):
     super(FetchImageTest, self).setUp()
     self.dpath = os.path.join(self.temp_dir, b'arttest')
     self.source = fetchart.RemoteArtSource(logger, self.plugin.config)
     self.settings = Settings(maxwidth=0)
     self.candidate = fetchart.Candidate(logger, url=self.URL)
Exemplo n.º 3
0
 def fs_source_get(_self, album, settings, paths):
     if paths:
         yield fetchart.Candidate(logger, path=self.image_file)
Exemplo n.º 4
0
 def test_do_not_delete_original_if_already_in_place(self):
     artdest = os.path.join(os.path.dirname(self.i.path), b'cover.jpg')
     shutil.copyfile(self.art_file, artdest)
     self.afa_response = fetchart.Candidate(logger, path=artdest)
     self._fetch_art(True)
Exemplo n.º 5
0
 def fs_source_get(_self, album, extra):
     if extra['paths']:
         yield fetchart.Candidate(logger, path=self.image_file)
Exemplo n.º 6
0
 def test_jpeg_type_returns_path(self):
     self.mock_response('image/jpeg')
     candidate = fetchart.Candidate(logger, url=self.URL)
     self.source.fetch_image(candidate, self.extra)
     self.assertNotEqual(candidate.path, None)
Exemplo n.º 7
0
 def test_invalid_type_returns_none(self):
     self.mock_response('image/watercolour')
     candidate = fetchart.Candidate(logger, url=self.URL)
     self.source.fetch_image(candidate, self.extra)
     self.assertEqual(candidate.path, None)