コード例 #1
0
ファイル: test_art.py プロジェクト: dreewoo/beets
 def test_local_only_gets_fs_image(self):
     _common.touch(os.path.join(self.dpath, 'art.jpg'))
     album = _common.Bag(mb_albumid=self.MBID, asin=self.ASIN)
     artpath = fetchart.art_for_album(album, [self.dpath],
                                      None, local_only=True)
     self.assertEqual(artpath, os.path.join(self.dpath, 'art.jpg'))
     self.assertEqual(len(responses.calls), 0)
コード例 #2
0
 def test_local_only_gets_fs_image(self):
     _common.touch(os.path.join(self.dpath, 'art.jpg'))
     album = _common.Bag(mb_albumid=self.MBID, asin=self.ASIN)
     artpath = self.plugin.art_for_album(album, [self.dpath],
                                         local_only=True)
     self.assertEqual(artpath, os.path.join(self.dpath, 'art.jpg'))
     self.assertEqual(len(responses.calls), 0)
コード例 #3
0
ファイル: test_art.py プロジェクト: msabramo/beets
 def test_main_interface_gives_precedence_to_fs_art(self):
     _common.touch(os.path.join(self.dpath, 'a.jpg'))
     fetchart.urllib.urlretrieve = \
             MockUrlRetrieve('anotherpath', 'image/jpeg')
     album = AlbumInfo(None, None, None, None, None, asin='xxxx')
     artpath = fetchart.art_for_album(album, self.dpath)
     self.assertEqual(artpath, os.path.join(self.dpath, 'a.jpg'))
コード例 #4
0
ファイル: test_files.py プロジェクト: Tantali/beets
    def test_removing_last_item_in_album_with_albumart_prunes_dir(self):
        artfile = os.path.join(self.temp_dir, 'testart.jpg')
        touch(artfile)
        self.ai.set_art(artfile)

        parent = os.path.dirname(self.i.path)
        self.lib.remove(self.i, True)
        self.assertNotExists(parent)
コード例 #5
0
    def test_removing_last_item_in_album_with_albumart_prunes_dir(self):
        artfile = os.path.join(self.temp_dir, 'testart.jpg')
        touch(artfile)
        self.ai.set_art(artfile)

        parent = os.path.dirname(self.i.path)
        self.lib.remove(self.i, True)
        self.assertNotExists(parent)
コード例 #6
0
ファイル: test_files.py プロジェクト: cmclaughlin/beets
    def setUp(self):
        super(SafeMoveCopyTest, self).setUp()

        self.path = os.path.join(self.temp_dir, 'testfile')
        touch(self.path)
        self.otherpath = os.path.join(self.temp_dir, 'testfile2')
        touch(self.otherpath)
        self.dest = self.path + '.dest'
コード例 #7
0
ファイル: test_files.py プロジェクト: 241n/beets
    def setUp(self):
        super(SafeMoveCopyTest, self).setUp()

        self.path = os.path.join(self.temp_dir, 'testfile')
        touch(self.path)
        self.otherpath = os.path.join(self.temp_dir, 'testfile2')
        touch(self.otherpath)
        self.dest = self.path + '.dest'
コード例 #8
0
ファイル: test_art.py プロジェクト: Lugoues/beets
 def test_local_only_gets_fs_image(self):
     _common.touch(os.path.join(self.dpath, 'a.jpg'))
     mock_retrieve = MockUrlRetrieve('image/jpeg')
     fetchart.urllib.urlretrieve = mock_retrieve
     album = _common.Bag(mb_albumid='releaseid', asin='xxxx')
     artpath = fetchart.art_for_album(album, [self.dpath], local_only=True)
     self.assertEqual(artpath, os.path.join(self.dpath, 'a.jpg'))
     self.assertFalse(self.urlopen_called)
     self.assertFalse(mock_retrieve.fetched)
