mirror of
https://github.com/beetbox/beets.git
synced 2025-12-14 20:43:41 +01:00
start fixing up tests for confit overhaul
This commit is contained in:
parent
582851a6fe
commit
e84a41b550
3 changed files with 23 additions and 47 deletions
|
|
@ -71,36 +71,10 @@ def item():
|
|||
'album_id': None,
|
||||
})
|
||||
|
||||
# Dummy import stuff.
|
||||
def iconfig(lib, **kwargs):
|
||||
config = importer.ImportConfig(
|
||||
lib = lib,
|
||||
paths = None,
|
||||
resume = False,
|
||||
logfile = None,
|
||||
color = False,
|
||||
quiet = True,
|
||||
quiet_fallback = importer.action.SKIP,
|
||||
copy = True,
|
||||
move = False,
|
||||
write = False,
|
||||
delete = False,
|
||||
choose_match_func = lambda x, y: importer.action.SKIP,
|
||||
should_resume_func = lambda _: False,
|
||||
threaded = False,
|
||||
autot = True,
|
||||
singletons = False,
|
||||
choose_item_func = lambda x, y: importer.action.SKIP,
|
||||
timid = False,
|
||||
query = None,
|
||||
incremental = False,
|
||||
ignore = [],
|
||||
resolve_duplicate_func = lambda x, y: None,
|
||||
per_disc_numbering = False,
|
||||
)
|
||||
for k, v in kwargs.items():
|
||||
setattr(config, k, v)
|
||||
return config
|
||||
# Dummy import session.
|
||||
def import_session(lib, logfile=None, paths=[], query=[]):
|
||||
return importer.ImportSession(lib, logfile, paths, query)
|
||||
|
||||
|
||||
# Mock timing.
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ from beetsplug import fetchart
|
|||
from beets.autotag import AlbumInfo, AlbumMatch
|
||||
from beets import library
|
||||
from beets import importer
|
||||
from beets import config
|
||||
import os
|
||||
import shutil
|
||||
import StringIO
|
||||
|
|
@ -204,7 +205,7 @@ class ArtImporterTest(unittest.TestCase, _common.ExtraAsserts):
|
|||
|
||||
# The plugin and import configuration.
|
||||
self.plugin = fetchart.FetchArtPlugin()
|
||||
self.config = _common.iconfig(self.lib)
|
||||
self.session = _common.import_session(self.lib)
|
||||
|
||||
# Import task for the coroutine.
|
||||
self.task = importer.ImportTask(None, None, [self.i])
|
||||
|
|
@ -235,8 +236,8 @@ class ArtImporterTest(unittest.TestCase, _common.ExtraAsserts):
|
|||
the path was not set.
|
||||
"""
|
||||
# Execute the two relevant parts of the importer.
|
||||
self.plugin.fetch_art(self.config, self.task)
|
||||
self.plugin.assign_art(self.config, self.task)
|
||||
self.plugin.fetch_art(self.session, self.task)
|
||||
self.plugin.assign_art(self.session, self.task)
|
||||
|
||||
artpath = self.lib.albums()[0].artpath
|
||||
if should_exist:
|
||||
|
|
@ -264,12 +265,12 @@ class ArtImporterTest(unittest.TestCase, _common.ExtraAsserts):
|
|||
self.assertExists(self.art_file)
|
||||
|
||||
def test_delete_original_file(self):
|
||||
self.config.delete = True
|
||||
config['import']['delete'] = True
|
||||
self._fetch_art(True)
|
||||
self.assertNotExists(self.art_file)
|
||||
|
||||
def test_move_original_file(self):
|
||||
self.config.move = True
|
||||
config['import']['move'] = True
|
||||
self._fetch_art(True)
|
||||
self.assertNotExists(self.art_file)
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ from beets.ui import commands
|
|||
from beets import autotag
|
||||
from beets import importer
|
||||
from beets.mediafile import MediaFile
|
||||
from beets import config
|
||||
|
||||
class ListTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
|
@ -324,7 +325,7 @@ class UpdateTest(unittest.TestCase, _common.ExtraAsserts):
|
|||
if reset_mtime:
|
||||
self.i.mtime = 0
|
||||
self.lib.store(self.i)
|
||||
commands.update_items(self.lib, query, album, move, True, False, None)
|
||||
commands.update_items(self.lib, query, album, move, False)
|
||||
|
||||
def test_delete_removes_item(self):
|
||||
self.assertTrue(list(self.lib.items()))
|
||||
|
|
@ -453,7 +454,7 @@ class AutotagTest(unittest.TestCase):
|
|||
[_common.item()],
|
||||
)
|
||||
task.set_candidates('artist', 'album', [], autotag.RECOMMEND_NONE)
|
||||
res = commands.choose_match(task, _common.iconfig(None, quiet=False))
|
||||
res = commands.choose_match(_common.import_session(None), task)
|
||||
self.assertEqual(res, result)
|
||||
self.assertTrue('No match' in self.io.getoutput())
|
||||
|
||||
|
|
@ -573,46 +574,47 @@ class ShowdiffTest(unittest.TestCase):
|
|||
self.io.restore()
|
||||
|
||||
def test_showdiff_strings(self):
|
||||
commands._showdiff('field', 'old', 'new', True)
|
||||
commands._showdiff('field', 'old', 'new')
|
||||
out = self.io.getoutput()
|
||||
self.assertTrue('field' in out)
|
||||
|
||||
def test_showdiff_identical(self):
|
||||
commands._showdiff('field', 'old', 'old', True)
|
||||
commands._showdiff('field', 'old', 'old')
|
||||
out = self.io.getoutput()
|
||||
self.assertFalse('field' in out)
|
||||
|
||||
def test_showdiff_ints(self):
|
||||
commands._showdiff('field', 2, 3, True)
|
||||
commands._showdiff('field', 2, 3)
|
||||
out = self.io.getoutput()
|
||||
self.assertTrue('field' in out)
|
||||
|
||||
def test_showdiff_ints_no_color(self):
|
||||
commands._showdiff('field', 2, 3, False)
|
||||
config['color'] = False
|
||||
commands._showdiff('field', 2, 3)
|
||||
out = self.io.getoutput()
|
||||
self.assertTrue('field' in out)
|
||||
|
||||
def test_showdiff_shows_both(self):
|
||||
commands._showdiff('field', 'old', 'new', True)
|
||||
commands._showdiff('field', 'old', 'new')
|
||||
out = self.io.getoutput()
|
||||
self.assertTrue('old' in out)
|
||||
self.assertTrue('new' in out)
|
||||
|
||||
def test_showdiff_floats_close_to_identical(self):
|
||||
commands._showdiff('field', 1.999, 2.001, True)
|
||||
commands._showdiff('field', 1.999, 2.001)
|
||||
out = self.io.getoutput()
|
||||
self.assertFalse('field' in out)
|
||||
|
||||
def test_showdiff_floats_differenct(self):
|
||||
commands._showdiff('field', 1.999, 4.001, True)
|
||||
commands._showdiff('field', 1.999, 4.001)
|
||||
out = self.io.getoutput()
|
||||
self.assertTrue('field' in out)
|
||||
|
||||
def test_showdiff_ints_colorizing_is_not_stringwise(self):
|
||||
commands._showdiff('field', 222, 333, True)
|
||||
commands._showdiff('field', 222, 333)
|
||||
complete_diff = self.io.getoutput().split()[1]
|
||||
|
||||
commands._showdiff('field', 222, 232, True)
|
||||
commands._showdiff('field', 222, 232)
|
||||
partial_diff = self.io.getoutput().split()[1]
|
||||
|
||||
self.assertEqual(complete_diff, partial_diff)
|
||||
|
|
@ -667,7 +669,6 @@ class ShowChangeTest(unittest.TestCase):
|
|||
cur_artist,
|
||||
cur_album,
|
||||
autotag.AlbumMatch(0.1, info, mapping, set(), set()),
|
||||
color=False,
|
||||
)
|
||||
return self.io.getoutput().lower()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue