Add last 2 tests -- 100% line coverage

This commit is contained in:
Jesse Weinstein 2016-01-03 09:48:22 -08:00
parent 4a1a70e23d
commit 7f372a6a59

View file

@ -10,8 +10,9 @@ import os
from mock import patch, ANY
from test._common import unittest
from test.helper import TestHelper
from test.helper import TestHelper, control_stdin
from beets.ui import UserError
@patch('beetsplug.play.util.interactive_open')
class PlayPluginTest(unittest.TestCase, TestHelper):
@ -79,6 +80,19 @@ class PlayPluginTest(unittest.TestCase, TestHelper):
self.run_command('play', 'not found')
open_mock.assert_not_called()
def test_warning_threshold(self, open_mock):
self.config['play']['warning_treshold'] = 1
item2 = self.add_item(title='another NiceTitle')
with control_stdin("a"):
self.run_command('play', 'nice')
open_mock.assert_not_called()
def test_command_failed(self, open_mock):
open_mock.side_effect = OSError("some reason")
with self.assertRaises(UserError):
self.run_command('play', 'title:aNiceTitle')
def assertPlaylistCorrect(self, open_mock, expected='{}\n'):
playlist = open(open_mock.call_args[0][0][0], 'r')
self.assertEqual(expected.format(self.item.path.decode('utf-8')),