Allow an empty body when attachment is provided (#156)

This commit is contained in:
Gerald
2023-12-24 03:35:10 +08:00
committed by GitHub
parent 9d3f8c7a33
commit 4ad2bb1c03
3 changed files with 22 additions and 1 deletions

View File

@@ -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',