Squashed commit of the following:

commit 99fd94580f95dcbfb77b73e2de846f76a5709ef9
Author: Sonny <sonnyba871@gmail.com>
Date:   Sat Feb 15 21:45:16 2020 +0100

    Use postgres password

    As of https://gitlab.com/gitlab-com/support-forum/issues/5199
This commit is contained in:
sonny 2020-07-12 20:26:14 +02:00
parent 391796a0c0
commit 177755e302
66 changed files with 8955 additions and 372 deletions

View file

@ -11,7 +11,7 @@ from newsreader.news.collection.exceptions import (
StreamTimeOutException,
)
from newsreader.news.collection.feed import FeedClient
from newsreader.news.collection.tests.factories import CollectionRuleFactory
from newsreader.news.collection.tests.factories import FeedFactory
from .mocks import simple_mock
@ -27,8 +27,9 @@ class FeedClientTestCase(TestCase):
patch.stopall()
def test_client_retrieves_single_rules(self):
rule = CollectionRuleFactory.create()
rule = FeedFactory.create()
mock_stream = MagicMock(rule=rule)
self.mocked_read.return_value = (simple_mock, mock_stream)
with FeedClient([rule]) as client:
@ -39,9 +40,10 @@ class FeedClientTestCase(TestCase):
self.mocked_read.assert_called_once_with()
def test_client_catches_stream_exception(self):
rule = CollectionRuleFactory.create()
rule = FeedFactory.create()
mock_stream = MagicMock(rule=rule)
self.mocked_read.side_effect = StreamException("Stream exception")
self.mocked_read.side_effect = StreamException(message="Stream exception")
with FeedClient([rule]) as client:
for data, stream in client:
@ -52,9 +54,12 @@ class FeedClientTestCase(TestCase):
self.mocked_read.assert_called_once_with()
def test_client_catches_stream_not_found_exception(self):
rule = CollectionRuleFactory.create()
rule = FeedFactory.create()
mock_stream = MagicMock(rule=rule)
self.mocked_read.side_effect = StreamNotFoundException("Stream not found")
self.mocked_read.side_effect = StreamNotFoundException(
message="Stream not found"
)
with FeedClient([rule]) as client:
for data, stream in client:
@ -65,9 +70,10 @@ class FeedClientTestCase(TestCase):
self.mocked_read.assert_called_once_with()
def test_client_catches_stream_denied_exception(self):
rule = CollectionRuleFactory.create()
rule = FeedFactory.create()
mock_stream = MagicMock(rule=rule)
self.mocked_read.side_effect = StreamDeniedException("Stream denied")
self.mocked_read.side_effect = StreamDeniedException(message="Stream denied")
with FeedClient([rule]) as client:
for data, stream in client:
@ -78,9 +84,12 @@ class FeedClientTestCase(TestCase):
self.mocked_read.assert_called_once_with()
def test_client_catches_stream_timed_out(self):
rule = CollectionRuleFactory.create()
rule = FeedFactory.create()
mock_stream = MagicMock(rule=rule)
self.mocked_read.side_effect = StreamTimeOutException("Stream timed out")
self.mocked_read.side_effect = StreamTimeOutException(
message="Stream timed out"
)
with FeedClient([rule]) as client:
for data, stream in client:
@ -91,22 +100,12 @@ class FeedClientTestCase(TestCase):
self.mocked_read.assert_called_once_with()
def test_client_catches_stream_parse_exception(self):
rule = CollectionRuleFactory.create()
rule = FeedFactory.create()
mock_stream = MagicMock(rule=rule)
self.mocked_read.side_effect = StreamParseException("Stream has wrong contents")
with FeedClient([rule]) as client:
for data, stream in client:
self.assertEquals(data, {"entries": []})
self.assertEquals(stream.rule.error, "Stream has wrong contents")
self.assertEquals(stream.rule.succeeded, False)
self.mocked_read.assert_called_once_with()
def test_client_catches_stream_parse_exception(self):
rule = CollectionRuleFactory.create()
mock_stream = MagicMock(rule=rule)
self.mocked_read.side_effect = StreamParseException("Stream has wrong contents")
self.mocked_read.side_effect = StreamParseException(
message="Stream has wrong contents"
)
with FeedClient([rule]) as client:
for data, stream in client:
@ -117,9 +116,10 @@ class FeedClientTestCase(TestCase):
self.mocked_read.assert_called_once_with()
def test_client_catches_long_exception_text(self):
rule = CollectionRuleFactory.create()
rule = FeedFactory.create()
mock_stream = MagicMock(rule=rule)
self.mocked_read.side_effect = StreamParseException(words(1000))
self.mocked_read.side_effect = StreamParseException(message=words(1000))
with FeedClient([rule]) as client:
for data, stream in client: