From 0656407561dd93a5d90749f9a1b8379a1c2ddacb Mon Sep 17 00:00:00 2001 From: Malachi Soord Date: Thu, 16 Sep 2021 07:00:25 +0200 Subject: [PATCH] Upgrade pylast from 4.2.0 to 4.2.1 (#56015) * Upgrade pylast from 4.2.0 to 4.2.1 * Fix test * Use MockNetwork * Tidy * Fix lint --- homeassistant/components/lastfm/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/lastfm/test_sensor.py | 12 ++++++++++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/lastfm/manifest.json b/homeassistant/components/lastfm/manifest.json index 9b4b0e5cdfc..f850b39a620 100644 --- a/homeassistant/components/lastfm/manifest.json +++ b/homeassistant/components/lastfm/manifest.json @@ -2,7 +2,7 @@ "domain": "lastfm", "name": "Last.fm", "documentation": "https://www.home-assistant.io/integrations/lastfm", - "requirements": ["pylast==4.2.0"], + "requirements": ["pylast==4.2.1"], "codeowners": [], "iot_class": "cloud_polling" } diff --git a/requirements_all.txt b/requirements_all.txt index 1a75da74585..f65f5dc9734 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1575,7 +1575,7 @@ pykwb==0.0.8 pylacrosse==0.4 # homeassistant.components.lastfm -pylast==4.2.0 +pylast==4.2.1 # homeassistant.components.launch_library pylaunches==1.0.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index bbaf253e270..e5f8275c01e 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -912,7 +912,7 @@ pykrakenapi==0.1.8 pykulersky==0.5.2 # homeassistant.components.lastfm -pylast==4.2.0 +pylast==4.2.1 # homeassistant.components.forked_daapd pylibrespot-java==0.1.0 diff --git a/tests/components/lastfm/test_sensor.py b/tests/components/lastfm/test_sensor.py index af7a177edb8..cbb37f94dc4 100644 --- a/tests/components/lastfm/test_sensor.py +++ b/tests/components/lastfm/test_sensor.py @@ -9,8 +9,16 @@ from homeassistant.components.lastfm.sensor import STATE_NOT_SCROBBLING from homeassistant.setup import async_setup_component +class MockNetwork: + """Mock _Network object for pylast.""" + + def __init__(self, username: str): + """Initialize the mock.""" + self.username = username + + class MockUser: - """Mock user object for pylast.""" + """Mock User object for pylast.""" def __init__(self, now_playing_result): """Initialize the mock.""" @@ -67,7 +75,7 @@ async def test_update_playing(hass, lastfm_network): """Test update when song playing.""" lastfm_network.return_value.get_user.return_value = MockUser( - Track("artist", "title", None) + Track("artist", "title", MockNetwork("test")) ) assert await async_setup_component(