|
5 | 5 | from bs4 import BeautifulSoup |
6 | 6 | from django.conf import settings |
7 | 7 | from django.contrib.auth.models import AnonymousUser |
| 8 | +from django.core import mail |
8 | 9 | from django.http import Http404 |
9 | 10 | from django.test import RequestFactory, TestCase, override_settings |
10 | 11 | from django.urls import reverse |
|
26 | 27 | SealedSubmissionFactory, |
27 | 28 | ) |
28 | 29 | from hypha.apply.funds.views.submission_detail import SubmissionDetailView |
29 | | -from hypha.apply.funds.workflows import INITIAL_STATE |
| 30 | +from hypha.apply.funds.workflows import DRAFT_STATE, INITIAL_STATE |
30 | 31 | from hypha.apply.projects.models import Project |
31 | 32 | from hypha.apply.projects.models.project import CONTRACTING |
32 | 33 | from hypha.apply.projects.tests.factories import ProjectFactory |
@@ -1252,6 +1253,25 @@ def test_can_submit_submission(self): |
1252 | 1253 | submission = self.refresh(self.draft_proposal_submission) |
1253 | 1254 | self.assertNotEqual(old_status, submission.status) |
1254 | 1255 |
|
| 1256 | + @override_settings(SEND_MESSAGES=True) |
| 1257 | + def test_submitting_application_in_draft_state_sends_correct_email(self): |
| 1258 | + draft_submission = ApplicationSubmissionFactory( |
| 1259 | + user=self.user, status=DRAFT_STATE |
| 1260 | + ) |
| 1261 | + data = {**prepare_form_data(draft_submission), "submit": True} |
| 1262 | + |
| 1263 | + self.post_page(draft_submission, {"submit": True, **data}, "edit") |
| 1264 | + |
| 1265 | + self.assertEqual(len(mail.outbox), 1) |
| 1266 | + self.assertIn( |
| 1267 | + "We will review and reply to your submission as quickly as possible.", |
| 1268 | + mail.outbox[0].body, |
| 1269 | + ) |
| 1270 | + self.assertNotIn( |
| 1271 | + "Please note that it is not submitted for review because it's still in draft.", |
| 1272 | + mail.outbox[0].body, |
| 1273 | + ) |
| 1274 | + |
1255 | 1275 | def test_gets_draft_on_edit_submission(self): |
1256 | 1276 | draft_revision = ApplicationRevisionFactory( |
1257 | 1277 | submission=self.draft_proposal_submission |
|
0 commit comments