mirror of
https://github.com/beetbox/beets.git
synced 2025-12-22 16:43:25 +01:00
add relative_to test
This commit is contained in:
parent
6b49b0ff23
commit
a47de98653
1 changed files with 15 additions and 6 deletions
|
|
@ -30,23 +30,32 @@ class PlayPluginTest(unittest.TestCase, TestHelper):
|
|||
|
||||
@patch('beetsplug.play.util.interactive_open')
|
||||
def test_args_option(self, open_mock):
|
||||
self.config['play']['command'] = 'true'
|
||||
self.config['play']['command'] = 'echo'
|
||||
self.run_command('play', '-A', 'foo', 'title:aNiceTitle')
|
||||
|
||||
open_mock.assert_called_once_with(ANY, 'true foo')
|
||||
open_mock.assert_called_once_with(ANY, 'echo foo')
|
||||
self.assertPlaylistCorrect(open_mock)
|
||||
|
||||
@patch('beetsplug.play.util.interactive_open')
|
||||
def test_args_option_in_middle(self, open_mock):
|
||||
self.config['play']['command'] = 'true $args other'
|
||||
self.config['play']['command'] = 'echo $args other'
|
||||
self.run_command('play', '-A', 'foo', 'title:aNiceTitle')
|
||||
|
||||
open_mock.assert_called_once_with(ANY, 'true foo other')
|
||||
open_mock.assert_called_once_with(ANY, 'echo foo other')
|
||||
self.assertPlaylistCorrect(open_mock)
|
||||
|
||||
def assertPlaylistCorrect(self, open_mock):
|
||||
@patch('beetsplug.play.util.interactive_open')
|
||||
def test_relative_to(self, open_mock):
|
||||
self.config['play']['command'] = 'echo'
|
||||
self.config['play']['relative_to'] = '/something'
|
||||
self.run_command('play', 'title:aNiceTitle')
|
||||
|
||||
open_mock.assert_called_once_with(ANY, 'echo')
|
||||
self.assertPlaylistCorrect(open_mock, '..{}\n')
|
||||
|
||||
def assertPlaylistCorrect(self, open_mock, expected='{}\n'):
|
||||
playlist = open(open_mock.call_args[0][0][0], 'r')
|
||||
self.assertEqual(self.item.path.decode('utf-8') + '\n',
|
||||
self.assertEqual(expected.format(self.item.path.decode('utf-8')),
|
||||
playlist.read().decode('utf-8'))
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue