beets/test/test_bareasc.py
Graham R. Cobb dcbe622b76 Oops, use in for matching! (It was late last night!)
Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
2021-03-15 10:25:19 +00:00

90 lines
2.6 KiB
Python

# -*- coding: utf-8 -*-
# This file is part of beets.
# Copyright 2021, Graham R. Cobb.
"""Tests for the 'bareasc' plugin."""
from __future__ import division, absolute_import, print_function
import unittest
from test.helper import TestHelper
from beets import logging
class BareascPluginTest(unittest.TestCase, TestHelper):
def setUp(self):
self.setup_beets()
self.log = logging.getLogger('beets.web')
self.config['bareasc']['prefix'] = u'#'
self.load_plugins('bareasc')
# Add library elements. Note that self.lib.add overrides any "id=<n>"
# and assigns the next free id number.
self.add_item(title=u'with accents',
album_id=2,
artist=u'Antonín dvořák')
self.add_item(title=u'without accents',
artist=u'Antonín dvorak')
self.add_item(title=u'with umlaut',
album_id=2,
artist=u'Brüggen')
self.add_item(title=u'without umlaut',
artist=u'Bruggen')
def test_search_normal_noaccent(self):
items = self.lib.items(u'dvorak')
self.assertEqual(len(items), 1)
self.assertEqual([items[0].title], [u'without accents'])
def test_search_normal_accent(self):
items = self.lib.items(u'dvořák')
self.assertEqual(len(items), 1)
self.assertEqual([items[0].title], [u'with accents'])
def test_search_bareasc_noaccent(self):
items = self.lib.items(u'#dvorak')
self.assertEqual(len(items), 2)
self.assertEqual(
{items[0].title, items[1].title},
{u'without accents', u'with accents'}
)
def test_search_bareasc_accent(self):
items = self.lib.items(u'#dvořák')
self.assertEqual(len(items), 2)
self.assertEqual(
{items[0].title, items[1].title},
{u'without accents', u'with accents'}
)
def test_search_bareasc_noumlaut(self):
items = self.lib.items(u'#Bruggen')
self.assertEqual(len(items), 2)
self.assertEqual(
{items[0].title, items[1].title},
{u'without umlaut', u'with umlaut'}
)
def test_search_bareasc_umlaut(self):
items = self.lib.items(u'#Brüggen')
self.assertEqual(len(items), 2)
self.assertEqual(
{items[0].title, items[1].title},
{u'without umlaut', u'with umlaut'}
)
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == '__main__':
unittest.main(defaultTest='suite')