Update praw to 6.4.0 (#27324)

* Update praw to 6.4.0

* Update requirements_test_all.txt

* Fix docstrings

* Update tests
This commit is contained in:
Fabian Affolter 2019-10-27 10:04:43 +01:00 committed by GitHub
parent 2747f08385
commit 7e862e4d92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 12 deletions

View File

@ -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": []

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -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,7 +161,8 @@ 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."""
"""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")
@ -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")