Skip to content

Commit

Permalink
Add test for async_browse
Browse files Browse the repository at this point in the history
  • Loading branch information
rajlaud committed Sep 26, 2020
1 parent 69fd604 commit 4d2c126
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import pytest
from pysqueezebox import Player, Server, async_discover

BROWSE_LIMIT = 50

# pylint: disable=C0103
# All test coroutines will be treated as marked.
pytestmark = pytest.mark.asyncio
Expand Down Expand Up @@ -219,6 +221,32 @@ async def test_get_player(lms, player):
assert player.player_id == test_player_c.player_id


async def test_browse(lms):
"""Test browsing the library."""
categories = [
("playlists", "playlist_id"),
("artists", "artist_id"),
("genres", "genre_id"),
("albums", "album_id"),
]

for category in categories:
await lookup_helper(lms, category[0], category[1])


async def lookup_helper(lms, category, id_type):
"""Lookup a known item and make sure the name matches."""
result = await lms.async_browse(category, limit=BROWSE_LIMIT)
assert result["title"] is not None
assert len(result["items"]) > 0
browse_id = result["items"][0].get("id")
title = result["items"][0].get("title")
result = await lms.async_browse(
category[:-1], limit=BROWSE_LIMIT, browse_id=(id_type, browse_id)
)
assert result["title"] == title


def print_properties(player):
"""Print all properties of player."""
for p in dir(Player):
Expand Down

0 comments on commit 4d2c126

Please sign in to comment.