コード例 #9
0
ファイル: test_art.py プロジェクト: Rawrpwnzl/beets
 def test_local_only_gets_fs_image(self):
     _common.touch(os.path.join(self.dpath, 'a.jpg'))
     mock_retrieve = MockUrlRetrieve('image/jpeg')
     fetchart.urllib.urlretrieve = mock_retrieve
     album = _common.Bag(mb_albumid='releaseid', asin='xxxx')
     artpath = fetchart.art_for_album(album, self.dpath, local_only=True)
     self.assertEqual(artpath, os.path.join(self.dpath, 'a.jpg'))
     self.assertFalse(self.urlopen_called)
     self.assertFalse(mock_retrieve.fetched)
コード例 #10
0
ファイル: test_files.py プロジェクト: sashaseifollahi/beets
    def test_move_avoids_collision_with_existing_file(self):
        # Make a conflicting file at the destination.
        dest = self.lib.destination(self.i)
        os.makedirs(os.path.dirname(dest))
        touch(dest)

        self.lib.move(self.i)
        self.assertNotEqual(self.i.path, dest)
        self.assertEqual(os.path.dirname(self.i.path), os.path.dirname(dest))
コード例 #11
0
ファイル: test_files.py プロジェクト: BenningtonCollege/beets
    def test_move_avoids_collision_with_existing_file(self):
        # Make a conflicting file at the destination.
        dest = self.lib.destination(self.i)
        os.makedirs(os.path.dirname(dest))
        touch(dest)

        self.lib.move(self.i)
        self.assertNotEqual(self.i.path, dest)
        self.assertEqual(os.path.dirname(self.i.path),
                         os.path.dirname(dest))
コード例 #12
0
ファイル: test_files.py プロジェクト: BenningtonCollege/beets
 def setUp(self):
     # Make library and item.
     self.lib = beets.library.Library(':memory:')
     self.libdir = os.path.abspath(os.path.join(_common.RSRC, 'testlibdir'))
     self.lib.directory = self.libdir
     self.i = item()
     self.i.path = self.lib.destination(self.i)
     # Make a music file.
     util.mkdirall(self.i.path)
     touch(self.i.path)
     # Make an album with the item.
     self.ai = self.lib.add_album((self.i,))
コード例 #13
0
ファイル: test_files.py プロジェクト: sashaseifollahi/beets
 def setUp(self):
     # Make library and item.
     self.lib = beets.library.Library(':memory:')
     self.libdir = os.path.abspath(os.path.join(_common.RSRC, 'testlibdir'))
     self.lib.directory = self.libdir
     self.i = item()
     self.i.path = self.lib.destination(self.i)
     # Make a music file.
     util.mkdirall(self.i.path)
     touch(self.i.path)
     # Make an album with the item.
     self.ai = self.lib.add_album((self.i, ))
コード例 #14
0
ファイル: test_files.py プロジェクト: BenningtonCollege/beets
 def setUp(self):
     self.base = os.path.join(_common.RSRC, 'testdir')
     os.mkdir(self.base)
     touch(os.path.join(self.base, 'x.mp3'))
     touch(os.path.join(self.base, 'x.1.mp3'))
     touch(os.path.join(self.base, 'x.2.mp3'))
     touch(os.path.join(self.base, 'y.mp3'))
コード例 #15
0
ファイル: test_files.py プロジェクト: 241n/beets
    def setUp(self):
        super(RemoveTest, self).setUp()

        # Make library and item.
        self.lib = beets.library.Library(':memory:')
        self.libdir = os.path.abspath(os.path.join(self.temp_dir, 'testlibdir'))
        self.lib.directory = self.libdir
        self.i = item(self.lib)
        self.i.path = self.i.destination()
        # Make a music file.
        util.mkdirall(self.i.path)
        touch(self.i.path)
        # Make an album with the item.
        self.ai = self.lib.add_album((self.i,))
コード例 #16
0
ファイル: test_files.py プロジェクト: sashaseifollahi/beets
    def test_setart_copies_image(self):
        os.remove(self.art)

        newart = os.path.join(self.libdir, 'newart.jpg')
        touch(newart)
        i2 = item()
        i2.path = self.i.path
        i2.artist = 'someArtist'
        ai = self.lib.add_album((i2, ))
        self.lib.move(i2, True)

        self.assertEqual(ai.artpath, None)
        ai.set_art(newart)
        self.assertTrue(os.path.exists(ai.artpath))
コード例 #17
0
ファイル: test_files.py プロジェクト: BenningtonCollege/beets
    def test_setart_copies_image(self):
        os.remove(self.art)

        newart = os.path.join(self.libdir, 'newart.jpg')
        touch(newart)
        i2 = item()
        i2.path = self.i.path
        i2.artist = 'someArtist'
        ai = self.lib.add_album((i2,))
        self.lib.move(i2, True)
        
        self.assertEqual(ai.artpath, None)
        ai.set_art(newart)
        self.assertTrue(os.path.exists(ai.artpath))
コード例 #18
0
ファイル: test_files.py プロジェクト: cmclaughlin/beets
    def setUp(self):
        super(RemoveTest, self).setUp()

        # Make library and item.
        self.lib = beets.library.Library(':memory:')
        self.libdir = os.path.join(self.temp_dir, 'testlibdir')
        self.lib.directory = self.libdir
        self.i = item(self.lib)
        self.i.path = self.i.destination()
        # Make a music file.
        util.mkdirall(self.i.path)
        touch(self.i.path)
        # Make an album with the item.
        self.ai = self.lib.add_album((self.i,))
コード例 #19
0
ファイル: test_files.py プロジェクト: sashaseifollahi/beets
 def setUp(self):
     self.base = os.path.join(_common.RSRC, 'testdir')
     os.mkdir(self.base)
     touch(os.path.join(self.base, 'x.mp3'))
     touch(os.path.join(self.base, 'x.1.mp3'))
     touch(os.path.join(self.base, 'x.2.mp3'))
     touch(os.path.join(self.base, 'y.mp3'))
コード例 #20
0
ファイル: test_files.py プロジェクト: sashaseifollahi/beets
 def setUp(self):
     # Make library and item.
     self.lib = beets.library.Library(':memory:')
     self.lib.path_formats = \
         [('default', join('$albumartist', '$album', '$title'))]
     self.libdir = os.path.join(_common.RSRC, 'testlibdir')
     self.lib.directory = self.libdir
     self.i = item()
     # Make a file for the item.
     self.i.path = self.lib.destination(self.i)
     util.mkdirall(self.i.path)
     touch(self.i.path)
     # Make an album.
     self.ai = self.lib.add_album((self.i, ))
     # Alternate destination dir.
     self.otherdir = os.path.join(_common.RSRC, 'testotherdir')
コード例 #21
0
ファイル: test_files.py プロジェクト: sashaseifollahi/beets
    def test_setart_to_existing_art_works(self):
        os.remove(self.art)

        # Original art.
        newart = os.path.join(self.libdir, 'newart.jpg')
        touch(newart)
        i2 = item()
        i2.path = self.i.path
        i2.artist = 'someArtist'
        ai = self.lib.add_album((i2, ))
        self.lib.move(i2, True)
        ai.set_art(newart)

        # Set the art again.
        ai.set_art(ai.artpath)
        self.assertTrue(os.path.exists(ai.artpath))
コード例 #22
0
ファイル: test_files.py プロジェクト: sashaseifollahi/beets
    def test_setart_to_existing_but_unset_art_works(self):
        newart = os.path.join(self.libdir, 'newart.jpg')
        touch(newart)
        i2 = item()
        i2.path = self.i.path
        i2.artist = 'someArtist'
        ai = self.lib.add_album((i2, ))
        self.lib.move(i2, True)

        # Copy the art to the destination.
        artdest = ai.art_destination(newart)
        shutil.copy(newart, artdest)

        # Set the art again.
        ai.set_art(artdest)
        self.assertTrue(os.path.exists(ai.artpath))
コード例 #23
0
ファイル: test_files.py プロジェクト: BenningtonCollege/beets
 def setUp(self):
     # Make library and item.
     self.lib = beets.library.Library(':memory:')
     self.lib.path_formats = \
         [('default', join('$albumartist', '$album', '$title'))]
     self.libdir = os.path.join(_common.RSRC, 'testlibdir')
     self.lib.directory = self.libdir
     self.i = item()
     # Make a file for the item.
     self.i.path = self.lib.destination(self.i)
     util.mkdirall(self.i.path)
     touch(self.i.path)
     # Make an album.
     self.ai = self.lib.add_album((self.i,))
     # Alternate destination dir.
     self.otherdir = os.path.join(_common.RSRC, 'testotherdir')
コード例 #24
0
ファイル: test_files.py プロジェクト: BenningtonCollege/beets
    def test_setart_to_existing_but_unset_art_works(self):
        newart = os.path.join(self.libdir, 'newart.jpg')
        touch(newart)
        i2 = item()
        i2.path = self.i.path
        i2.artist = 'someArtist'
        ai = self.lib.add_album((i2,))
        self.lib.move(i2, True)

        # Copy the art to the destination.
        artdest = ai.art_destination(newart)
        shutil.copy(newart, artdest)

        # Set the art again.
        ai.set_art(artdest)
        self.assertTrue(os.path.exists(ai.artpath))
コード例 #25
0
ファイル: test_files.py プロジェクト: BenningtonCollege/beets
    def test_setart_to_existing_art_works(self):
        os.remove(self.art)

        # Original art.
        newart = os.path.join(self.libdir, 'newart.jpg')
        touch(newart)
        i2 = item()
        i2.path = self.i.path
        i2.artist = 'someArtist'
        ai = self.lib.add_album((i2,))
        self.lib.move(i2, True)
        ai.set_art(newart)

        # Set the art again.
        ai.set_art(ai.artpath)
        self.assertTrue(os.path.exists(ai.artpath))
コード例 #26
0
ファイル: test_files.py プロジェクト: cmclaughlin/beets
    def setUp(self):
        super(UniquePathTest, self).setUp()

        self.base = os.path.join(self.temp_dir, 'testdir')
        os.mkdir(self.base)
        touch(os.path.join(self.base, 'x.mp3'))
        touch(os.path.join(self.base, 'x.1.mp3'))
        touch(os.path.join(self.base, 'x.2.mp3'))
        touch(os.path.join(self.base, 'y.mp3'))
コード例 #27
0
ファイル: test_files.py プロジェクト: 241n/beets
    def setUp(self):
        super(UniquePathTest, self).setUp()

        self.base = os.path.join(self.temp_dir, 'testdir')
        os.mkdir(self.base)
        touch(os.path.join(self.base, 'x.mp3'))
        touch(os.path.join(self.base, 'x.1.mp3'))
        touch(os.path.join(self.base, 'x.2.mp3'))
        touch(os.path.join(self.base, 'y.mp3'))
コード例 #28
0
ファイル: test_files.py プロジェクト: sashaseifollahi/beets
    def test_setart_to_conflicting_file_gets_new_path(self):
        newart = os.path.join(self.libdir, 'newart.jpg')
        touch(newart)
        i2 = item()
        i2.path = self.i.path
        i2.artist = 'someArtist'
        ai = self.lib.add_album((i2, ))
        self.lib.move(i2, True)

        # Make a file at the destination.
        artdest = ai.art_destination(newart)
        touch(artdest)

        # Set the art.
        ai.set_art(newart)
        self.assertNotEqual(artdest, ai.artpath)
        self.assertEqual(os.path.dirname(artdest), os.path.dirname(ai.artpath))
コード例 #29
0
ファイル: test_files.py プロジェクト: BenningtonCollege/beets
 def setUp(self):
     # Make library and item.
     self.lib = beets.library.Library(':memory:')
     self.libdir = os.path.abspath(os.path.join(_common.RSRC, 'testlibdir'))
     self.lib.directory = self.libdir
     self.i = item()
     self.i.path = self.lib.destination(self.i)
     # Make a music file.
     util.mkdirall(self.i.path)
     touch(self.i.path)
     # Make an album.
     self.ai = self.lib.add_album((self.i,))
     # Make an art file too.
     self.art = self.lib.get_album(self.i).art_destination('something.jpg')
     touch(self.art)
     self.ai.artpath = self.art
     # Alternate destination dir.
     self.otherdir = os.path.join(_common.RSRC, 'testotherdir')
