mirror of
https://github.com/caronc/apprise-api.git
synced 2025-01-31 18:09:17 +01:00
Stateless GET Parameter Support
This commit is contained in:
parent
2b21ab71ef
commit
1da364bbb5
@ -372,6 +372,33 @@ class StatelessNotifyTests(SimpleTestCase):
|
|||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert mock_notify.call_count == 1
|
assert mock_notify.call_count == 1
|
||||||
|
|
||||||
|
@mock.patch('apprise.Apprise.notify')
|
||||||
|
def test_notify_with_get_parameters(self, mock_notify):
|
||||||
|
"""
|
||||||
|
Test sending a simple notification using JSON with GET
|
||||||
|
parameters
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Set our return value
|
||||||
|
mock_notify.return_value = True
|
||||||
|
|
||||||
|
# Preare our JSON data
|
||||||
|
json_data = {
|
||||||
|
'urls': 'json://user@my.domain.ca',
|
||||||
|
'body': 'test notifiction',
|
||||||
|
}
|
||||||
|
|
||||||
|
# Send our notification as a JSON object
|
||||||
|
response = self.client.post(
|
||||||
|
'/notify/?title=my%20title&format=text&type=info',
|
||||||
|
data=json.dumps(json_data),
|
||||||
|
content_type='application/json',
|
||||||
|
)
|
||||||
|
|
||||||
|
# Still supported
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert mock_notify.call_count == 1
|
||||||
|
|
||||||
@mock.patch('apprise.Apprise.notify')
|
@mock.patch('apprise.Apprise.notify')
|
||||||
def test_notify_by_loaded_urls_with_json(self, mock_notify):
|
def test_notify_by_loaded_urls_with_json(self, mock_notify):
|
||||||
"""
|
"""
|
||||||
|
@ -1039,6 +1039,27 @@ class StatelessNotifyView(View):
|
|||||||
# defined
|
# defined
|
||||||
content['urls'] = settings.APPRISE_STATELESS_URLS
|
content['urls'] = settings.APPRISE_STATELESS_URLS
|
||||||
|
|
||||||
|
#
|
||||||
|
# Allow 'format' value to be specified as part of the URL
|
||||||
|
# parameters if not found otherwise defined.
|
||||||
|
#
|
||||||
|
if not content.get('format') and 'format' in request.GET:
|
||||||
|
content['format'] = request.GET['format']
|
||||||
|
|
||||||
|
#
|
||||||
|
# Allow 'type' value to be specified as part of the URL parameters
|
||||||
|
# if not found otherwise defined.
|
||||||
|
#
|
||||||
|
if not content.get('type') and 'type' in request.GET:
|
||||||
|
content['type'] = request.GET['type']
|
||||||
|
|
||||||
|
#
|
||||||
|
# Allow 'title' value to be specified as part of the URL parameters
|
||||||
|
# if not found otherwise defined.
|
||||||
|
#
|
||||||
|
if not content.get('title') and 'title' in request.GET:
|
||||||
|
content['title'] = request.GET['title']
|
||||||
|
|
||||||
# Some basic error checking
|
# Some basic error checking
|
||||||
if not content.get('body') or \
|
if not content.get('body') or \
|
||||||
content.get('type', apprise.NotifyType.INFO) \
|
content.get('type', apprise.NotifyType.INFO) \
|
||||||
|
Loading…
Reference in New Issue
Block a user