From 7f372a6a59c748992b58c4d419c1b0ddb8ec018e Mon Sep 17 00:00:00 2001 From: Jesse Weinstein Date: Sun, 3 Jan 2016 09:48:22 -0800 Subject: [PATCH] Add last 2 tests -- 100% line coverage --- test/test_play.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/test_play.py b/test/test_play.py index 4166c895f..6d0986102 100644 --- a/test/test_play.py +++ b/test/test_play.py @@ -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')),