beets / test /

The default branch has multiple heads

"""Tests for the 'the' plugin"""

from _common import unittest
import _common
from beets import config
from beetsplug.the import ThePlugin, PATTERN_A, PATTERN_THE, FORMAT

class ThePluginTest(_common.TestCase):

    def test_unthe_with_default_patterns(self):
        self.assertEqual(ThePlugin().unthe('', PATTERN_THE), '')
        self.assertEqual(ThePlugin().unthe('The Something', PATTERN_THE), 
                         'Something, The')
        self.assertEqual(ThePlugin().unthe('The The', PATTERN_THE), 
                         'The, The')
        self.assertEqual(ThePlugin().unthe('The    The', PATTERN_THE), 
                         'The, The')
        self.assertEqual(ThePlugin().unthe('The   The   X', PATTERN_THE), 
                         'The   X, The')
        self.assertEqual(ThePlugin().unthe('the The', PATTERN_THE), 
                         'The, the')
        self.assertEqual(ThePlugin().unthe('Protected The', PATTERN_THE), 
                         'Protected The')
        self.assertEqual(ThePlugin().unthe('A Boy', PATTERN_A), 
                         'Boy, A')
        self.assertEqual(ThePlugin().unthe('a girl', PATTERN_A), 
                         'girl, a')
        self.assertEqual(ThePlugin().unthe('An Apple', PATTERN_A), 
                         'Apple, An')
        self.assertEqual(ThePlugin().unthe('An A Thing', PATTERN_A), 
                         'A Thing, An')
        self.assertEqual(ThePlugin().unthe('the An Arse', PATTERN_A), 
                         'the An Arse')

    def test_unthe_with_strip(self):
        config['the']['strip'] = True
        self.assertEqual(ThePlugin().unthe('The Something', PATTERN_THE), 
        self.assertEqual(ThePlugin().unthe('An A', PATTERN_A), 'A') 

    def test_template_function_with_defaults(self):
        ThePlugin().patterns = [PATTERN_THE, PATTERN_A]
        ThePlugin().format = FORMAT
        self.assertEqual(ThePlugin().the_template_func('The The'), 'The, The')
        self.assertEqual(ThePlugin().the_template_func('An A'), 'A, An')

    def test_custom_pattern(self):
        config['the']['patterns'] = [u'^test\s']
        config['the']['format'] = FORMAT
        self.assertEqual(ThePlugin().the_template_func('test passed'), 
                         'passed, test')

    def test_custom_format(self):
        config['the']['patterns'] = [PATTERN_THE, PATTERN_A]
        config['the']['format'] = u'{1} ({0})'
        self.assertEqual(ThePlugin().the_template_func('The A'), 'The (A)')

def suite():
    return unittest.TestLoader().loadTestsFromName(__name__)

if __name__ == '__main__':
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.