Consolidate export tests into MoveTest

Just one new flag.
This commit is contained in:
Adrian Sampson 2017-06-10 20:26:41 -04:00
parent 730c84e5e5
commit ca4f96e33c

View file

@ -421,8 +421,9 @@ class MoveTest(_common.TestCase):
self.otherdir = os.path.join(self.temp_dir, b'testotherdir')
def _move(self, query=(), dest=None, copy=False, album=False,
pretend=False):
commands.move_items(self.lib, dest, query, copy, album, pretend)
pretend=False, export=False):
commands.move_items(self.lib, dest, query, copy, album, pretend,
export=export)
def test_move_item(self):
self._move()
@ -476,45 +477,20 @@ class MoveTest(_common.TestCase):
self.i.load()
self.assertIn(b'srcfile', self.i.path)
class ExportTest(_common.TestCase):
def setUp(self):
super(ExportTest, self).setUp()
self.libdir = os.path.join(self.temp_dir, b'testlibdir')
os.mkdir(self.libdir)
self.itempath = os.path.join(self.libdir, b'srcfile')
shutil.copy(os.path.join(_common.RSRC, b'full.mp3'), self.itempath)
# Add a file to the library but don't copy it in yet.
self.lib = library.Library(':memory:', self.libdir)
self.i = library.Item.from_path(self.itempath)
self.lib.add(self.i)
self.album = self.lib.add_album([self.i])
# Alternate destination directory.
self.otherdir = os.path.join(self.temp_dir, b'testotherdir')
def _move(self, query=(), dest=None, copy=False, album=False,
pretend=False, export=True):
commands.move_items(self.lib, dest, query, copy, album,
pretend, export=export)
def test_export_item_custom_dir(self):
self._move(dest=self.otherdir)
self._move(dest=self.otherdir, export=True)
self.i.load()
self.assertEqual(self.i.path, self.itempath)
self.assertExists(self.otherdir)
def test_export_album_custom_dir(self):
self._move(dest=self.otherdir, album=True)
self._move(dest=self.otherdir, album=True, export=True)
self.i.load()
self.assertEqual(self.i.path, self.itempath)
self.assertExists(self.otherdir)
def test_pretend_export_item(self):
self._move(dest=self.otherdir, pretend=True)
self._move(dest=self.otherdir, pretend=True, export=True)
self.i.load()
self.assertIn(b'srcfile', self.i.path)
self.assertNotExists(self.otherdir)