mirror of
https://github.com/caronc/apprise.git
synced 2025-02-16 10:19:50 +01:00
Tests: Use no_throttling
fixture everywhere
This commit is contained in:
parent
85daf12fbd
commit
c797d1e2eb
@ -24,4 +24,25 @@
|
||||
# THE SOFTWARE.
|
||||
import sys
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
from apprise import NotifyBase
|
||||
from apprise.plugins.NotifyPushBullet import NotifyPushBullet
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), 'helpers'))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def no_throttling():
|
||||
"""
|
||||
A pytest fixture which disables Apprise throttling.
|
||||
"""
|
||||
backup = {}
|
||||
backup["NotifyBase"] = NotifyBase.request_rate_per_sec
|
||||
backup["NotifyPushBullet"] = NotifyPushBullet.request_rate_per_sec
|
||||
NotifyBase.request_rate_per_sec = 0
|
||||
NotifyPushBullet.request_rate_per_sec = 0
|
||||
yield
|
||||
NotifyBase.request_rate_per_sec = backup["NotifyBase"]
|
||||
NotifyPushBullet.request_rate_per_sec = backup["NotifyPushBullet"]
|
||||
|
@ -119,13 +119,11 @@ def test_plugin_boxcar_urls():
|
||||
|
||||
@mock.patch('requests.get')
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_boxcar_edge_cases(mock_post, mock_get):
|
||||
def test_plugin_boxcar_edge_cases(mock_post, mock_get, no_throttling):
|
||||
"""
|
||||
NotifyBoxcar() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Generate some generic message types
|
||||
device = 'A' * 64
|
||||
|
@ -132,13 +132,11 @@ def test_plugin_bulksms_urls():
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_bulksms_edge_cases(mock_post):
|
||||
def test_plugin_bulksms_edge_cases(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyBulkSMS() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Initialize some generic (but valid) tokens
|
||||
user = 'abcd'
|
||||
|
@ -152,13 +152,11 @@ def test_plugin_custom_form_urls():
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_custom_form_attachments(mock_post):
|
||||
def test_plugin_custom_form_attachments(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyForm() Attachments
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
okay_response = requests.Request()
|
||||
okay_response.status_code = requests.codes.ok
|
||||
@ -226,13 +224,11 @@ def test_plugin_custom_form_attachments(mock_post):
|
||||
|
||||
@mock.patch('requests.post')
|
||||
@mock.patch('requests.get')
|
||||
def test_plugin_custom_form_edge_cases(mock_get, mock_post):
|
||||
def test_plugin_custom_form_edge_cases(mock_get, mock_post, no_throttling):
|
||||
"""
|
||||
NotifyForm() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare our response
|
||||
response = requests.Request()
|
||||
|
@ -150,13 +150,11 @@ def test_plugin_custom_json_urls():
|
||||
|
||||
@mock.patch('requests.post')
|
||||
@mock.patch('requests.get')
|
||||
def test_plugin_custom_json_edge_cases(mock_get, mock_post):
|
||||
def test_plugin_custom_json_edge_cases(mock_get, mock_post, no_throttling):
|
||||
"""
|
||||
NotifyJSON() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare our response
|
||||
response = requests.Request()
|
||||
|
@ -165,13 +165,11 @@ def test_plugin_custom_xml_urls():
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_notify_xml_plugin_attachments(mock_post):
|
||||
def test_notify_xml_plugin_attachments(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyXML() Attachments
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
okay_response = requests.Request()
|
||||
okay_response.status_code = requests.codes.ok
|
||||
@ -227,13 +225,11 @@ def test_notify_xml_plugin_attachments(mock_post):
|
||||
|
||||
@mock.patch('requests.post')
|
||||
@mock.patch('requests.get')
|
||||
def test_plugin_custom_xml_edge_cases(mock_get, mock_post):
|
||||
def test_plugin_custom_xml_edge_cases(mock_get, mock_post, no_throttling):
|
||||
"""
|
||||
NotifyXML() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare our response
|
||||
response = requests.Request()
|
||||
|
@ -168,13 +168,11 @@ def test_plugin_discord_urls():
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_discord_general(mock_post):
|
||||
def test_plugin_discord_general(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyDiscord() General Checks
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Initialize some generic (but valid) tokens
|
||||
webhook_id = 'A' * 24
|
||||
@ -364,13 +362,11 @@ def test_plugin_discord_general(mock_post):
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_discord_attachments(mock_post):
|
||||
def test_plugin_discord_attachments(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyDiscord() Attachment Checks
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Initialize some generic (but valid) tokens
|
||||
webhook_id = 'C' * 24
|
||||
|
@ -248,13 +248,11 @@ TEST_URLS = (
|
||||
|
||||
@mock.patch('smtplib.SMTP')
|
||||
@mock.patch('smtplib.SMTP_SSL')
|
||||
def test_plugin_email(mock_smtp, mock_smtpssl):
|
||||
def test_plugin_email(mock_smtp, mock_smtpssl, no_throttling):
|
||||
"""
|
||||
NotifyEmail() General Checks
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# iterate over our dictionary and test it out
|
||||
for (url, meta) in TEST_URLS:
|
||||
@ -450,13 +448,11 @@ def test_plugin_email_webbase_lookup(mock_smtp, mock_smtpssl):
|
||||
|
||||
|
||||
@mock.patch('smtplib.SMTP')
|
||||
def test_plugin_email_smtplib_init_fail(mock_smtplib):
|
||||
def test_plugin_email_smtplib_init_fail(mock_smtplib, no_throttling):
|
||||
"""
|
||||
NotifyEmail() Test exception handling when calling smtplib.SMTP()
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
obj = Apprise.instantiate(
|
||||
'mailto://user:pass@gmail.com', suppress_exceptions=False)
|
||||
@ -475,13 +471,11 @@ def test_plugin_email_smtplib_init_fail(mock_smtplib):
|
||||
|
||||
|
||||
@mock.patch('smtplib.SMTP')
|
||||
def test_plugin_email_smtplib_send_okay(mock_smtplib):
|
||||
def test_plugin_email_smtplib_send_okay(mock_smtplib, no_throttling):
|
||||
"""
|
||||
NotifyEmail() Test a successfully sent email
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Defaults to HTML
|
||||
obj = Apprise.instantiate(
|
||||
@ -543,13 +537,11 @@ def test_plugin_email_smtplib_send_okay(mock_smtplib):
|
||||
|
||||
|
||||
@mock.patch('smtplib.SMTP')
|
||||
def test_plugin_email_smtplib_internationalization(mock_smtp):
|
||||
def test_plugin_email_smtplib_internationalization(mock_smtp, no_throttling):
|
||||
"""
|
||||
NotifyEmail() Internationalization Handling
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Defaults to HTML
|
||||
obj = Apprise.instantiate(
|
||||
@ -741,15 +733,12 @@ def test_plugin_email_dict_variations():
|
||||
|
||||
@mock.patch('smtplib.SMTP_SSL')
|
||||
@mock.patch('smtplib.SMTP')
|
||||
def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl):
|
||||
def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl, no_throttling):
|
||||
"""
|
||||
NotifyEmail() Test email url parsing
|
||||
|
||||
"""
|
||||
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyEmail.request_rate_per_sec = 0
|
||||
|
||||
response = mock.Mock()
|
||||
mock_smtp_ssl.return_value = response
|
||||
mock_smtp.return_value = response
|
||||
|
@ -26,7 +26,6 @@ from unittest import mock
|
||||
|
||||
from json import dumps
|
||||
from apprise import Apprise
|
||||
from apprise import plugins
|
||||
import requests
|
||||
from helpers import AppriseURLTester
|
||||
|
||||
@ -87,13 +86,11 @@ def test_plugin_template_urls():
|
||||
@mock.patch('requests.get')
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_emby_general(mock_post, mock_get, mock_logout,
|
||||
mock_login, mock_sessions):
|
||||
mock_login, mock_sessions, no_throttling):
|
||||
"""
|
||||
NotifyEmby General Tests
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
req = requests.Request()
|
||||
req.status_code = requests.codes.ok
|
||||
@ -163,13 +160,11 @@ def test_plugin_emby_general(mock_post, mock_get, mock_logout,
|
||||
|
||||
@mock.patch('requests.get')
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_emby_login(mock_post, mock_get):
|
||||
def test_plugin_emby_login(mock_post, mock_get, no_throttling):
|
||||
"""
|
||||
NotifyEmby() login()
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare Mock
|
||||
mock_get.return_value = requests.Request()
|
||||
@ -279,13 +274,12 @@ def test_plugin_emby_login(mock_post, mock_get):
|
||||
@mock.patch('apprise.plugins.NotifyEmby.logout')
|
||||
@mock.patch('requests.get')
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_emby_sessions(mock_post, mock_get, mock_logout, mock_login):
|
||||
def test_plugin_emby_sessions(mock_post, mock_get, mock_logout, mock_login,
|
||||
no_throttling):
|
||||
"""
|
||||
NotifyEmby() sessions()
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare Mock
|
||||
mock_get.return_value = requests.Request()
|
||||
@ -376,13 +370,11 @@ def test_plugin_emby_sessions(mock_post, mock_get, mock_logout, mock_login):
|
||||
@mock.patch('apprise.plugins.NotifyEmby.login')
|
||||
@mock.patch('requests.get')
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_emby_logout(mock_post, mock_get, mock_login):
|
||||
def test_plugin_emby_logout(mock_post, mock_get, mock_login, no_throttling):
|
||||
"""
|
||||
NotifyEmby() logout()
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare Mock
|
||||
mock_get.return_value = requests.Request()
|
||||
|
@ -207,13 +207,11 @@ def test_plugin_fcm_urls():
|
||||
@pytest.mark.skipif(
|
||||
hasattr(sys, "pypy_version_info"), reason="Does not work reliably on PyPy")
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_fcm_general_legacy(mock_post):
|
||||
def test_plugin_fcm_general_legacy(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyFCM() General Legacy/APIKey Checks
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare a good response
|
||||
response = mock.Mock()
|
||||
@ -334,7 +332,7 @@ def test_plugin_fcm_general_legacy(mock_post):
|
||||
@pytest.mark.skipif(
|
||||
'cryptography' not in sys.modules, reason="Requires cryptography")
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_fcm_general_oauth(mock_post):
|
||||
def test_plugin_fcm_general_oauth(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyFCM() General OAuth Checks
|
||||
|
||||
@ -343,9 +341,6 @@ def test_plugin_fcm_general_oauth(mock_post):
|
||||
# Valid Keyfile
|
||||
path = os.path.join(PRIVATE_KEYFILE_DIR, 'service_account.json')
|
||||
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare a good response
|
||||
response = mock.Mock()
|
||||
response.content = json.dumps({
|
||||
@ -853,13 +848,11 @@ def test_plugin_fcm_cryptography_import_error():
|
||||
@pytest.mark.skipif(
|
||||
'cryptography' not in sys.modules, reason="Requires cryptography")
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_fcm_edge_cases(mock_post):
|
||||
def test_plugin_fcm_edge_cases(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyFCM() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare a good response
|
||||
response = mock.Mock()
|
||||
|
@ -163,13 +163,11 @@ def test_plugin_flock_urls():
|
||||
|
||||
@mock.patch('requests.get')
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_flock_edge_cases(mock_post, mock_get):
|
||||
def test_plugin_flock_edge_cases(mock_post, mock_get, no_throttling):
|
||||
"""
|
||||
NotifyFlock() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Initializes the plugin with an invalid token
|
||||
with pytest.raises(TypeError):
|
||||
|
@ -114,13 +114,11 @@ def test_plugin_gitter_urls():
|
||||
|
||||
@mock.patch('requests.get')
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_gitter_general(mock_post, mock_get):
|
||||
def test_plugin_gitter_general(mock_post, mock_get, no_throttling):
|
||||
"""
|
||||
NotifyGitter() General Tests
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Generate a valid token (40 characters)
|
||||
token = 'a' * 40
|
||||
|
@ -323,7 +323,7 @@ def test_plugin_growl_general(mock_gntp):
|
||||
@pytest.mark.skipif(
|
||||
'gntp' not in sys.modules, reason="Requires gntp")
|
||||
@mock.patch('gntp.notifier.GrowlNotifier')
|
||||
def test_plugin_growl_config_files(mock_gntp):
|
||||
def test_plugin_growl_config_files(mock_gntp, no_throttling):
|
||||
"""
|
||||
NotifyGrowl() Config File Cases
|
||||
"""
|
||||
@ -350,9 +350,6 @@ def test_plugin_growl_config_files(mock_gntp):
|
||||
tag: growl_str emerg
|
||||
"""
|
||||
|
||||
# Disable Throttling to speed testing
|
||||
apprise.plugins.NotifyGrowl.request_rate_per_sec = 0
|
||||
|
||||
mock_notifier = mock.Mock()
|
||||
mock_gntp.return_value = mock_notifier
|
||||
mock_notifier.notify.return_value = True
|
||||
|
@ -145,13 +145,11 @@ def test_plugin_guilded_urls():
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_guilded_general(mock_post):
|
||||
def test_plugin_guilded_general(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyGuilded() General Checks
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Initialize some generic (but valid) tokens
|
||||
webhook_id = 'A' * 24
|
||||
|
@ -124,13 +124,11 @@ def test_plugin_homeassistant_urls():
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_homeassistant_general(mock_post):
|
||||
def test_plugin_homeassistant_general(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyHomeAssistant() General Checks
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
response = mock.Mock()
|
||||
response.content = ''
|
||||
|
@ -111,13 +111,11 @@ def test_plugin_ifttt_urls():
|
||||
|
||||
@mock.patch('requests.get')
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_ifttt_edge_cases(mock_post, mock_get):
|
||||
def test_plugin_ifttt_edge_cases(mock_post, mock_get, no_throttling):
|
||||
"""
|
||||
NotifyIFTTT() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Initialize some generic (but valid) tokens
|
||||
webhook_id = 'webhook_id'
|
||||
@ -135,9 +133,6 @@ def test_plugin_ifttt_edge_cases(mock_post, mock_get):
|
||||
with pytest.raises(TypeError):
|
||||
plugins.NotifyIFTTT(webhook_id=None, events=None)
|
||||
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Initializes the plugin with an invalid webhook id
|
||||
with pytest.raises(TypeError):
|
||||
plugins.NotifyIFTTT(webhook_id=None, events=events)
|
||||
|
@ -129,13 +129,11 @@ def test_plugin_join_urls():
|
||||
|
||||
@mock.patch('requests.get')
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_join_edge_cases(mock_post, mock_get):
|
||||
def test_plugin_join_edge_cases(mock_post, mock_get, no_throttling):
|
||||
"""
|
||||
NotifyJoin() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Generate some generic message types
|
||||
device = 'A' * 32
|
||||
@ -172,7 +170,7 @@ def test_plugin_join_edge_cases(mock_post, mock_get):
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_join_config_files(mock_post):
|
||||
def test_plugin_join_config_files(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyJoin() Config File Cases
|
||||
"""
|
||||
@ -199,9 +197,6 @@ def test_plugin_join_config_files(mock_post):
|
||||
tag: join_str emerg
|
||||
""" % ('a' * 32, 'b' * 32, 'c' * 32, 'd' * 32)
|
||||
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyJoin.request_rate_per_sec = 0
|
||||
|
||||
# Prepare Mock
|
||||
mock_post.return_value = requests.Request()
|
||||
mock_post.return_value.status_code = requests.codes.ok
|
||||
|
@ -95,13 +95,11 @@ def test_plugin_kumulos_urls():
|
||||
AppriseURLTester(tests=apprise_url_tests).run_all()
|
||||
|
||||
|
||||
def test_plugin_kumulos_edge_cases():
|
||||
def test_plugin_kumulos_edge_cases(no_throttling):
|
||||
"""
|
||||
NotifyKumulos() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Invalid API Key
|
||||
with pytest.raises(TypeError):
|
||||
|
@ -176,13 +176,11 @@ def test_plugin_mailgun_urls():
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_mailgun_attachments(mock_post):
|
||||
def test_plugin_mailgun_attachments(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyMailgun() Attachments
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
okay_response = requests.Request()
|
||||
okay_response.status_code = requests.codes.ok
|
||||
|
@ -196,13 +196,11 @@ def test_plugin_matrix_urls():
|
||||
|
||||
@mock.patch('requests.get')
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_matrix_general(mock_post, mock_get):
|
||||
def test_plugin_matrix_general(mock_post, mock_get, no_throttling):
|
||||
"""
|
||||
NotifyMatrix() General Tests
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
response_obj = {
|
||||
'room_id': '!abc123:localhost',
|
||||
@ -353,13 +351,11 @@ def test_plugin_matrix_general(mock_post, mock_get):
|
||||
|
||||
@mock.patch('requests.get')
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_matrix_fetch(mock_post, mock_get):
|
||||
def test_plugin_matrix_fetch(mock_post, mock_get, no_throttling):
|
||||
"""
|
||||
NotifyMatrix() Server Fetch/API Tests
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
response_obj = {
|
||||
'room_id': '!abc123:localhost',
|
||||
@ -406,9 +402,6 @@ def test_plugin_matrix_fetch(mock_post, mock_get):
|
||||
# We would hve failed to send our notification
|
||||
assert obj.send(user='test', password='passwd', body="test") is False
|
||||
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
response_obj = {
|
||||
# Registration
|
||||
'access_token': 'abcd1234',
|
||||
@ -460,13 +453,11 @@ def test_plugin_matrix_fetch(mock_post, mock_get):
|
||||
|
||||
@mock.patch('requests.get')
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_matrix_auth(mock_post, mock_get):
|
||||
def test_plugin_matrix_auth(mock_post, mock_get, no_throttling):
|
||||
"""
|
||||
NotifyMatrix() Server Authentication
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
response_obj = {
|
||||
# Registration
|
||||
@ -556,13 +547,11 @@ def test_plugin_matrix_auth(mock_post, mock_get):
|
||||
|
||||
@mock.patch('requests.get')
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_matrix_rooms(mock_post, mock_get):
|
||||
def test_plugin_matrix_rooms(mock_post, mock_get, no_throttling):
|
||||
"""
|
||||
NotifyMatrix() Room Testing
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
response_obj = {
|
||||
# Registration
|
||||
|
@ -122,13 +122,11 @@ def test_plugin_mattermost_urls():
|
||||
AppriseURLTester(tests=apprise_url_tests).run_all()
|
||||
|
||||
|
||||
def test_plugin_mattermost_edge_cases():
|
||||
def test_plugin_mattermost_edge_cases(no_throttling):
|
||||
"""
|
||||
NotifyMattermost() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Invalid Authorization Token
|
||||
with pytest.raises(TypeError):
|
||||
|
@ -103,13 +103,11 @@ def test_plugin_messagebird_urls():
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_messagebird_edge_cases(mock_post):
|
||||
def test_plugin_messagebird_edge_cases(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyMessageBird() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare our response
|
||||
response = requests.Request()
|
||||
|
@ -54,13 +54,11 @@ def test_plugin_mqtt_paho_import_error(mock_post):
|
||||
@pytest.mark.skipif(
|
||||
'paho' not in sys.modules, reason="Requires paho-mqtt")
|
||||
@mock.patch('paho.mqtt.client.Client')
|
||||
def test_plugin_mqtt_general(mock_client):
|
||||
def test_plugin_mqtt_general(mock_client, no_throttling):
|
||||
"""
|
||||
NotifyMQTT() General Checks
|
||||
|
||||
"""
|
||||
# Speed up request rate for testing
|
||||
apprise.plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# our call to publish() response object
|
||||
publish_result = mock.Mock()
|
||||
|
@ -126,13 +126,11 @@ def test_plugin_msg91_urls():
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_msg91_edge_cases(mock_post):
|
||||
def test_plugin_msg91_edge_cases(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyMSG91() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare our response
|
||||
response = requests.Request()
|
||||
|
@ -176,13 +176,11 @@ def test_plugin_msteams_urls():
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_msteams_templating(mock_post, tmpdir):
|
||||
def test_plugin_msteams_templating(mock_post, tmpdir, no_throttling):
|
||||
"""
|
||||
NotifyMSTeams() Templating
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare Mock
|
||||
mock_post.return_value = requests.Request()
|
||||
@ -387,15 +385,12 @@ def test_plugin_msteams_templating(mock_post, tmpdir):
|
||||
@pytest.mark.skipif(
|
||||
hasattr(sys, "pypy_version_info"), reason="Does not work reliably on PyPy")
|
||||
@mock.patch('requests.post')
|
||||
def test_msteams_yaml_config(mock_post, tmpdir):
|
||||
def test_msteams_yaml_config(mock_post, tmpdir, no_throttling):
|
||||
"""
|
||||
NotifyMSTeams() YAML Configuration Entries
|
||||
|
||||
"""
|
||||
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare Mock
|
||||
mock_post.return_value = requests.Request()
|
||||
mock_post.return_value.status_code = requests.codes.ok
|
||||
|
@ -131,13 +131,11 @@ def test_plugin_nextcloud_urls():
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_nextcloud_edge_cases(mock_post):
|
||||
def test_plugin_nextcloud_edge_cases(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyNextcloud() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# A response
|
||||
robj = mock.Mock()
|
||||
|
@ -121,13 +121,11 @@ def test_plugin_nextcloudtalk_urls():
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_nextcloudtalk_edge_cases(mock_post):
|
||||
def test_plugin_nextcloudtalk_edge_cases(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyNextcloud() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# A response
|
||||
robj = mock.Mock()
|
||||
|
@ -234,13 +234,11 @@ def test_plugin_ntfy_chat_urls():
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_ntfy_attachments(mock_post):
|
||||
def test_plugin_ntfy_attachments(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyNtfy() Attachment Checks
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyNtfy.request_rate_per_sec = 0
|
||||
|
||||
# Prepare Mock return object
|
||||
response = mock.Mock()
|
||||
@ -351,13 +349,11 @@ def test_plugin_ntfy_attachments(mock_post):
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_custom_ntfy_edge_cases(mock_post):
|
||||
def test_plugin_custom_ntfy_edge_cases(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyNtfy() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare our response
|
||||
response = requests.Request()
|
||||
@ -430,7 +426,7 @@ def test_plugin_custom_ntfy_edge_cases(mock_post):
|
||||
|
||||
@mock.patch('requests.post')
|
||||
@mock.patch('requests.get')
|
||||
def test_plugin_ntfy_config_files(mock_post, mock_get):
|
||||
def test_plugin_ntfy_config_files(mock_post, mock_get, no_throttling):
|
||||
"""
|
||||
NotifyNtfy() Config File Cases
|
||||
"""
|
||||
@ -459,9 +455,6 @@ def test_plugin_ntfy_config_files(mock_post, mock_get):
|
||||
tag: ntfy_str max
|
||||
"""
|
||||
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyNtfy.request_rate_per_sec = 0
|
||||
|
||||
# Prepare Mock
|
||||
mock_post.return_value = requests.Request()
|
||||
mock_post.return_value.status_code = requests.codes.ok
|
||||
|
@ -183,13 +183,11 @@ def test_plugin_office365_urls():
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_office365_general(mock_post):
|
||||
def test_plugin_office365_general(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyOffice365() General Testing
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Initialize some generic (but valid) tokens
|
||||
email = 'user@example.net'
|
||||
@ -301,13 +299,11 @@ def test_plugin_office365_general(mock_post):
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_office365_authentication(mock_post):
|
||||
def test_plugin_office365_authentication(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyOffice365() Authentication Testing
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Initialize some generic (but valid) tokens
|
||||
tenant = 'ff-gg-hh-ii-jj'
|
||||
|
@ -192,13 +192,11 @@ def test_plugin_pushbullet_urls():
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_pushbullet_attachments(mock_post):
|
||||
def test_plugin_pushbullet_attachments(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyPushBullet() Attachment Checks
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyPushBullet.request_rate_per_sec = 0
|
||||
|
||||
# Initialize some generic (but valid) tokens
|
||||
access_token = 't' * 32
|
||||
@ -335,13 +333,11 @@ def test_plugin_pushbullet_attachments(mock_post):
|
||||
|
||||
@mock.patch('requests.get')
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_pushbullet_edge_cases(mock_post, mock_get):
|
||||
def test_plugin_pushbullet_edge_cases(mock_post, mock_get, no_throttling):
|
||||
"""
|
||||
NotifyPushBullet() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Initialize some generic (but valid) tokens
|
||||
accesstoken = 'a' * 32
|
||||
|
@ -145,13 +145,11 @@ def test_plugin_pushed_urls():
|
||||
|
||||
@mock.patch('requests.get')
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_pushed_edge_cases(mock_post, mock_get):
|
||||
def test_plugin_pushed_edge_cases(mock_post, mock_get, no_throttling):
|
||||
"""
|
||||
NotifyPushed() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Chat ID
|
||||
recipients = '@ABCDEFG, @DEFGHIJ, #channel, #channel2'
|
||||
|
@ -96,13 +96,11 @@ def test_plugin_pushjet_urls():
|
||||
AppriseURLTester(tests=apprise_url_tests).run_all()
|
||||
|
||||
|
||||
def test_plugin_pushjet_edge_cases():
|
||||
def test_plugin_pushjet_edge_cases(no_throttling):
|
||||
"""
|
||||
NotifyPushjet() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# No application Key specified
|
||||
with pytest.raises(TypeError):
|
||||
|
@ -225,14 +225,12 @@ def test_plugin_reddit_urls():
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_reddit_general(mock_post):
|
||||
def test_plugin_reddit_general(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyReddit() General Tests
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
plugins.NotifyReddit.clock_skew = timedelta(seconds=0)
|
||||
NotifyReddit.clock_skew = timedelta(seconds=0)
|
||||
|
||||
# Generate a valid credentials:
|
||||
kwargs = {
|
||||
|
@ -228,13 +228,11 @@ def test_plugin_rocket_chat_urls():
|
||||
|
||||
@mock.patch('requests.get')
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_rocketchat_edge_cases(mock_post, mock_get):
|
||||
def test_plugin_rocketchat_edge_cases(mock_post, mock_get, no_throttling):
|
||||
"""
|
||||
NotifyRocketChat() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Chat ID
|
||||
recipients = 'AbcD1245, @l2g, @lead2gold, #channel, #channel2'
|
||||
|
@ -122,13 +122,11 @@ def test_plugin_ryver_urls():
|
||||
AppriseURLTester(tests=apprise_url_tests).run_all()
|
||||
|
||||
|
||||
def test_plugin_ryver_edge_cases():
|
||||
def test_plugin_ryver_edge_cases(no_throttling):
|
||||
"""
|
||||
NotifyRyver() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# No token
|
||||
with pytest.raises(TypeError):
|
||||
|
@ -126,13 +126,11 @@ def test_plugin_sendgrid_urls():
|
||||
|
||||
@mock.patch('requests.get')
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_sendgrid_edge_cases(mock_post, mock_get):
|
||||
def test_plugin_sendgrid_edge_cases(mock_post, mock_get, no_throttling):
|
||||
"""
|
||||
NotifySendGrid() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# no apikey
|
||||
with pytest.raises(TypeError):
|
||||
|
@ -154,13 +154,11 @@ def test_plugin_signal_urls():
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_signal_edge_cases(mock_post):
|
||||
def test_plugin_signal_edge_cases(mock_post, no_throttling):
|
||||
"""
|
||||
NotifySignalAPI() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare our response
|
||||
response = requests.Request()
|
||||
@ -209,13 +207,11 @@ def test_plugin_signal_edge_cases(mock_post):
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_signal_test_based_on_feedback(mock_post):
|
||||
def test_plugin_signal_test_based_on_feedback(mock_post, no_throttling):
|
||||
"""
|
||||
NotifySignalAPI() User Feedback Test
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare our response
|
||||
response = requests.Request()
|
||||
@ -309,13 +305,11 @@ def test_plugin_signal_test_based_on_feedback(mock_post):
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_notify_signal_plugin_attachments(mock_post):
|
||||
def test_notify_signal_plugin_attachments(mock_post, no_throttling):
|
||||
"""
|
||||
NotifySignalAPI() Attachments
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
okay_response = requests.Request()
|
||||
okay_response.status_code = requests.codes.ok
|
||||
|
@ -130,13 +130,11 @@ def test_plugin_fcm_cryptography_import_error():
|
||||
|
||||
@pytest.mark.skipif(
|
||||
'cryptography' not in sys.modules, reason="Requires cryptography")
|
||||
def test_plugin_simplepush_edge_cases():
|
||||
def test_plugin_simplepush_edge_cases(no_throttling):
|
||||
"""
|
||||
NotifySimplePush() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# No token
|
||||
with pytest.raises(TypeError):
|
||||
@ -156,12 +154,10 @@ def test_plugin_simplepush_edge_cases():
|
||||
@pytest.mark.skipif(
|
||||
'cryptography' not in sys.modules, reason="Requires cryptography")
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_simplepush_general(mock_post):
|
||||
def test_plugin_simplepush_general(mock_post, no_throttling):
|
||||
"""
|
||||
NotifySimplePush() General Tests
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare a good response
|
||||
response = mock.Mock()
|
||||
|
@ -133,13 +133,11 @@ def test_plugin_sinch_urls():
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_sinch_edge_cases(mock_post):
|
||||
def test_plugin_sinch_edge_cases(mock_post, no_throttling):
|
||||
"""
|
||||
NotifySinch() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare our response
|
||||
response = requests.Request()
|
||||
|
@ -269,13 +269,11 @@ def test_plugin_smseagle_urls():
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_smseagle_edge_cases(mock_post):
|
||||
def test_plugin_smseagle_edge_cases(mock_post, no_throttling):
|
||||
"""
|
||||
NotifySMSEagle() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare our response
|
||||
response = requests.Request()
|
||||
@ -321,13 +319,11 @@ def test_plugin_smseagle_edge_cases(mock_post):
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_smseagle_result_set(mock_post):
|
||||
def test_plugin_smseagle_result_set(mock_post, no_throttling):
|
||||
"""
|
||||
NotifySMSEagle() Result Sets
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare our response
|
||||
response = requests.Request()
|
||||
@ -539,13 +535,11 @@ def test_plugin_smseagle_result_set(mock_post):
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_notify_smseagle_plugin_result_list(mock_post):
|
||||
def test_notify_smseagle_plugin_result_list(mock_post, no_throttling):
|
||||
"""
|
||||
NotifySMSEagle() Result List Response
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
okay_response = requests.Request()
|
||||
okay_response.status_code = requests.codes.ok
|
||||
@ -583,13 +577,11 @@ def test_notify_smseagle_plugin_result_list(mock_post):
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_notify_smseagle_plugin_attachments(mock_post):
|
||||
def test_notify_smseagle_plugin_attachments(mock_post, no_throttling):
|
||||
"""
|
||||
NotifySMSEagle() Attachments
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
okay_response = requests.Request()
|
||||
okay_response.status_code = requests.codes.ok
|
||||
|
@ -155,13 +155,11 @@ def test_plugin_smtp2go_urls():
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_smtp2go_attachments(mock_post):
|
||||
def test_plugin_smtp2go_attachments(mock_post, no_throttling):
|
||||
"""
|
||||
NotifySMTP2Go() Attachments
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
okay_response = requests.Request()
|
||||
okay_response.status_code = requests.codes.ok
|
||||
|
@ -263,14 +263,12 @@ def test_plugin_sparkpost_urls():
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_sparkpost_throttling(mock_post):
|
||||
def test_plugin_sparkpost_throttling(mock_post, no_throttling):
|
||||
"""
|
||||
NotifySparkPost() Throttling
|
||||
|
||||
"""
|
||||
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
plugins.NotifySparkPost.sparkpost_retry_wait_sec = 0.1
|
||||
plugins.NotifySparkPost.sparkpost_retry_attempts = 3
|
||||
|
||||
@ -334,13 +332,11 @@ def test_plugin_sparkpost_throttling(mock_post):
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_sparkpost_attachments(mock_post):
|
||||
def test_plugin_sparkpost_attachments(mock_post, no_throttling):
|
||||
"""
|
||||
NotifySparkPost() Attachments
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
plugins.NotifySparkPost.sparkpost_retry_wait_sec = 0.1
|
||||
plugins.NotifySparkPost.sparkpost_retry_attempts = 3
|
||||
|
||||
|
@ -128,15 +128,13 @@ def test_plugin_twilio_urls():
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_twilio_auth(mock_post):
|
||||
def test_plugin_twilio_auth(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyTwilio() Auth
|
||||
- account-wide auth token
|
||||
- API key and its own auth token
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
response = mock.Mock()
|
||||
response.content = ''
|
||||
@ -199,13 +197,11 @@ def test_plugin_twilio_auth(mock_post):
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_twilio_edge_cases(mock_post):
|
||||
def test_plugin_twilio_edge_cases(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyTwilio() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare our response
|
||||
response = requests.Request()
|
||||
|
@ -164,13 +164,11 @@ def test_plugin_twist_init():
|
||||
|
||||
@mock.patch('requests.get')
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_twist_auth(mock_post, mock_get):
|
||||
def test_plugin_twist_auth(mock_post, mock_get, no_throttling):
|
||||
"""
|
||||
NotifyTwist() login/logout()
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare Mock
|
||||
mock_get.return_value = requests.Request()
|
||||
@ -268,13 +266,11 @@ def test_plugin_twist_auth(mock_post, mock_get):
|
||||
|
||||
@mock.patch('requests.get')
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_twist_cache(mock_post, mock_get):
|
||||
def test_plugin_twist_cache(mock_post, mock_get, no_throttling):
|
||||
"""
|
||||
NotifyTwist() Cache Handling
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
def _response(url, *args, **kwargs):
|
||||
|
||||
@ -355,7 +351,7 @@ def test_plugin_twist_cache(mock_post, mock_get):
|
||||
|
||||
@mock.patch('requests.get')
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_twist_fetch(mock_post, mock_get):
|
||||
def test_plugin_twist_fetch(mock_post, mock_get, no_throttling):
|
||||
"""
|
||||
NotifyTwist() fetch()
|
||||
|
||||
@ -364,8 +360,6 @@ def test_plugin_twist_fetch(mock_post, mock_get):
|
||||
happens to expire. This tests these edge cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Track our iteration; by tracing within an object, we can re-reference
|
||||
# it within a function scope.
|
||||
|
@ -212,7 +212,7 @@ def test_plugin_twitter_urls():
|
||||
|
||||
@mock.patch('requests.get')
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_twitter_general(mock_post, mock_get):
|
||||
def test_plugin_twitter_general(mock_post, mock_get, no_throttling):
|
||||
"""
|
||||
NotifyTwitter() General Tests
|
||||
|
||||
@ -228,9 +228,6 @@ def test_plugin_twitter_general(mock_post, mock_get):
|
||||
'id': 9876,
|
||||
}]
|
||||
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Epoch time:
|
||||
epoch = datetime.utcfromtimestamp(0)
|
||||
|
||||
@ -423,7 +420,7 @@ def test_plugin_twitter_edge_cases():
|
||||
|
||||
@mock.patch('requests.post')
|
||||
@mock.patch('requests.get')
|
||||
def test_plugin_twitter_dm_attachments(mock_get, mock_post):
|
||||
def test_plugin_twitter_dm_attachments(mock_get, mock_post, no_throttling):
|
||||
"""
|
||||
NotifyTwitter() DM Attachment Checks
|
||||
|
||||
@ -439,9 +436,6 @@ def test_plugin_twitter_dm_attachments(mock_get, mock_post):
|
||||
'id': 9876,
|
||||
}
|
||||
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare a good DM response
|
||||
good_dm_response = mock.Mock()
|
||||
good_dm_response.content = dumps(good_dm_response_obj)
|
||||
@ -642,7 +636,7 @@ def test_plugin_twitter_dm_attachments(mock_get, mock_post):
|
||||
|
||||
@mock.patch('requests.post')
|
||||
@mock.patch('requests.get')
|
||||
def test_plugin_twitter_tweet_attachments(mock_get, mock_post):
|
||||
def test_plugin_twitter_tweet_attachments(mock_get, mock_post, no_throttling):
|
||||
"""
|
||||
NotifyTwitter() Tweet Attachment Checks
|
||||
|
||||
@ -658,9 +652,6 @@ def test_plugin_twitter_tweet_attachments(mock_get, mock_post):
|
||||
'id': 9876,
|
||||
}
|
||||
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare a good DM response
|
||||
good_tweet_response = mock.Mock()
|
||||
good_tweet_response.content = dumps(good_tweet_response_obj)
|
||||
|
@ -180,13 +180,11 @@ def test_plugin_vonage_urls():
|
||||
|
||||
|
||||
@mock.patch('requests.post')
|
||||
def test_plugin_vonage_edge_cases(mock_post):
|
||||
def test_plugin_vonage_edge_cases(mock_post, no_throttling):
|
||||
"""
|
||||
NotifyVonage() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Prepare our response
|
||||
response = requests.Request()
|
||||
|
@ -120,13 +120,11 @@ def test_plugin_zulip_urls():
|
||||
AppriseURLTester(tests=apprise_url_tests).run_all()
|
||||
|
||||
|
||||
def test_plugin_zulip_edge_cases():
|
||||
def test_plugin_zulip_edge_cases(no_throttling):
|
||||
"""
|
||||
NotifyZulip() Edge Cases
|
||||
|
||||
"""
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# must be 32 characters long
|
||||
token = 'a' * 32
|
||||
|
@ -28,7 +28,6 @@ from random import choice
|
||||
from string import ascii_uppercase as str_alpha
|
||||
from string import digits as str_num
|
||||
|
||||
from apprise import plugins
|
||||
from apprise import NotifyBase
|
||||
from apprise.common import NotifyFormat
|
||||
from apprise.common import OverflowMode
|
||||
@ -38,7 +37,7 @@ import logging
|
||||
logging.disable(logging.CRITICAL)
|
||||
|
||||
|
||||
def test_notify_overflow_truncate():
|
||||
def test_notify_overflow_truncate(no_throttling):
|
||||
"""
|
||||
API: Overflow Truncate Functionality Testing
|
||||
|
||||
@ -47,9 +46,6 @@ def test_notify_overflow_truncate():
|
||||
# A little preparation
|
||||
#
|
||||
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Number of characters per line
|
||||
row = 24
|
||||
|
||||
@ -210,7 +206,7 @@ def test_notify_overflow_truncate():
|
||||
assert title[0:TestNotification.body_maxlen] == chunks[0].get('body')
|
||||
|
||||
|
||||
def test_notify_overflow_split():
|
||||
def test_notify_overflow_split(no_throttling):
|
||||
"""
|
||||
API: Overflow Split Functionality Testing
|
||||
|
||||
@ -220,9 +216,6 @@ def test_notify_overflow_split():
|
||||
# A little preparation
|
||||
#
|
||||
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
# Number of characters per line
|
||||
row = 24
|
||||
|
||||
@ -386,7 +379,7 @@ def test_notify_overflow_split():
|
||||
offset += len(_body)
|
||||
|
||||
|
||||
def test_notify_overflow_general():
|
||||
def test_notify_overflow_general(no_throttling):
|
||||
"""
|
||||
API: Overflow General Testing
|
||||
|
||||
@ -396,9 +389,6 @@ def test_notify_overflow_general():
|
||||
# A little preparation
|
||||
#
|
||||
|
||||
# Disable Throttling to speed testing
|
||||
plugins.NotifyBase.request_rate_per_sec = 0
|
||||
|
||||
#
|
||||
# First Test: Truncated Title
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user