mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 16:42:42 +01:00
Rename LibTestCase to ItemInDBTestCase
This commit is contained in:
parent
91099d362e
commit
b64eaeda0a
7 changed files with 22 additions and 26 deletions
|
|
@ -520,20 +520,15 @@ class BeetsTestCase(unittest.TestCase, TestHelper):
|
||||||
self.teardown_beets()
|
self.teardown_beets()
|
||||||
|
|
||||||
|
|
||||||
class LibTestCase(BeetsTestCase):
|
class ItemInDBTestCase(BeetsTestCase):
|
||||||
"""A test case that includes an in-memory library object (`lib`) and
|
"""A test case that includes an in-memory library object (`lib`) and
|
||||||
an item added to the library (`i`).
|
an item added to the library (`i`).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.lib = beets.library.Library(":memory:")
|
|
||||||
self.i = _common.item(self.lib)
|
self.i = _common.item(self.lib)
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
self.lib._connection().close()
|
|
||||||
super().tearDown()
|
|
||||||
|
|
||||||
|
|
||||||
class ImportHelper:
|
class ImportHelper:
|
||||||
"""Provides tools to setup a library, a directory containing files that are
|
"""Provides tools to setup a library, a directory containing files that are
|
||||||
|
|
@ -985,3 +980,4 @@ class CleanupModulesMixin:
|
||||||
"""Remove files created by the plugin."""
|
"""Remove files created by the plugin."""
|
||||||
for module in cls.modules:
|
for module in cls.modules:
|
||||||
clean_module_tempdir(module)
|
clean_module_tempdir(module)
|
||||||
|
self.lib = beets.library.Library(":memory:")
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,11 @@ import unittest
|
||||||
from beets import logging
|
from beets import logging
|
||||||
from beets.library import Album, Item
|
from beets.library import Album, Item
|
||||||
from beets.test import _common
|
from beets.test import _common
|
||||||
from beets.test.helper import LibTestCase
|
from beets.test.helper import ItemInDBTestCase
|
||||||
from beetsplug import web
|
from beetsplug import web
|
||||||
|
|
||||||
|
|
||||||
class WebPluginTest(LibTestCase):
|
class WebPluginTest(ItemInDBTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.log = logging.getLogger("beets.web")
|
self.log = logging.getLogger("beets.web")
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ from beets.dbcore.query import (
|
||||||
InvalidQueryArgumentValueError,
|
InvalidQueryArgumentValueError,
|
||||||
_parse_periods,
|
_parse_periods,
|
||||||
)
|
)
|
||||||
from beets.test.helper import LibTestCase
|
from beets.test.helper import ItemInDBTestCase
|
||||||
|
|
||||||
|
|
||||||
def _date(string):
|
def _date(string):
|
||||||
|
|
@ -152,7 +152,7 @@ def _parsetime(s):
|
||||||
return time.mktime(datetime.strptime(s, "%Y-%m-%d %H:%M").timetuple())
|
return time.mktime(datetime.strptime(s, "%Y-%m-%d %H:%M").timetuple())
|
||||||
|
|
||||||
|
|
||||||
class DateQueryTest(LibTestCase):
|
class DateQueryTest(ItemInDBTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.i.added = _parsetime("2013-03-30 22:21")
|
self.i.added = _parsetime("2013-03-30 22:21")
|
||||||
|
|
@ -187,7 +187,7 @@ class DateQueryTest(LibTestCase):
|
||||||
self.assertEqual(len(matched), 0)
|
self.assertEqual(len(matched), 0)
|
||||||
|
|
||||||
|
|
||||||
class DateQueryTestRelative(LibTestCase):
|
class DateQueryTestRelative(ItemInDBTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
|
|
@ -233,7 +233,7 @@ class DateQueryTestRelative(LibTestCase):
|
||||||
self.assertEqual(len(matched), 0)
|
self.assertEqual(len(matched), 0)
|
||||||
|
|
||||||
|
|
||||||
class DateQueryTestRelativeMore(LibTestCase):
|
class DateQueryTestRelativeMore(ItemInDBTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.i.added = _parsetime(datetime.now().strftime("%Y-%m-%d %H:%M"))
|
self.i.added = _parsetime(datetime.now().strftime("%Y-%m-%d %H:%M"))
|
||||||
|
|
|
||||||
|
|
@ -32,14 +32,14 @@ import beets.library
|
||||||
from beets import config, plugins, util
|
from beets import config, plugins, util
|
||||||
from beets.test import _common
|
from beets.test import _common
|
||||||
from beets.test._common import item
|
from beets.test._common import item
|
||||||
from beets.test.helper import BeetsTestCase, LibTestCase
|
from beets.test.helper import BeetsTestCase, ItemInDBTestCase
|
||||||
from beets.util import bytestring_path, syspath
|
from beets.util import bytestring_path, syspath
|
||||||
|
|
||||||
# Shortcut to path normalization.
|
# Shortcut to path normalization.
|
||||||
np = util.normpath
|
np = util.normpath
|
||||||
|
|
||||||
|
|
||||||
class LoadTest(LibTestCase):
|
class LoadTest(ItemInDBTestCase):
|
||||||
def test_load_restores_data_from_db(self):
|
def test_load_restores_data_from_db(self):
|
||||||
original_title = self.i.title
|
original_title = self.i.title
|
||||||
self.i.title = "something"
|
self.i.title = "something"
|
||||||
|
|
@ -53,7 +53,7 @@ class LoadTest(LibTestCase):
|
||||||
self.assertNotIn("artist", self.i._dirty)
|
self.assertNotIn("artist", self.i._dirty)
|
||||||
|
|
||||||
|
|
||||||
class StoreTest(LibTestCase):
|
class StoreTest(ItemInDBTestCase):
|
||||||
def test_store_changes_database_value(self):
|
def test_store_changes_database_value(self):
|
||||||
self.i.year = 1987
|
self.i.year = 1987
|
||||||
self.i.store()
|
self.i.store()
|
||||||
|
|
@ -126,7 +126,7 @@ class AddTest(BeetsTestCase):
|
||||||
self.assertEqual(new_grouping, self.i.grouping)
|
self.assertEqual(new_grouping, self.i.grouping)
|
||||||
|
|
||||||
|
|
||||||
class RemoveTest(LibTestCase):
|
class RemoveTest(ItemInDBTestCase):
|
||||||
def test_remove_deletes_from_db(self):
|
def test_remove_deletes_from_db(self):
|
||||||
self.i.remove()
|
self.i.remove()
|
||||||
c = self.lib._connection().execute("select * from items")
|
c = self.lib._connection().execute("select * from items")
|
||||||
|
|
@ -547,7 +547,7 @@ class DestinationTest(BeetsTestCase):
|
||||||
self.assertEqual(self.i.destination(), np("one/foo/two"))
|
self.assertEqual(self.i.destination(), np("one/foo/two"))
|
||||||
|
|
||||||
|
|
||||||
class ItemFormattedMappingTest(LibTestCase):
|
class ItemFormattedMappingTest(ItemInDBTestCase):
|
||||||
def test_formatted_item_value(self):
|
def test_formatted_item_value(self):
|
||||||
formatted = self.i.formatted()
|
formatted = self.i.formatted()
|
||||||
self.assertEqual(formatted["artist"], "the artist")
|
self.assertEqual(formatted["artist"], "the artist")
|
||||||
|
|
@ -1228,7 +1228,7 @@ class ImportTimeTest(BeetsTestCase):
|
||||||
self.assertGreater(self.singleton.added, 0)
|
self.assertGreater(self.singleton.added, 0)
|
||||||
|
|
||||||
|
|
||||||
class TemplateTest(LibTestCase):
|
class TemplateTest(ItemInDBTestCase):
|
||||||
def test_year_formatted_in_template(self):
|
def test_year_formatted_in_template(self):
|
||||||
self.i.year = 123
|
self.i.year = 123
|
||||||
self.i.store()
|
self.i.store()
|
||||||
|
|
@ -1258,7 +1258,7 @@ class TemplateTest(LibTestCase):
|
||||||
self.assertEqual(f"{item:$tagada}", "togodo")
|
self.assertEqual(f"{item:$tagada}", "togodo")
|
||||||
|
|
||||||
|
|
||||||
class UnicodePathTest(LibTestCase):
|
class UnicodePathTest(ItemInDBTestCase):
|
||||||
def test_unicode_path(self):
|
def test_unicode_path(self):
|
||||||
self.i.path = os.path.join(_common.RSRC, "unicode\u2019d.mp3".encode())
|
self.i.path = os.path.join(_common.RSRC, "unicode\u2019d.mp3".encode())
|
||||||
# If there are any problems with unicode paths, we will raise
|
# If there are any problems with unicode paths, we will raise
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ from beets.dbcore.query import (
|
||||||
)
|
)
|
||||||
from beets.library import Item, Library
|
from beets.library import Item, Library
|
||||||
from beets.test import _common
|
from beets.test import _common
|
||||||
from beets.test.helper import BeetsTestCase, LibTestCase
|
from beets.test.helper import BeetsTestCase, ItemInDBTestCase
|
||||||
from beets.util import syspath
|
from beets.util import syspath
|
||||||
|
|
||||||
# Because the absolute path begins with something like C:, we
|
# Because the absolute path begins with something like C:, we
|
||||||
|
|
@ -55,7 +55,7 @@ class AssertsMixin:
|
||||||
self.assertNotIn(item.id, result_ids)
|
self.assertNotIn(item.id, result_ids)
|
||||||
|
|
||||||
|
|
||||||
class AnyFieldQueryTest(LibTestCase):
|
class AnyFieldQueryTest(ItemInDBTestCase):
|
||||||
def test_no_restriction(self):
|
def test_no_restriction(self):
|
||||||
q = dbcore.query.AnyFieldQuery(
|
q = dbcore.query.AnyFieldQuery(
|
||||||
"title",
|
"title",
|
||||||
|
|
@ -486,7 +486,7 @@ class MatchTest(BeetsTestCase):
|
||||||
self.assertNotEqual(q3, q4)
|
self.assertNotEqual(q3, q4)
|
||||||
|
|
||||||
|
|
||||||
class PathQueryTest(LibTestCase, AssertsMixin):
|
class PathQueryTest(ItemInDBTestCase, AssertsMixin):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import unittest
|
||||||
|
|
||||||
from beets import library, ui
|
from beets import library, ui
|
||||||
from beets.test import _common
|
from beets.test import _common
|
||||||
from beets.test.helper import BeetsTestCase, LibTestCase
|
from beets.test.helper import BeetsTestCase, ItemInDBTestCase
|
||||||
from beets.ui import commands
|
from beets.ui import commands
|
||||||
from beets.util import syspath
|
from beets.util import syspath
|
||||||
|
|
||||||
|
|
@ -88,7 +88,7 @@ class QueryTest(BeetsTestCase):
|
||||||
self.check_do_query(0, 2, album=True, also_items=False)
|
self.check_do_query(0, 2, album=True, also_items=False)
|
||||||
|
|
||||||
|
|
||||||
class FieldsTest(LibTestCase):
|
class FieldsTest(ItemInDBTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ from random import random
|
||||||
|
|
||||||
from beets import config, ui
|
from beets import config, ui
|
||||||
from beets.test import _common
|
from beets.test import _common
|
||||||
from beets.test.helper import BeetsTestCase, LibTestCase, control_stdin
|
from beets.test.helper import BeetsTestCase, ItemInDBTestCase, control_stdin
|
||||||
|
|
||||||
|
|
||||||
class InputMethodsTest(BeetsTestCase):
|
class InputMethodsTest(BeetsTestCase):
|
||||||
|
|
@ -90,7 +90,7 @@ class InputMethodsTest(BeetsTestCase):
|
||||||
self.assertEqual(items, ["1", "3"])
|
self.assertEqual(items, ["1", "3"])
|
||||||
|
|
||||||
|
|
||||||
class InitTest(LibTestCase):
|
class InitTest(ItemInDBTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue