Issue 69: Tests for Headers support

pull/70/head
Kaustubh Phatak 2019-02-15 14:37:55 -08:00
parent 753e36feab
commit 761291e65c
No known key found for this signature in database
GPG Key ID: B79B46BF74CB18E4
5 changed files with 19 additions and 5 deletions

View File

@ -425,5 +425,6 @@ class NotifyBase(object):
if 'user' in results['qsd']: if 'user' in results['qsd']:
results['user'] = results['qsd']['user'] results['user'] = results['qsd']['user']
results['headers'] = {k[1:]: v for k, v in results['qsd'].items() if re.match(r'^-.', k)} results['headers'] = {k[1:]: v for k, v in results['qsd'].items()
if re.match(r'^-.', k)}
return results return results

View File

@ -58,8 +58,8 @@ LIST_DELIM = re.compile(r'[ \t\r\n,\\/]+')
# region as a delimiter. This is a bit hacky; but it's much easier than having # region as a delimiter. This is a bit hacky; but it's much easier than having
# users of this product search though this Access Key Secret and escape all # users of this product search though this Access Key Secret and escape all
# of the forward slashes! # of the forward slashes!
IS_REGION = re.compile( IS_REGION = re.compile(r'^\s*(?P<country>[a-z]{2})-'
r'^\s*(?P<country>[a-z]{2})-(?P<area>[a-z]+)-(?P<no>[0-9]+)\s*$', re.I) r'(?P<area>[a-z]+)-(?P<no>[0-9]+)\s*$', re.I)
# Extend HTTP Error Messages # Extend HTTP Error Messages
AWS_HTTP_ERROR_MAP = HTTP_ERROR_MAP.copy() AWS_HTTP_ERROR_MAP = HTTP_ERROR_MAP.copy()

View File

@ -166,6 +166,12 @@ def test_notify_base_urls():
assert 'password' in results assert 'password' in results
assert results['password'] == "newpassword" assert results['password'] == "newpassword"
# pass headers
results = NotifyBase.parse_url(
'https://localhost:8080?-HeaderKey=HeaderValue')
assert 'headerkey' in results['headers']
assert results['headers']['headerkey'] == 'HeaderValue'
# User Handling # User Handling
# user keyword over-rides default password # user keyword over-rides default password

View File

@ -431,6 +431,10 @@ TEST_URLS = (
# is set and tests that we gracfully handle them # is set and tests that we gracfully handle them
'test_requests_exceptions': True, 'test_requests_exceptions': True,
}), }),
('json://localhost:8080/path?-HeaderKey=HeaderValue', {
'instance': plugins.NotifyJSON,
}),
################################## ##################################
# NotifyKODI # NotifyKODI
@ -1470,6 +1474,9 @@ TEST_URLS = (
# is set and tests that we gracfully handle them # is set and tests that we gracfully handle them
'test_requests_exceptions': True, 'test_requests_exceptions': True,
}), }),
('xml://localhost:8080/path?-HeaderKey=HeaderValue', {
'instance': plugins.NotifyXML,
}),
) )