Skip to content

Commit

Permalink
add test scenario for the #893
Browse files Browse the repository at this point in the history
  • Loading branch information
plodri committed Jul 24, 2024
1 parent 9185fbf commit 6bd2129
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/test_playutils_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,42 @@ def mock_play_utils():
yield mock_instance


def test_hevc_transcoding_scenario(mock_play_utils):
with patch('jellyfin_kodi.helper.playutils.settings') as mock_settings:
# Scenario 1: Force Transcode enabled, Transcode HEVC disabled
mock_settings.side_effect = [
True, # transcode_h265 = True (Transcode HEVC disabled)
"", # videoPreferredCodec = "" (no preference)
False, # transcode_mpeg2 = False
False # transcode_vc1 = False
]
mock_play_utils.get_transcoding_video_codec.return_value = "h264,mpeg4,mpeg2video,vc1"
result_1 = mock_play_utils.get_transcoding_video_codec()

# Scenario 2: Force Transcode enabled, Transcode HEVC enabled
mock_settings.side_effect = [
False, # transcode_h265 = False (Transcode HEVC enabled)
"", # videoPreferredCodec = "" (no preference)
False, # transcode_mpeg2 = False
False # transcode_vc1 = False
]
mock_play_utils.get_transcoding_video_codec.return_value = "h264,mpeg4,mpeg2video,vc1,hevc"
result_2 = mock_play_utils.get_transcoding_video_codec()

# Assertions
assert "hevc" not in result_1, "HEVC should not be in codec list when Transcode HEVC is disabled"
assert "hevc" in result_2, "HEVC should be in codec list when Transcode HEVC is enabled"

# Ensure other codecs are present in both scenarios
for codec in ["h264", "mpeg4", "mpeg2video", "vc1"]:
assert codec in result_1, f"{codec} should be in codec list regardless of HEVC setting"
assert codec in result_2, f"{codec} should be in codec list regardless of HEVC setting"

# Ensure the order is correct in both scenarios
assert result_1 == "h264,mpeg4,mpeg2video,vc1", "Codec order incorrect when HEVC is disabled"
assert result_2 == "h264,mpeg4,mpeg2video,vc1,hevc", "Codec order incorrect when HEVC is enabled"


@pytest.mark.parametrize("transcode_h265, preferred_codec, expected_result", [
(False, "", "h264,mpeg4,mpeg2video,vc1,hevc"),
(True, "", "h264,mpeg4,mpeg2video,vc1"),
Expand Down

0 comments on commit 6bd2129

Please sign in to comment.