Example #1
0
def test_parse_uri_album_invalid():
    with pytest.raises(ValueError) as err_inf:
        parse_uri("kitchen:album:INVALID")

    assert str(
        err_inf.value
    ) == "Invalid kitchen URI 'kitchen:album:INVALID': Invalid ID 'INVALID'"
Example #2
0
def test_parse_uri_album_track_invalid():
    with pytest.raises(ValueError) as err_inf:
        parse_uri("kitchen:album:123456789012345678901234567890ab:1:a")

    assert (
        str(err_inf.value) ==
        "Invalid kitchen URI 'kitchen:album:123456789012345678901234567890ab:1:a': Invalid number 'a'"
    )
Example #3
0
def test_parse_uri_station_stream():
    result = parse_uri("kitchen:station:123456789012345678901234567890ab:1")

    assert type(result) == StationStreamUri
    assert str(result) == "kitchen:station:123456789012345678901234567890ab:1"
    assert result.station_id == "123456789012345678901234567890ab"
    assert result.stream_no == 1
Example #4
0
def test_parse_uri_album_track():
    result = parse_uri("kitchen:album:123456789012345678901234567890ab:1:2")

    assert type(result) == AlbumTrackUri
    assert str(result) == "kitchen:album:123456789012345678901234567890ab:1:2"
    assert result.album_id == "123456789012345678901234567890ab"
    assert result.disc_no == 1
    assert result.track_no == 2
Example #5
0
def test_get_images_for_track_with_image(tmp_path, caplog):
    make_album(tmp_path / "media" / "a1", EXAMPLE_ALBUM)
    make_image(tmp_path / "media" / "a1" / "cover.jpg")
    provider = KitchenLibraryProvider(backend={}, config=make_config(tmp_path))
    track_uri = provider.browse(str(AlbumsUri()))[0].uri + ":1:1"
    album_id = parse_uri(track_uri).album_id

    result = provider.get_images([track_uri])

    assert caplog.text == ""
    assert result == {
        track_uri: [Image(uri=f"/kitchen/albums/{album_id}/cover.jpg")]
    }
Example #6
0
def test_parse_uri_search():
    result = parse_uri("kitchen:search")

    assert type(result) == SearchUri
    assert str(result) == "kitchen:search"
Example #7
0
def test_parse_uri_album():
    result = parse_uri("kitchen:album:123456789012345678901234567890ab")

    assert type(result) == AlbumUri
    assert str(result) == "kitchen:album:123456789012345678901234567890ab"
    assert result.album_id == "123456789012345678901234567890ab"
Example #8
0
def test_parse_uri_stations():
    result = parse_uri("kitchen:stations")

    assert type(result) == StationsUri
    assert str(result) == "kitchen:stations"
Example #9
0
def test_parse_uri_albums():
    result = parse_uri("kitchen:albums")

    assert type(result) == AlbumsUri
    assert str(result) == "kitchen:albums"
Example #10
0
def test_parse_uri_root():
    result = parse_uri("kitchen:root")

    assert result == ROOT_URI
    assert str(result) == "kitchen:root"
Example #11
0
def test_parse_uri_none():
    result = parse_uri("foo")

    assert result is None