def test_play_audio_file(self, mock_subprocess, mock_conf): mock_conf.get.return_value = test_config play_audio_file('indifference.wav') mock_subprocess.Popen.assert_called_once_with( ['mock_wav', 'indifference.wav'], env=Anything()) mock_subprocess.Popen.reset_mock() play_audio_file('praise.mp3') mock_subprocess.Popen.assert_called_once_with( ['mock_mp3', 'praise.mp3'], env=Anything()) 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())
def test_play_wav_exception(self, mock_log, mock_subprocess, mock_conf): """Test that stack trace is provided when unknown excpetion occurs""" def raise_exception(*arg, **kwarg): raise Exception mock_subprocess.Popen.side_effect = raise_exception mock_conf.get.return_value = test_config self.assertEqual(play_wav('indifference.wav'), None) mock_log.exception.called_once_with(Anything())
def test_play_wav_file_not_found(self, mock_log, mock_subprocess, mock_conf): """Test that simple log is raised when subprocess can't find command. """ def raise_filenotfound(*arg, **kwarg): raise FileNotFoundError('TEST FILE NOT FOUND') mock_subprocess.Popen.side_effect = raise_filenotfound mock_conf.get.return_value = test_config self.assertEqual(play_wav('indifference.wav'), None) mock_log.error.called_once_with(Anything())
def test_play_wav(self, mock_subprocess, mock_conf): mock_conf.get.return_value = test_config play_wav('indifference.wav') mock_subprocess.Popen.assert_called_once_with(['mock_wav', 'indifference.wav'], env=Anything())
def test_play_mp3(self, mock_subprocess, mock_conf): mock_conf.get.return_value = test_config play_mp3('praise.mp3') mock_subprocess.Popen.assert_called_once_with(['mock_mp3', 'praise.mp3'], env=Anything())
def test_play_ogg(self, mock_subprocess, mock_conf): mock_conf.get.return_value = test_config play_ogg('insult.ogg') mock_subprocess.Popen.assert_called_once_with(['mock_ogg', 'insult.ogg'], env=Anything())