mirror of
https://github.com/caronc/apprise.git
synced 2025-02-06 05:19:15 +01:00
fix: cto= and rto= lines now work from YAML config (#751)
This commit is contained in:
parent
640c00ae70
commit
29e4c5ebd8
@ -194,7 +194,7 @@ class URLBase:
|
||||
asset if isinstance(asset, AppriseAsset) else AppriseAsset()
|
||||
|
||||
# Certificate Verification (for SSL calls); default to being enabled
|
||||
self.verify_certificate = kwargs.get('verify', True)
|
||||
self.verify_certificate = parse_bool(kwargs.get('verify', True))
|
||||
|
||||
# Secure Mode
|
||||
self.secure = kwargs.get('secure', False)
|
||||
@ -222,24 +222,22 @@ class URLBase:
|
||||
self.password = URLBase.unquote(self.password)
|
||||
|
||||
# Store our Timeout Variables
|
||||
if 'socket_read_timeout' in kwargs:
|
||||
if 'rto' in kwargs:
|
||||
try:
|
||||
self.socket_read_timeout = \
|
||||
float(kwargs.get('socket_read_timeout'))
|
||||
self.socket_read_timeout = float(kwargs.get('rto'))
|
||||
except (TypeError, ValueError):
|
||||
self.logger.warning(
|
||||
'Invalid socket read timeout (rto) was specified {}'
|
||||
.format(kwargs.get('socket_read_timeout')))
|
||||
.format(kwargs.get('rto')))
|
||||
|
||||
if 'socket_connect_timeout' in kwargs:
|
||||
if 'cto' in kwargs:
|
||||
try:
|
||||
self.socket_connect_timeout = \
|
||||
float(kwargs.get('socket_connect_timeout'))
|
||||
self.socket_connect_timeout = float(kwargs.get('cto'))
|
||||
|
||||
except (TypeError, ValueError):
|
||||
self.logger.warning(
|
||||
'Invalid socket connect timeout (cto) was specified {}'
|
||||
.format(kwargs.get('socket_connect_timeout')))
|
||||
.format(kwargs.get('cto')))
|
||||
|
||||
if 'tag' in kwargs:
|
||||
# We want to associate some tags with our notification service.
|
||||
@ -647,11 +645,11 @@ class URLBase:
|
||||
|
||||
# Store our socket read timeout if specified
|
||||
if 'rto' in results['qsd']:
|
||||
results['socket_read_timeout'] = results['qsd']['rto']
|
||||
results['rto'] = results['qsd']['rto']
|
||||
|
||||
# Store our socket connect timeout if specified
|
||||
if 'cto' in results['qsd']:
|
||||
results['socket_connect_timeout'] = results['qsd']['cto']
|
||||
results['cto'] = results['qsd']['cto']
|
||||
|
||||
if 'port' in results['qsd']:
|
||||
results['port'] = results['qsd']['port']
|
||||
|
@ -27,6 +27,7 @@ import pytest
|
||||
from apprise.AppriseAsset import AppriseAsset
|
||||
from apprise.config.ConfigBase import ConfigBase
|
||||
from apprise import ConfigFormat
|
||||
from inspect import cleandoc
|
||||
import yaml
|
||||
|
||||
# Disable logging for a cleaner testing output
|
||||
@ -957,6 +958,44 @@ def test_yaml_vs_text_tagging():
|
||||
assert 'mytag' in yaml_result[0]
|
||||
|
||||
|
||||
def test_config_base_config_parse_yaml_globals():
|
||||
"""
|
||||
API: ConfigBase.config_parse_yaml globals
|
||||
|
||||
"""
|
||||
|
||||
# general reference used below
|
||||
asset = AppriseAsset()
|
||||
|
||||
# Invalid Syntax (throws a ScannerError)
|
||||
results, config = ConfigBase.config_parse_yaml(cleandoc("""
|
||||
urls:
|
||||
- jsons://localhost1:
|
||||
- to: jeff@gmail.com
|
||||
tag: jeff, customer
|
||||
cto: 30
|
||||
rto: 30
|
||||
verify: no
|
||||
|
||||
- jsons://localhost2?cto=30&rto=30&verify=no:
|
||||
- to: json@gmail.com
|
||||
tag: json, customer
|
||||
"""), asset=asset)
|
||||
|
||||
# Invalid data gets us an empty result set
|
||||
assert isinstance(results, list)
|
||||
|
||||
# Our results loaded
|
||||
assert len(results) == 2
|
||||
assert len(config) == 0
|
||||
|
||||
# Now verify that our global variables correctly initialized
|
||||
for entry in results:
|
||||
assert entry.verify_certificate is False
|
||||
assert entry.socket_read_timeout == 30
|
||||
assert entry.socket_connect_timeout == 30
|
||||
|
||||
|
||||
# This test fails on CentOS 8.x so it was moved into it's own function
|
||||
# so it could be bypassed. The ability to use lists in YAML files didn't
|
||||
# appear to happen until later on; it's certainly not available in v3.12
|
||||
|
Loading…
Reference in New Issue
Block a user