def setUp(self): self.io = _common.DummyIO() self.io.install() self.lib = library.Library(':memory:') i = test_db.item() self.lib.add(i) self.lib.add_album([i])
def _no_candidates_test(self, result): res = commands.choose_match( 'path', [test_db.item()], # items 'artist', 'album', [], # candidates autotag.RECOMMEND_NONE ) self.assertEqual(res, result) self.assertTrue('No match' in self.io.getoutput())
def test_setart_copies_image(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,)) i2.move(self.lib, True) self.assertEqual(ai.artpath, None) ai.set_art(newart) self.assertTrue(os.path.exists(ai.artpath))
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('rsrc', 'testlibdir') self.lib.directory = self.libdir self.i = item() # Make a file for the item. self.i.path = self.lib.destination(self.i) beets.library._mkdirall(self.i.path) touch(self.i.path) # Make an album. self.ai = self.lib.add_album((self.i,))
def setUp(self): # Make library and item. self.lib = beets.library.Library(':memory:') self.libdir = os.path.abspath(os.path.join('rsrc', 'testlibdir')) self.lib.directory = self.libdir self.i = item() self.i.path = self.lib.destination(self.i) # Make a music file. beets.library._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
def test_setart_sets_permissions(self): 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,)) i2.move(self.lib, 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)
# the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. """Various tests for querying the library database. """ import unittest, sys, os sys.path.append('..') import beets.library import test_db parse_query = beets.library.CollectionQuery._parse_query some_item = test_db.item() class QueryParseTest(unittest.TestCase): def test_one_basic_term(self): q = 'test' r = [(None, 'test')] self.assertEqual(parse_query(q), r) def test_three_basic_terms(self): q = 'test one two' r = [(None, 'test'), (None, 'one'), (None, 'two')] self.assertEqual(parse_query(q), r) def test_one_keyed_term(self): q = 'test:val' r = [('test', 'val')]