
"""Tests for the play plugin"""

from __future__ import (division, absolute_import, print_function,
                        unicode_literals)

from mock import patch, Mock

from test._common import unittest
from test.helper import TestHelper


class PlayPluginTest(unittest.TestCase, TestHelper):
    def setUp(self):
        self.setup_beets()
        self.load_plugins('play')
        self.add_item(title='aNiceTitle')

    def tearDown(self):
        self.teardown_beets()
        self.unload_plugins()

    @patch('beetsplug.play.util.interactive_open', Mock())
    def test_basic(self):
        self.run_command('play', 'title:aNiceTitle')


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

if __name__ == b'__main__':
    unittest.main(defaultTest='suite')


"""Tests for the play plugin"""

from __future__ import (division, absolute_import, print_function,
                        unicode_literals)

from mock import patch, ANY

from test._common import unittest
from test.helper import TestHelper


class PlayPluginTest(unittest.TestCase, TestHelper):
    def setUp(self):
        self.setup_beets()
        self.load_plugins('play')
        self.item = self.add_item(title='aNiceTitle')

    def tearDown(self):
        self.teardown_beets()
        self.unload_plugins()

    @patch('beetsplug.play.util.interactive_open')
    def test_basic(self, open_mock):
        self.run_command('play', 'title:aNiceTitle')

        open_mock.assert_called_once_with(ANY, None)
        playlist = open(open_mock.call_args[0][0][0], 'r')
        self.assertEqual(self.item.path.decode('utf-8') + '\n',
                         playlist.read().decode('utf-8'))


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

if __name__ == b'__main__':
    unittest.main(defaultTest='suite')

Verify that the generated playlist contains the path to the item
Verify that the generated playlist contains the path to the item

  
  """Tests for the play plugin"""
  
  from __future__ import (division, absolute_import, print_function,
                          unicode_literals)
  
- from mock import patch, Mock
+ from mock import patch, ANY
  
  from test._common import unittest
  from test.helper import TestHelper
  
  
  class PlayPluginTest(unittest.TestCase, TestHelper):
      def setUp(self):
          self.setup_beets()
          self.load_plugins('play')
-         self.add_item(title='aNiceTitle')
+         self.item = self.add_item(title='aNiceTitle')
  
      def tearDown(self):
          self.teardown_beets()
          self.unload_plugins()
  
-     @patch('beetsplug.play.util.interactive_open', Mock())
+     @patch('beetsplug.play.util.interactive_open')
-     def test_basic(self):
+     def test_basic(self, open_mock):
          self.run_command('play', 'title:aNiceTitle')
+ 
+         open_mock.assert_called_once_with(ANY, None)
+         playlist = open(open_mock.call_args[0][0][0], 'r')
+         self.assertEqual(self.item.path.decode('utf-8') + '\n',
+                          playlist.read().decode('utf-8'))
  
  
  def suite():
      return unittest.TestLoader().loadTestsFromName(__name__)
  
  if __name__ == b'__main__':
      unittest.main(defaultTest='suite')
  
Verify that the generated playlist contains the path to the item
## Code Before:

"""Tests for the play plugin"""

from __future__ import (division, absolute_import, print_function,
                        unicode_literals)

from mock import patch, Mock

from test._common import unittest
from test.helper import TestHelper


class PlayPluginTest(unittest.TestCase, TestHelper):
    def setUp(self):
        self.setup_beets()
        self.load_plugins('play')
        self.add_item(title='aNiceTitle')

    def tearDown(self):
        self.teardown_beets()
        self.unload_plugins()

    @patch('beetsplug.play.util.interactive_open', Mock())
    def test_basic(self):
        self.run_command('play', 'title:aNiceTitle')


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

if __name__ == b'__main__':
    unittest.main(defaultTest='suite')

## Instruction:
Verify that the generated playlist contains the path to the item
## Code After:

"""Tests for the play plugin"""

from __future__ import (division, absolute_import, print_function,
                        unicode_literals)

from mock import patch, ANY

from test._common import unittest
from test.helper import TestHelper


class PlayPluginTest(unittest.TestCase, TestHelper):
    def setUp(self):
        self.setup_beets()
        self.load_plugins('play')
        self.item = self.add_item(title='aNiceTitle')

    def tearDown(self):
        self.teardown_beets()
        self.unload_plugins()

    @patch('beetsplug.play.util.interactive_open')
    def test_basic(self, open_mock):
        self.run_command('play', 'title:aNiceTitle')

        open_mock.assert_called_once_with(ANY, None)
        playlist = open(open_mock.call_args[0][0][0], 'r')
        self.assertEqual(self.item.path.decode('utf-8') + '\n',
                         playlist.read().decode('utf-8'))


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

if __name__ == b'__main__':
    unittest.main(defaultTest='suite')
