Esempio n. 1
0
    def setUp(self):
        super(ImportApplyTest, self).setUp()

        self.libdir = os.path.join(self.temp_dir, 'testlibdir')
        os.mkdir(self.libdir)
        self.libpath = os.path.join(self.temp_dir, 'testlib.blb')
        self.lib = library.Library(self.libpath, self.libdir)
        self.lib.path_formats = [
            ('default', 'one'),
            ('singleton:true', 'three'),
            ('comp:true', 'two'),
        ]
        self.session = _common.import_session(self.lib)

        self.srcdir = os.path.join(self.temp_dir, 'testsrcdir')
        os.mkdir(self.srcdir)
        os.mkdir(os.path.join(self.srcdir, 'testalbum'))
        self.srcpath = os.path.join(self.srcdir, 'testalbum', 'srcfile.mp3')
        shutil.copy(os.path.join(_common.RSRC, 'full.mp3'), self.srcpath)
        self.i = library.Item.from_path(self.srcpath)
        self.i.comp = False

        trackinfo = TrackInfo('one', 'trackid', 'some artist', 'artistid', 1)
        self.info = AlbumInfo(
            artist='some artist',
            album='some album',
            tracks=[trackinfo],
            va=False,
            album_id='albumid',
            artist_id='artistid',
            albumtype='soundtrack',
        )
Esempio n. 2
0
 def _no_candidates_test(self, result):
     task = importer.ImportTask("toppath", "path", [_common.item()])
     task.set_candidates("artist", "album", [], autotag.recommendation.none)
     session = _common.import_session(cli=True)
     res = session.choose_match(task)
     self.assertEqual(res, result)
     self.assertTrue("No match" in self.io.getoutput())
Esempio n. 3
0
    def setUp(self):
        super(ImportApplyTest, self).setUp()

        self.libdir = os.path.join(self.temp_dir, 'testlibdir')
        os.mkdir(self.libdir)
        self.libpath = os.path.join(self.temp_dir, 'testlib.blb')
        self.lib = library.Library(self.libpath, self.libdir)
        self.lib.path_formats = [
            ('default', 'one'),
            ('singleton:true', 'three'),
            ('comp:true', 'two'),
        ]
        self.session = _common.import_session(self.lib)

        self.srcdir = os.path.join(self.temp_dir, 'testsrcdir')
        os.mkdir(self.srcdir)
        os.mkdir(os.path.join(self.srcdir, 'testalbum'))
        self.srcpath = os.path.join(self.srcdir, 'testalbum', 'srcfile.mp3')
        shutil.copy(os.path.join(_common.RSRC, 'full.mp3'), self.srcpath)
        self.i = library.Item.from_path(self.srcpath)
        self.i.comp = False
        self.lib.add(self.i)

        trackinfo = TrackInfo('one',  'trackid', 'some artist',
                              'artistid', 1)
        self.info = AlbumInfo(
            artist = 'some artist',
            album = 'some album',
            tracks = [trackinfo],
            va = False,
            album_id = 'albumid',
            artist_id = 'artistid',
            albumtype = 'soundtrack',
        )
Esempio n. 4
0
 def _no_candidates_test(self, result):
     task = importer.ImportTask(
         'toppath',
         'path',
         [_common.item()],
     )
     task.set_candidates('artist', 'album', [], autotag.recommendation.none)
     session = _common.import_session(cli=True)
     res = session.choose_match(task)
     self.assertEqual(res, result)
     self.assertTrue('No match' in self.io.getoutput())
Esempio n. 5
0
 def _no_candidates_test(self, result):
     task = importer.ImportTask(
         'toppath',
         'path',
         [_common.item()],
     )
     task.set_candidates('artist', 'album', [], autotag.recommendation.none)
     session = _common.import_session(cli=True)
     res = session.choose_match(task)
     self.assertEqual(res, result)
     self.assertTrue('No match' in self.io.getoutput())
Esempio n. 6
0
    def setUp(self):
        self.dbpath = os.path.join(_common.RSRC, 'templib.blb')
        self.lib = library.Library(self.dbpath)
        self.session = _common.import_session(self.lib)

        # Make an "album" that has a homogenous artist. (Modified by
        # individual tests.)
        i1 = _common.item()
        i2 = _common.item()
        i3 = _common.item()
        i1.title = 'first item'
        i2.title = 'second item'
        i3.title = 'third item'
        i1.comp = i2.comp = i3.comp = False
        i1.albumartist = i2.albumartist = i3.albumartist = ''
        self.items = [i1, i2, i3]
Esempio n. 7
0
    def setUp(self):
        self.dbpath = os.path.join(_common.RSRC, 'templib.blb')
        self.lib = library.Library(self.dbpath)
        self.session = _common.import_session(self.lib)

        # Make an "album" that has a homogenous artist. (Modified by
        # individual tests.)
        i1 = _common.item()
        i2 = _common.item()
        i3 = _common.item()
        i1.title = 'first item'
        i2.title = 'second item'
        i3.title = 'third item'
        i1.comp = i2.comp = i3.comp = False
        i1.albumartist = i2.albumartist = i3.albumartist = ''
        self.items = [i1, i2, i3]
Esempio n. 8
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, 'tmpcover.jpg')
        _common.touch(self.art_file)
        self.old_afa = fetchart.art_for_album
        self.afa_response = self.art_file

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

        fetchart.art_for_album = art_for_album

        # Test library.
        self.libpath = os.path.join(self.temp_dir, 'tmplib.blb')
        self.libdir = os.path.join(self.temp_dir, 'tmplib')
        os.mkdir(self.libdir)
        os.mkdir(os.path.join(self.libdir, 'album'))
        itempath = os.path.join(self.libdir, 'album', 'test.mp3')
        shutil.copyfile(os.path.join(_common.RSRC, '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 plugin and import configuration.
        self.plugin = fetchart.FetchArtPlugin()
        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='some album',
            album_id='albumid',
            artist='some artist',
            artist_id='artistid',
            tracks=[],
        )
        self.task.set_choice(AlbumMatch(0, info, {}, set(), set()))
Esempio n. 9
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, 'tmpcover.jpg')
        _common.touch(self.art_file)
        self.old_afa = fetchart.art_for_album
        self.afa_response = self.art_file

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

        fetchart.art_for_album = art_for_album

        # Test library.
        self.libpath = os.path.join(self.temp_dir, 'tmplib.blb')
        self.libdir = os.path.join(self.temp_dir, 'tmplib')
        os.mkdir(self.libdir)
        os.mkdir(os.path.join(self.libdir, 'album'))
        itempath = os.path.join(self.libdir, 'album', 'test.mp3')
        shutil.copyfile(os.path.join(_common.RSRC, '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 plugin and import configuration.
        self.plugin = fetchart.FetchArtPlugin()
        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='some album',
            album_id='albumid',
            artist='some artist',
            artist_id='artistid',
            tracks=[],
        )
        self.task.set_choice(AlbumMatch(0, info, {}, set(), set()))
Esempio n. 10
0
    def setUp(self):
        super(ApplyExistingItemsTest, self).setUp()

        self.libdir = os.path.join(self.temp_dir, 'testlibdir')
        os.mkdir(self.libdir)

        self.dbpath = os.path.join(self.temp_dir, 'templib.blb')
        self.lib = library.Library(self.dbpath, self.libdir)
        self.lib.path_formats = [
            ('default', '$artist/$title'),
        ]
        self.session = _common.import_session(self.lib)

        config['import']['write'] = False
        config['import']['copy'] = False

        self.srcpath = os.path.join(self.libdir, 'srcfile.mp3')
        shutil.copy(os.path.join(_common.RSRC, 'full.mp3'), self.srcpath)
        self.i = library.Item.from_path(self.srcpath)
        self.i.comp = False
Esempio n. 11
0
    def setUp(self):
        super(ApplyExistingItemsTest, self).setUp()

        self.libdir = os.path.join(self.temp_dir, 'testlibdir')
        os.mkdir(self.libdir)

        self.dbpath = os.path.join(self.temp_dir, 'templib.blb')
        self.lib = library.Library(self.dbpath, self.libdir)
        self.lib.path_formats = [
            ('default', '$artist/$title'),
        ]
        self.session = _common.import_session(self.lib)

        config['import']['write'] = False
        config['import']['copy'] = False

        self.srcpath = os.path.join(self.libdir, 'srcfile.mp3')
        shutil.copy(os.path.join(_common.RSRC, 'full.mp3'), self.srcpath)
        self.i = library.Item.from_path(self.srcpath)
        self.i.comp = False
Esempio n. 12
0
 def test_tag_log_unicode(self):
     sio = StringIO.StringIO()
     session = _common.import_session(logfile=sio)
     session.tag_log('status', 'caf\xc3\xa9')
     assert 'status caf' in sio.getvalue()
Esempio n. 13
0
 def test_tag_log_line(self):
     sio = StringIO.StringIO()
     session = _common.import_session(logfile=sio)
     session.tag_log('status', 'path')
     assert 'status path' in sio.getvalue()
Esempio n. 14
0
 def test_tag_log_line(self):
     sio = StringIO.StringIO()
     session = _common.import_session(logfile=sio)
     session.tag_log("status", "path")
     assert "status path" in sio.getvalue()
Esempio n. 15
0
 def test_tag_log_unicode(self):
     sio = StringIO.StringIO()
     session = _common.import_session(logfile=sio)
     session.tag_log("status", "caf\xc3\xa9")
     assert "status caf" in sio.getvalue()
Esempio n. 16
0
 def test_tag_log_line(self):
     sio = StringIO.StringIO()
     session = _common.import_session(logfile=sio)
     session.tag_log('status', 'path')
     assert 'status path' in sio.getvalue()
Esempio n. 17
0
 def test_tag_log_unicode(self):
     sio = StringIO.StringIO()
     session = _common.import_session(logfile=sio)
     session.tag_log('status', 'caf\xc3\xa9')
     assert 'status caf' in sio.getvalue()