def test_probe(self): processor = FileProcessor('input.mkv', 'output.mkv', 'roku') # Check correct command construction with patch('ffconv.file_processor.execute_cmd') as ecmd: ecmd.return_value = '{"streams": []}' self.assertFalse(ecmd.called) processor.probe() cmd = ['ffprobe', '-v', 'quiet', '-show_streams', '-of', 'json', 'input.mkv'] ecmd.assert_called_once_with(cmd) # Check correct result parsing with patch('subprocess.Popen.__enter__') as ctx_mgr: # Mock the process's stdout.readline and poll methods res = [b'{"streams": [', b'{"codec_type": "video", "codec_name": "h264", "index": 0},', b'{"codec_type": "AUDIO", "codec_name": "MP3", "index": 1, "tags": {"LANGUAGE": "POR"}}', b']}', b''] ctx_mgr.return_value = MagicMock(stdout=MagicMock(readline=MagicMock(side_effect=res)), poll=MagicMock(return_value=0)) # Run probe, make sure it returns the correct result res = processor.probe() self.assertEqual(res, [{"codec_type": "video", "codec_name": "h264", "index": 0}, {"codec_type": "audio", "codec_name": "mp3", "index": 1, "tags": {"language": "por"}}])