mirror of
https://github.com/caronc/apprise-api.git
synced 2024-12-13 10:21:14 +01:00
Allow an empty body when attachment is provided (#156)
This commit is contained in:
parent
9d3f8c7a33
commit
4ad2bb1c03
@ -136,6 +136,7 @@ class NotifyForm(forms.Form):
|
||||
widget=forms.Textarea(
|
||||
attrs={'placeholder': _('Define your message body here...')}),
|
||||
max_length=apprise.NotifyBase.body_maxlen,
|
||||
required=False,
|
||||
)
|
||||
|
||||
# Attachment Support
|
||||
|
@ -82,6 +82,26 @@ class NotifyTests(SimpleTestCase):
|
||||
# Reset our mock object
|
||||
mock_notify.reset_mock()
|
||||
|
||||
# Preare our form data
|
||||
form_data = {}
|
||||
attach_data = {
|
||||
'attachment': SimpleUploadedFile(
|
||||
"attach.txt", b"content here", content_type="text/plain")
|
||||
}
|
||||
|
||||
# At a minimum, just an attachment is required
|
||||
form = NotifyForm(form_data, attach_data)
|
||||
assert form.is_valid()
|
||||
|
||||
# Send our notification
|
||||
response = self.client.post(
|
||||
'/notify/{}'.format(key), form.cleaned_data)
|
||||
assert response.status_code == 200
|
||||
assert mock_notify.call_count == 1
|
||||
|
||||
# Reset our mock object
|
||||
mock_notify.reset_mock()
|
||||
|
||||
# Preare our form data
|
||||
form_data = {
|
||||
'body': 'test notifiction',
|
||||
|
@ -691,7 +691,7 @@ class NotifyView(View):
|
||||
content['title'] = request.GET['title']
|
||||
|
||||
# Some basic error checking
|
||||
if not content.get('body') or \
|
||||
if not content.get('body') and not attach or \
|
||||
content.get('type', apprise.NotifyType.INFO) \
|
||||
not in apprise.NOTIFY_TYPES:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user