def test_base_path_with_optional_uri_should_do_nothing(): media = Media(type='AUDIO', group_id='audio-group', name='English') assert media.uri is None assert media.base_uri is None media.base_path = "base_path" assert media.absolute_uri is None assert media.base_path is None
def test_invalid_values_for_boolean_fields_raises_errors(): media = Media(type='VIDEO', group_id='abc', name='Spanish doubled') with pytest.raises(InvalidMedia): media.default = '' with pytest.raises(InvalidMedia): media.forced = 'y' with pytest.raises(InvalidMedia): media.autoselect = 'n'
def test_medialist_uri_method(): langs = ['English', 'French', 'German'] ml = MediaList() for lang in langs: ml.append(Media(type='AUDIO', group_id='audio-group', name=lang, uri=('/%s.m3u8' % lang))) assert len(ml.uri) == len(langs) assert ml.uri[0] == '/%s.m3u8' % langs[0] assert ml.uri[1] == '/%s.m3u8' % langs[1] assert ml.uri[2] == '/%s.m3u8' % langs[2]
def test_valid_values_for_type_in_direct_assignment(): valid_values = ('AUDIO', 'VIDEO', 'SUBTITLES', 'CLOSED-CAPTIONS') media = Media(type='VIDEO', group_id='abc', name='Spanish doubled') for value in valid_values: media.type = value assert media.type == value
def test_invalid_value_for_type_raises_error(): media = Media(group_id='abc', type='AUDIO', name='Spanish doubled') with pytest.raises(InvalidMedia): media.type = 'NONEXISTENT'
def test_empty_value_for_name_raises_error(): media = Media(group_id='abc', type='AUDIO', name='Spanish doubled') with pytest.raises(InvalidMedia): media.name = None