# Path: mycroft/util/file_utils.py
# def get_temp_path(*args):
#     """Generate a valid path in the system temp directory.
# 
#     This method accepts one or more strings as arguments. The arguments are
#     joined and returned as a complete path inside the systems temp directory.
#     Importantly, this will not create any directories or files.
# 
#     Example usage: get_temp_path('mycroft', 'audio', 'example.wav')
#     Will return the equivalent of: '/tmp/mycroft/audio/example.wav'
# 
#     Args:
#         path_element (str): directories and/or filename
# 
#     Returns:
#         (str) a valid path in the systems temp directory
#     """
#     try:
#         path = os.path.join(tempfile.gettempdir(), *args)
#     except TypeError:
#         raise TypeError("Could not create a temp path, get_temp_path() only "
#                         "accepts Strings")
#     return path


from unittest import TestCase, mock
from test.util import Anything
from mycroft.util import (play_ogg, play_mp3, play_wav, play_audio_file,
                          record)
from mycroft.util.file_utils import get_temp_path
        mock_subprocess.Popen.reset_mock()
        mock_conf.get.return_value = test_config
        play_audio_file('insult.ogg')
        mock_subprocess.Popen.assert_called_once_with(['mock_ogg',
                                                       'insult.ogg'],
                                                      env=Anything())


@mock.patch('mycroft.util.audio_utils.subprocess')
class TestRecordSounds(TestCase):
    def test_record_with_duration(self, mock_subprocess):
        mock_proc = mock.Mock()(name='mock process')
        mock_subprocess.Popen.return_value = mock_proc
        rate = 16000
        channels = 1
        filename = get_temp_path('test.wav')
        duration = 42
        res = record(filename, duration, rate, channels)
        mock_subprocess.Popen.assert_called_once_with(['arecord',
                                                       '-r', str(rate),
                                                       '-c', str(channels),
                                                       '-d', str(duration),
                                                       filename])
        self.assertEqual(res, mock_proc)

    def test_record_without_duration(self, mock_subprocess):
        mock_proc = mock.Mock(name='mock process')
        mock_subprocess.Popen.return_value = mock_proc
        rate = 16000
        channels = 1

# Path: mycroft/util/file_utils.py
# def get_temp_path(*args):
#     """Generate a valid path in the system temp directory.
# 
#     This method accepts one or more strings as arguments. The arguments are
#     joined and returned as a complete path inside the systems temp directory.
#     Importantly, this will not create any directories or files.
# 
#     Example usage: get_temp_path('mycroft', 'audio', 'example.wav')
#     Will return the equivalent of: '/tmp/mycroft/audio/example.wav'
# 
#     Args:
#         path_element (str): directories and/or filename
# 
#     Returns:
#         (str) a valid path in the systems temp directory
#     """
#     try:
#         path = os.path.join(tempfile.gettempdir(), *args)
#     except TypeError:
#         raise TypeError("Could not create a temp path, get_temp_path() only "
#                         "accepts Strings")
#     return path


# Path: test/unittests/util/test_audio_utils.py
from unittest import TestCase, mock
from test.util import Anything
from mycroft.util import (play_ogg, play_mp3, play_wav, play_audio_file,
                          record)
from mycroft.util.file_utils import get_temp_path

        mock_subprocess.Popen.reset_mock()
        mock_conf.get.return_value = test_config
        play_audio_file('insult.ogg')
        mock_subprocess.Popen.assert_called_once_with(['mock_ogg',
                                                       'insult.ogg'],
                                                      env=Anything())


@mock.patch('mycroft.util.audio_utils.subprocess')
class TestRecordSounds(TestCase):
    def test_record_with_duration(self, mock_subprocess):
        mock_proc = mock.Mock()(name='mock process')
        mock_subprocess.Popen.return_value = mock_proc
        rate = 16000
        channels = 1
        filename = get_temp_path('test.wav')
        duration = 42
        res = record(filename, duration, rate, channels)
        mock_subprocess.Popen.assert_called_once_with(['arecord',
                                                       '-r', str(rate),
                                                       '-c', str(channels),
                                                       '-d', str(duration),
                                                       filename])
        self.assertEqual(res, mock_proc)

    def test_record_without_duration(self, mock_subprocess):
        mock_proc = mock.Mock(name='mock process')
        mock_subprocess.Popen.return_value = mock_proc
        rate = 16000
        channels = 1

        filename = get_temp_path('test.wav')