コード例 #30
0
ファイル: test_ui.py プロジェクト: mrmachine/beets
    def setUp(self):
        super(UpdateTest, self).setUp()

        self.io.install()

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

        # Copy a file into the library.
        self.lib = library.Library(":memory:", self.libdir)
        self.i = library.Item.from_path(os.path.join(_common.RSRC, "full.mp3"))
        self.lib.add(self.i, True)
        self.album = self.lib.add_album([self.i])

        # Album art.
        artfile = os.path.join(_common.RSRC, "testart.jpg")
        _common.touch(artfile)
        self.album.set_art(artfile)
        os.remove(artfile)
コード例 #31
0
    def setUp(self):
        self.io = _common.DummyIO()
        self.io.install()

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

        # Copy a file into the library.
        self.lib = library.Library(':memory:', self.libdir)
        self.i = library.Item.from_path(os.path.join(_common.RSRC, 'full.mp3'))
        self.lib.add(self.i, True)
        self.album = self.lib.add_album([self.i])

        # Album art.
        artfile = os.path.join(_common.RSRC, 'testart.jpg')
        _common.touch(artfile)
        self.album.set_art(artfile)
        os.remove(artfile)
コード例 #32
0
ファイル: test_ui.py プロジェクト: nidico/beets
    def setUp(self):
        self.io = _common.DummyIO()
        self.io.install()

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

        # Copy a file into the library.
        self.lib = library.Library(':memory:', self.libdir)
        self.i = library.Item.from_path(os.path.join(_common.RSRC, 'full.mp3'))
        self.lib.add(self.i, True)
        self.album = self.lib.add_album([self.i])

        # Album art.
        artfile = os.path.join(_common.RSRC, 'testart.jpg')
        _common.touch(artfile)
        self.album.set_art(artfile)
        os.remove(artfile)
コード例 #33
0
ファイル: test_files.py プロジェクト: BenningtonCollege/beets
    def test_setart_to_conflicting_file_gets_new_path(self):
        newart = os.path.join(self.libdir, 'newart.jpg')
        touch(newart)
        i2 = item()
        i2.path = self.i.path
        i2.artist = 'someArtist'
        ai = self.lib.add_album((i2,))
        self.lib.move(i2, True)

        # Make a file at the destination.
        artdest = ai.art_destination(newart)
        touch(artdest)

        # Set the art.
        ai.set_art(newart)
        self.assertNotEqual(artdest, ai.artpath)
        self.assertEqual(os.path.dirname(artdest),
                         os.path.dirname(ai.artpath))
コード例 #34
0
ファイル: test_files.py プロジェクト: sashaseifollahi/beets
 def setUp(self):
     # Make library and item.
     self.lib = beets.library.Library(':memory:')
     self.libdir = os.path.abspath(os.path.join(_common.RSRC, 'testlibdir'))
     self.lib.directory = self.libdir
     self.i = item()
     self.i.path = self.lib.destination(self.i)
     # Make a music file.
     util.mkdirall(self.i.path)
     touch(self.i.path)
     # Make an album.
     self.ai = self.lib.add_album((self.i, ))
     # Make an art file too.
     self.art = self.lib.get_album(self.i).art_destination('something.jpg')
     touch(self.art)
     self.ai.artpath = self.art
     # Alternate destination dir.
     self.otherdir = os.path.join(_common.RSRC, 'testotherdir')
コード例 #35
0
ファイル: test_art.py プロジェクト: zhang-xun/beets
    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()))
コード例 #36
0
    def setUp(self):
        super(UpdateTest, self).setUp()

        self.io.install()

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

        # Copy a file into the library.
        self.lib = library.Library(':memory:', self.libdir)
        self.i = library.Item.from_path(os.path.join(_common.RSRC, 'full.mp3'))
        self.lib.add(self.i, True)
        self.album = self.lib.add_album([self.i])

        # Album art.
        artfile = os.path.join(_common.RSRC, 'testart.jpg')
        _common.touch(artfile)
        self.album.set_art(artfile)
        self.album.store()
        os.remove(artfile)
コード例 #37
0
ファイル: test_art.py プロジェクト: dreewoo/beets
    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()))
コード例 #38
0
ファイル: test_ui.py プロジェクト: axujen/beets
    def setUp(self):
        super(UpdateTest, self).setUp()

        self.io.install()

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

        # Copy a file into the library.
        self.lib = library.Library(':memory:', self.libdir)
        self.i = library.Item.from_path(os.path.join(_common.RSRC, 'full.mp3'))
        self.lib.add(self.i)
        self.i.move(True)
        self.album = self.lib.add_album([self.i])

        # Album art.
        artfile = os.path.join(self.temp_dir, 'testart.jpg')
        _common.touch(artfile)
        self.album.set_art(artfile)
        self.album.store()
        os.remove(artfile)
コード例 #39
0
ファイル: test_files.py プロジェクト: cmclaughlin/beets
    def setUp(self):
        super(ArtFileTest, self).setUp()

        # Make library and item.
        self.lib = beets.library.Library(':memory:')
        self.libdir = os.path.join(self.temp_dir, 'testlibdir')
        self.lib.directory = self.libdir
        self.i = item(self.lib)
        self.i.path = self.i.destination()
        # Make a music file.
        util.mkdirall(self.i.path)
        touch(self.i.path)
        # Make an album.
        self.ai = self.lib.add_album((self.i,))
        # Make an art file too.
        self.art = self.lib.get_album(self.i).art_destination('something.jpg')
        touch(self.art)
        self.ai.artpath = self.art
        self.ai.store()
        # Alternate destination dir.
        self.otherdir = os.path.join(self.temp_dir, 'testotherdir')
コード例 #40
0
ファイル: test_files.py プロジェクト: BenningtonCollege/beets
 def setUp(self):
     self.base = os.path.join(_common.RSRC, 'testdir')
     os.mkdir(self.base)
     touch(os.path.join(self.base, 'y'))
     touch(os.path.join(self.base, 'x'))
     os.mkdir(os.path.join(self.base, 'd'))
     touch(os.path.join(self.base, 'd', 'z'))
コード例 #41
0
ファイル: test_art.py プロジェクト: dreewoo/beets
 def test_precedence_amongst_correct_files(self):
     _common.touch(os.path.join(self.dpath, 'back.jpg'))
     _common.touch(os.path.join(self.dpath, 'front.jpg'))
     _common.touch(os.path.join(self.dpath, 'front-cover.jpg'))
     fn = fetchart.art_in_path(self.dpath,
                               ('cover', 'front', 'back'), False)
     self.assertEqual(fn, os.path.join(self.dpath, 'front-cover.jpg'))
コード例 #42
0
ファイル: test_files.py プロジェクト: sashaseifollahi/beets
 def setUp(self):
     self.base = os.path.join(_common.RSRC, 'testdir')
     os.mkdir(self.base)
     touch(os.path.join(self.base, 'y'))
     touch(os.path.join(self.base, 'x'))
     os.mkdir(os.path.join(self.base, 'd'))
     touch(os.path.join(self.base, 'd', 'z'))
コード例 #43
0
ファイル: test_art.py プロジェクト: zhang-xun/beets
 def test_precedence_amongst_correct_files(self):
     _common.touch(os.path.join(self.dpath, 'back.jpg'))
     _common.touch(os.path.join(self.dpath, 'front.jpg'))
     _common.touch(os.path.join(self.dpath, 'front-cover.jpg'))
     fn = fetchart.art_in_path(self.dpath, ('cover', 'front', 'back'),
                               False)
     self.assertEqual(fn, os.path.join(self.dpath, 'front-cover.jpg'))
コード例 #44
0
ファイル: test_importer.py プロジェクト: encukou/beets
    def setUp(self):
        # Mock the album art fetcher to always return our test file.
        self.art_file = os.path.join(_common.RSRC, 'tmpcover.jpg')
        _common.touch(self.art_file)
        self.old_afa = art.art_for_album
        art.art_for_album = lambda a, b: self.art_file

        # Test library.
        self.libpath = os.path.join(_common.RSRC, 'tmplib.blb')
        self.libdir = os.path.join(_common.RSRC, '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()

        # Set up an art-fetching coroutine.
        self.config = _common.iconfig(self.lib)
        self.config.art = True
        self.coro = importer.fetch_art(self.config)
        self.coro.next()

        # Import task for the coroutine.
        self.task = importer.ImportTask(None, None, [self.i])
        self.task.is_album = True
        self.task.album_id = self.album.id
        info = AlbumInfo(
            album = 'some album',
            album_id = 'albumid',
            artist = 'some artist',
            artist_id = 'artistid',
            tracks = [TrackInfo('one',  'trackid', 'some artist',
                                'artistid', 1)],
        )
        self.task.set_choice((info, [self.i]))
コード例 #45
0
ファイル: test_importer.py プロジェクト: coolkehon/beets
    def setUp(self):
        # Mock the album art fetcher to always return our test file.
        self.art_file = os.path.join(_common.RSRC, 'tmpcover.jpg')
        _common.touch(self.art_file)
        self.old_afa = art.art_for_album
        art.art_for_album = lambda a, b: self.art_file

        # Test library.
        self.libpath = os.path.join(_common.RSRC, 'tmplib.blb')
        self.libdir = os.path.join(_common.RSRC, '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.save()

        # Set up an art-fetching coroutine.
        self.config = _common.iconfig(self.lib)
        self.config.art = True
        self.coro = importer.fetch_art(self.config)
        self.coro.next()

        # Import task for the coroutine.
        self.task = importer.ImportTask(None, None, [self.i])
        self.task.is_album = True
        self.task.album_id = self.album.id
        info = AlbumInfo(
            album='some album',
            album_id='albumid',
            artist='some artist',
            artist_id='artistid',
            tracks=[TrackInfo('one', 'trackid', 'some artist', 'artistid', 1)],
        )
        self.task.set_choice((info, [self.i]))
コード例 #46
0
ファイル: test_importer.py プロジェクト: domenkozar/beets
    def setUp(self):
        # Mock the album art fetcher to always return our test file.
        self.art_file = os.path.join(_common.RSRC, "tmpcover.jpg")
        _common.touch(self.art_file)
        self.old_afa = art.art_for_album
        art.art_for_album = lambda a, b: self.art_file

        # Test library.
        self.libpath = os.path.join(_common.RSRC, "tmplib.blb")
        self.libdir = os.path.join(_common.RSRC, "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.save()

        # Set up an art-fetching coroutine.
        self.config = _common.iconfig(self.lib)
        self.config.art = True
        self.coro = importer.fetch_art(self.config)
        self.coro.next()

        # Import task for the coroutine.
        self.task = importer.ImportTask(None, None, [self.i])
        self.task.is_album = True
        self.task.album_id = self.album.id
        info = AlbumInfo(
            album="some album",
            album_id="albumid",
            artist="some artist",
            artist_id="artistid",
            tracks=[TrackInfo("one", "trackid", "some artist", "artistid", 1)],
        )
        self.task.set_choice((info, [self.i]))
コード例 #47
0
ファイル: test_files.py プロジェクト: sashaseifollahi/beets
    def test_setart_sets_permissions(self):
        os.remove(self.art)

        newart = os.path.join(self.libdir, 'newart.jpg')
        touch(newart)
        os.chmod(newart, 0400)  # read-only

        try:
            i2 = item()
            i2.path = self.i.path
            i2.artist = 'someArtist'
            ai = self.lib.add_album((i2, ))
            self.lib.move(i2, True)
            ai.set_art(newart)

            mode = stat.S_IMODE(os.stat(ai.artpath).st_mode)
            self.assertTrue(mode & stat.S_IRGRP)
            self.assertTrue(os.access(ai.artpath, os.W_OK))

        finally:
            # Make everything writable so it can be cleaned up.
            os.chmod(newart, 0777)
            os.chmod(ai.artpath, 0777)
コード例 #48
0
ファイル: test_files.py プロジェクト: BenningtonCollege/beets
    def test_setart_sets_permissions(self):
        os.remove(self.art)

        newart = os.path.join(self.libdir, 'newart.jpg')
        touch(newart)
        os.chmod(newart, 0400) # read-only
        
        try:
            i2 = item()
            i2.path = self.i.path
            i2.artist = 'someArtist'
            ai = self.lib.add_album((i2,))
            self.lib.move(i2, True)
            ai.set_art(newart)
            
            mode = stat.S_IMODE(os.stat(ai.artpath).st_mode)
            self.assertTrue(mode & stat.S_IRGRP)
            self.assertTrue(os.access(ai.artpath, os.W_OK))
            
        finally:
            # Make everything writable so it can be cleaned up.
            os.chmod(newart, 0777)
            os.chmod(ai.artpath, 0777)
コード例 #49
0
ファイル: test_files.py プロジェクト: cmclaughlin/beets
    def setUp(self):
        super(WalkTest, self).setUp()

        self.base = os.path.join(self.temp_dir, 'testdir')
        os.mkdir(self.base)
        touch(os.path.join(self.base, 'y'))
        touch(os.path.join(self.base, 'x'))
        os.mkdir(os.path.join(self.base, 'd'))
        touch(os.path.join(self.base, 'd', 'z'))
コード例 #50
0
ファイル: test_files.py プロジェクト: 241n/beets
    def setUp(self):
        super(WalkTest, self).setUp()

        self.base = os.path.join(self.temp_dir, 'testdir')
        os.mkdir(self.base)
        touch(os.path.join(self.base, 'y'))
        touch(os.path.join(self.base, 'x'))
        os.mkdir(os.path.join(self.base, 'd'))
        touch(os.path.join(self.base, 'd', 'z'))
コード例 #51
0
ファイル: test_art.py プロジェクト: Lugoues/beets
 def test_appropriately_named_file_takes_precedence(self):
     _common.touch(os.path.join(self.dpath, 'a.jpg'))
     _common.touch(os.path.join(self.dpath, 'cover.jpg'))
     fn = fetchart.art_in_path(self.dpath)
     self.assertEqual(fn, os.path.join(self.dpath, 'cover.jpg'))
コード例 #52
0
ファイル: test_files.py プロジェクト: BenningtonCollege/beets
 def test_removing_last_item_prunes_dir_with_blacklisted_file(self):
     parent = os.path.dirname(self.i.path)
     touch(os.path.join(parent, '.DS_Store'))
     self.lib.remove(self.i, True)
     self.assertNotExists(parent)
コード例 #53
0
ファイル: test_files.py プロジェクト: sashaseifollahi/beets
 def setUp(self):
     self.path = os.path.join(_common.RSRC, 'testfile')
     touch(self.path)
     self.otherpath = os.path.join(_common.RSRC, 'testfile2')
     touch(self.otherpath)
     self.dest = self.path + '.dest'
コード例 #54
0
ファイル: test_files.py プロジェクト: sashaseifollahi/beets
 def setUp(self):
     self.path = os.path.join(_common.RSRC, 'testfile')
     touch(self.path)
コード例 #55
0
ファイル: test_files.py プロジェクト: sashaseifollahi/beets
 def test_removing_last_item_prunes_dir_with_blacklisted_file(self):
     parent = os.path.dirname(self.i.path)
     touch(os.path.join(parent, '.DS_Store'))
     self.lib.remove(self.i, True)
     self.assertNotExists(parent)
コード例 #56
0
ファイル: test_files.py プロジェクト: sashaseifollahi/beets
 def test_removing_last_item_preserves_nonempty_dir(self):
     parent = os.path.dirname(self.i.path)
     touch(os.path.join(parent, 'dummy.txt'))
     self.lib.remove(self.i, True)
     self.assertExists(parent)
コード例 #57
0
ファイル: test_files.py プロジェクト: BenningtonCollege/beets
 def setUp(self):
     self.path = os.path.join(_common.RSRC, 'testfile')
     touch(self.path)
コード例 #58
0
ファイル: test_files.py プロジェクト: BenningtonCollege/beets
 def setUp(self):
     self.path = os.path.join(_common.RSRC, 'testfile')
     touch(self.path)
     self.otherpath = os.path.join(_common.RSRC, 'testfile2')
     touch(self.otherpath)
     self.dest = self.path + '.dest'
コード例 #59
0
ファイル: test_art.py プロジェクト: Lugoues/beets
 def test_non_image_file_not_identified(self):
     _common.touch(os.path.join(self.dpath, 'a.txt'))
     fn = fetchart.art_in_path(self.dpath)
     self.assertEqual(fn, None)