diff --git a/homeassistant/components/reddit/manifest.json b/homeassistant/components/reddit/manifest.json index 55baecc486c..8ab4b686da7 100644 --- a/homeassistant/components/reddit/manifest.json +++ b/homeassistant/components/reddit/manifest.json @@ -3,7 +3,7 @@ "name": "Reddit", "documentation": "https://www.home-assistant.io/integrations/reddit", "requirements": [ - "praw==6.3.1" + "praw==6.4.0" ], "dependencies": [], "codeowners": [] diff --git a/homeassistant/components/reddit/sensor.py b/homeassistant/components/reddit/sensor.py index f9c8140f60d..82f622b968e 100644 --- a/homeassistant/components/reddit/sensor.py +++ b/homeassistant/components/reddit/sensor.py @@ -2,6 +2,7 @@ from datetime import timedelta import logging +import praw import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA @@ -51,8 +52,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Reddit sensor platform.""" - import praw - subreddits = config[CONF_SUBREDDITS] user_agent = "{}_home_assistant_sensor".format(config[CONF_USERNAME]) limit = config[CONF_MAXIMUM] @@ -117,8 +116,6 @@ class RedditSensor(Entity): def update(self): """Update data from Reddit API.""" - import praw - self._subreddit_data = [] try: diff --git a/requirements_all.txt b/requirements_all.txt index d02d11d5f58..a4621d0e45f 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -990,7 +990,7 @@ pocketcasts==0.1 postnl_api==1.0.2 # homeassistant.components.reddit -praw==6.3.1 +praw==6.4.0 # homeassistant.components.islamic_prayer_times prayer_times_calculator==0.0.3 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index db5c1a491cb..69eaf2d2922 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -354,7 +354,7 @@ plexwebsocket==0.0.1 pmsensor==0.4 # homeassistant.components.reddit -praw==6.3.1 +praw==6.4.0 # homeassistant.components.islamic_prayer_times prayer_times_calculator==0.0.3 diff --git a/tests/components/reddit/test_sensor.py b/tests/components/reddit/test_sensor.py index 0a0247e2585..a421f6f417c 100644 --- a/tests/components/reddit/test_sensor.py +++ b/tests/components/reddit/test_sensor.py @@ -3,6 +3,7 @@ import copy import unittest from unittest.mock import patch +from homeassistant.components.reddit import sensor as reddit_sensor from homeassistant.components.reddit.sensor import ( DOMAIN, ATTR_SUBREDDIT, @@ -98,7 +99,7 @@ MOCK_RESULTS_LENGTH = len(MOCK_RESULTS["results"]) class MockPraw: - """Mock class for tmdbsimple library.""" + """Mock class for Reddit library.""" def __init__( self, @@ -112,7 +113,7 @@ class MockPraw: self._data = MOCK_RESULTS def subreddit(self, subreddit: str): - """Return an instance of a sunbreddit.""" + """Return an instance of a subreddit.""" return MockSubreddit(subreddit, self._data) @@ -160,8 +161,9 @@ class TestRedditSetup(unittest.TestCase): @MockDependency("praw") @patch("praw.Reddit", new=MockPraw) def test_setup_with_valid_config(self, mock_praw): - """Test the platform setup with movie configuration.""" - setup_component(self.hass, "sensor", VALID_CONFIG) + """Test the platform setup with Reddit configuration.""" + with patch.object(reddit_sensor, "praw", mock_praw): + setup_component(self.hass, "sensor", VALID_CONFIG) state = self.hass.states.get("sensor.reddit_worldnews") assert int(state.state) == MOCK_RESULTS_LENGTH @@ -186,6 +188,6 @@ class TestRedditSetup(unittest.TestCase): @MockDependency("praw") @patch("praw.Reddit", new=MockPraw) def test_setup_with_invalid_config(self, mock_praw): - """Test the platform setup with invalid movie configuration.""" + """Test the platform setup with invalid Reddit configuration.""" setup_component(self.hass, "sensor", INVALID_SORT_BY_CONFIG) assert not self.hass.states.get("sensor.reddit_worldnews")