def test_embed_mkv(mocker): mocked_popen = mocker.patch('subprocess.Popen') mocked_popen.return_value = popen = MagicMock() popen.communicate.return_value = ('', '') popen.poll.return_value = 0 subtitles = [('eng', u'foo.eng.srt'), ('pob', u'foo.pob.srt')] mocked_convert = mocker.patch('ss.convert_language_code_to_iso639_2', side_effect=['eng', 'por', 'eng']) assert ss.embed_mkv(u'foo.avi', subtitles) == (True, '') mocked_convert.assert_has_calls([call('eng'), call('pob')]) params = (u'mkvmerge --output foo.mkv foo.avi ' u'--language 0:eng foo.eng.srt ' u'--language 0:por foo.pob.srt').split() mocked_popen.assert_called_once_with(params, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) popen.communicate.assert_called_once() popen.poll.assert_called_once() popen.communicate.return_value = ('failed error', '') popen.poll.return_value = 2 result = ss.embed_mkv(u'foo.avi', [('eng', u'foo.srt')]) assert result == (False, 'failed error')
def test_embed_mkv(mocker): mocked_popen = mocker.patch('subprocess.Popen') mocked_popen.return_value = popen = MagicMock() popen.communicate.return_value = ('', '') popen.poll.return_value = 0 subtitles = [('eng', u'foo.eng.srt'), ('pob', u'foo.pob.srt')] mocked_convert = mocker.patch('ss.convert_language_code_to_iso639_2', side_effect=['eng', 'por', 'eng']) assert ss.embed_mkv(u'foo.avi', subtitles) == (True, '') mocked_convert.assert_has_calls([call('eng'), call('pob')]) params = (u'mkvmerge --output foo.mkv foo.avi ' u'--language 0:eng foo.eng.srt ' u'--language 0:por foo.pob.srt').split() mocked_popen.assert_called_once_with(params, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) popen.communicate.assert_called_once_with() popen.poll.assert_called_once_with() popen.communicate.return_value = ('failed error', '') popen.poll.return_value = 2 result = ss.embed_mkv(u'foo.avi', [('eng', u'foo.srt')]) assert result == (False, 'failed error')
def test_embed_mkv(): with patch('subprocess.Popen') as mocked_popen: mocked_popen.return_value = popen = MagicMock() popen.communicate.return_value = ('', '') popen.poll.return_value = 0 assert ss.embed_mkv(u'foo.avi', u'foo.srt', 'eng') == (True, '') params = u'mkvmerge --output foo.mkv foo.avi --language 0:eng foo.srt'.split() mocked_popen.assert_called_once_with(params, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) popen.communicate.assert_called_once() popen.poll.assert_called_once() popen.communicate.return_value = ('failed error', '') popen.poll.return_value = 2 assert ss.embed_mkv(u'foo.avi', u'foo.srt', 'eng') == (False, 'failed error')
def test_embed_mkv(mocker): mocked_popen = mocker.patch("subprocess.Popen") mocked_popen.return_value = popen = MagicMock() popen.communicate.return_value = ("", "") popen.poll.return_value = 0 subtitles = [("eng", u"foo.eng.srt"), ("pob", u"foo.pob.srt")] mocked_convert = mocker.patch("ss.convert_language_code_to_iso639_2", side_effect=["eng", "por", "eng"]) assert ss.embed_mkv(u"foo.avi", subtitles) == (True, "") mocked_convert.assert_has_calls([call("eng"), call("pob")]) params = ( u"mkvmerge --output foo.mkv foo.avi " u"--language 0:eng foo.eng.srt " u"--language 0:por foo.pob.srt" ).split() mocked_popen.assert_called_once_with(params, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) popen.communicate.assert_called_once_with() popen.poll.assert_called_once_with() popen.communicate.return_value = ("failed error", "") popen.poll.return_value = 2 result = ss.embed_mkv(u"foo.avi", [("eng", u"foo.srt")]) assert result == (False, "failed error")