Example #1
0
    def test_open_anything(self):
        with _common.system_mock('Windows'):
            self.assertEqual(util.open_anything(), 'start')

        with _common.system_mock('Darwin'):
            self.assertEqual(util.open_anything(), 'open')

        with _common.system_mock('Tagada'):
            self.assertEqual(util.open_anything(), 'xdg-open')
Example #2
0
    def test_open_anything(self):
        with _common.system_mock('Windows'):
            self.assertEqual(util.open_anything(), 'start')

        with _common.system_mock('Darwin'):
            self.assertEqual(util.open_anything(), 'open')

        with _common.system_mock('Tagada'):
            self.assertEqual(util.open_anything(), 'xdg-open')
Example #3
0
    def test_case_sensitivity(self):
        self.add_album(path='/A/B/C2.mp3', title=u'caps path')

        makeq = partial(beets.library.PathQuery, u'path', '/A/B')

        results = self.lib.items(makeq(case_sensitive=True))
        self.assert_items_matched(results, [u'caps path'])

        results = self.lib.items(makeq(case_sensitive=False))
        self.assert_items_matched(results, [u'path item', u'caps path'])

        # Check for correct case sensitivity selection (this check
        # only works on non-Windows OSes).
        with _common.system_mock('Darwin'):
            # exists = True and samefile = True => Case insensitive
            q = makeq()
            self.assertEqual(q.case_sensitive, False)

            # exists = True and samefile = False => Case sensitive
            self.patcher_samefile.stop()
            self.patcher_samefile.start().return_value = False
            try:
                q = makeq()
                self.assertEqual(q.case_sensitive, True)
            finally:
                self.patcher_samefile.stop()
                self.patcher_samefile.start().return_value = True

        # Test platform-aware default sensitivity when the library path
        # does not exist. For the duration of this check, we change the
        # `os.path.exists` mock to return False.
        self.patcher_exists.stop()
        self.patcher_exists.start().return_value = False
        try:
            with _common.system_mock('Darwin'):
                q = makeq()
                self.assertEqual(q.case_sensitive, True)

            with _common.system_mock('Windows'):
                q = makeq()
                self.assertEqual(q.case_sensitive, False)
        finally:
            # Restore the `os.path.exists` mock to its original state.
            self.patcher_exists.stop()
            self.patcher_exists.start().return_value = True
Example #4
0
    def test_case_sensitivity(self):
        self.add_album(path=b'/A/B/C2.mp3', title='caps path')

        makeq = partial(beets.library.PathQuery, 'path', '/A/B')

        results = self.lib.items(makeq(case_sensitive=True))
        self.assert_items_matched(results, ['caps path'])

        results = self.lib.items(makeq(case_sensitive=False))
        self.assert_items_matched(results, ['path item', 'caps path'])

        # Check for correct case sensitivity selection (this check
        # only works on non-Windows OSes).
        with _common.system_mock('Darwin'):
            # exists = True and samefile = True => Case insensitive
            q = makeq()
            self.assertEqual(q.case_sensitive, False)

            # exists = True and samefile = False => Case sensitive
            self.patcher_samefile.stop()
            self.patcher_samefile.start().return_value = False
            try:
                q = makeq()
                self.assertEqual(q.case_sensitive, True)
            finally:
                self.patcher_samefile.stop()
                self.patcher_samefile.start().return_value = True

        # Test platform-aware default sensitivity when the library path
        # does not exist. For the duration of this check, we change the
        # `os.path.exists` mock to return False.
        self.patcher_exists.stop()
        self.patcher_exists.start().return_value = False
        try:
            with _common.system_mock('Darwin'):
                q = makeq()
                self.assertEqual(q.case_sensitive, True)

            with _common.system_mock('Windows'):
                q = makeq()
                self.assertEqual(q.case_sensitive, False)
        finally:
            # Restore the `os.path.exists` mock to its original state.
            self.patcher_exists.stop()
            self.patcher_exists.start().return_value = True
Example #5
0
    def test_case_sensitivity(self):
        self.add_album(path='/A/B/C2.mp3', title='caps path')

        makeq = partial(beets.library.PathQuery, 'path', '/A/B')

        results = self.lib.items(makeq(case_sensitive=True))
        self.assert_items_matched(results, ['caps path'])

        results = self.lib.items(makeq(case_sensitive=False))
        self.assert_items_matched(results, ['path item', 'caps path'])

        # test platform-aware default sensitivity
        with _common.system_mock('Darwin'):
            q = makeq()
            self.assertEqual(q.case_sensitive, True)

        with _common.system_mock('Windows'):
            q = makeq()
            self.assertEqual(q.case_sensitive, False)
Example #6
0
    def test_case_sensitivity(self):
        self.add_album(path='/A/B/C2.mp3', title='caps path')

        makeq = partial(beets.library.PathQuery, 'path', '/A/B')

        results = self.lib.items(makeq(case_sensitive=True))
        self.assert_items_matched(results, ['caps path'])

        results = self.lib.items(makeq(case_sensitive=False))
        self.assert_items_matched(results, ['path item', 'caps path'])

        # test platform-aware default sensitivity
        with _common.system_mock('Darwin'):
            q = makeq()
            self.assertEqual(q.case_sensitive, True)

        with _common.system_mock('Windows'):
            q = makeq()
            self.assertEqual(q.case_sensitive, False)
 def test_edit_config_with_windows_exec(self):
     with _common.system_mock('Windows'):
         with patch('os.execlp') as execlp:
             self.run_command('config', '-e')
     execlp.assert_called_once_with(self.config_path, self.config_path)
 def test_edit_config_with_xdg_open(self):
     with _common.system_mock('Linux'):
         with patch('os.execlp') as execlp:
             self.run_command('config', '-e')
     execlp.assert_called_once_with(
         'xdg-open', 'xdg-open', self.config_path)