fix: improve when Message objects are created (#5836)
* fix: improve when Message objects are created * test: further improve feedback test * fix: improve and test another form * test: Restructure test infrastructure
This commit is contained in:
parent
4179d08dbb
commit
ac65232115
|
@ -343,7 +343,7 @@ class NominateForm(forms.ModelForm):
|
|||
'year': self.nomcom.year(),
|
||||
}
|
||||
path = nomcom_template_path + NOMINATION_RECEIPT_TEMPLATE
|
||||
send_mail(None, to_email, from_email, subject, path, context, cc=cc)
|
||||
send_mail(None, to_email, from_email, subject, path, context, cc=cc, copy=False, save=False)
|
||||
|
||||
return nomination
|
||||
|
||||
|
@ -458,7 +458,7 @@ class NominateNewPersonForm(forms.ModelForm):
|
|||
'year': self.nomcom.year(),
|
||||
}
|
||||
path = nomcom_template_path + NOMINATION_RECEIPT_TEMPLATE
|
||||
send_mail(None, to_email, from_email, subject, path, context, cc=cc)
|
||||
send_mail(None, to_email, from_email, subject, path, context, cc=cc, copy=False, save=False)
|
||||
|
||||
return nomination
|
||||
|
||||
|
@ -551,7 +551,7 @@ class FeedbackForm(forms.ModelForm):
|
|||
}
|
||||
path = nomcom_template_path + FEEDBACK_RECEIPT_TEMPLATE
|
||||
# TODO - make the thing above more generic
|
||||
send_mail(None, to_email, from_email, subject, path, context, cc=cc, copy=False)
|
||||
send_mail(None, to_email, from_email, subject, path, context, cc=cc, copy=False, save=False)
|
||||
|
||||
class Meta:
|
||||
model = Feedback
|
||||
|
|
|
@ -122,7 +122,7 @@ class NomcomViewsTest(TestCase):
|
|||
self.check_url_status(url, 200)
|
||||
self.client.logout()
|
||||
login_testing_unauthorized(self, MEMBER_USER, url)
|
||||
return self.check_url_status(url, 200)
|
||||
self.check_url_status(url, 200)
|
||||
|
||||
def access_chair_url(self, url):
|
||||
login_testing_unauthorized(self, COMMUNITY_USER, url)
|
||||
|
@ -134,7 +134,7 @@ class NomcomViewsTest(TestCase):
|
|||
login_testing_unauthorized(self, COMMUNITY_USER, url)
|
||||
login_testing_unauthorized(self, CHAIR_USER, url)
|
||||
login_testing_unauthorized(self, SECRETARIAT_USER, url)
|
||||
return self.check_url_status(url, 200)
|
||||
self.check_url_status(url, 200)
|
||||
|
||||
def test_private_index_view(self):
|
||||
"""Verify private home view"""
|
||||
|
@ -599,6 +599,8 @@ class NomcomViewsTest(TestCase):
|
|||
self.nominate_view(public=True,confirmation=True)
|
||||
|
||||
self.assertEqual(len(outbox), messages_before + 3)
|
||||
self.assertEqual(Message.objects.count(), 2)
|
||||
self.assertFalse(Message.objects.filter(subject="Nomination receipt").exists())
|
||||
|
||||
self.assertEqual('IETF Nomination Information', outbox[-3]['Subject'])
|
||||
self.assertEqual(self.email_from, outbox[-3]['From'])
|
||||
|
@ -625,8 +627,7 @@ class NomcomViewsTest(TestCase):
|
|||
|
||||
def test_private_nominate(self):
|
||||
self.access_member_url(self.private_nominate_url)
|
||||
return self.nominate_view(public=False)
|
||||
self.client.logout()
|
||||
self.nominate_view(public=False)
|
||||
|
||||
def test_public_nominate_newperson(self):
|
||||
login_testing_unauthorized(self, COMMUNITY_USER, self.public_nominate_url)
|
||||
|
@ -666,13 +667,13 @@ class NomcomViewsTest(TestCase):
|
|||
|
||||
def test_private_nominate_newperson(self):
|
||||
self.access_member_url(self.private_nominate_url)
|
||||
return self.nominate_newperson_view(public=False)
|
||||
self.client.logout()
|
||||
self.nominate_newperson_view(public=False, confirmation=True)
|
||||
self.assertFalse(Message.objects.filter(subject="Nomination receipt").exists())
|
||||
|
||||
def test_private_nominate_newperson_who_already_exists(self):
|
||||
EmailFactory(address='nominee@example.com')
|
||||
self.access_member_url(self.private_nominate_newperson_url)
|
||||
return self.nominate_newperson_view(public=False)
|
||||
self.nominate_newperson_view(public=False)
|
||||
|
||||
def test_public_nominate_with_automatic_questionnaire(self):
|
||||
nomcom = get_nomcom_by_year(self.year)
|
||||
|
@ -844,8 +845,7 @@ class NomcomViewsTest(TestCase):
|
|||
|
||||
def test_add_questionnaire(self):
|
||||
self.access_chair_url(self.add_questionnaire_url)
|
||||
return self.add_questionnaire()
|
||||
self.client.logout()
|
||||
self.add_questionnaire()
|
||||
|
||||
def add_questionnaire(self, *args, **kwargs):
|
||||
public = kwargs.pop('public', False)
|
||||
|
@ -906,6 +906,8 @@ class NomcomViewsTest(TestCase):
|
|||
# We're interested in the confirmation receipt here
|
||||
self.assertEqual(len(outbox),3)
|
||||
self.assertEqual('NomCom comment confirmation', outbox[2]['Subject'])
|
||||
self.assertEqual(Message.objects.count(), 2)
|
||||
self.assertFalse(Message.objects.filter(subject="NomCom comment confirmation").exists())
|
||||
email_body = get_payload_text(outbox[2])
|
||||
self.assertIn(position, email_body)
|
||||
self.assertNotIn('$', email_body)
|
||||
|
@ -920,7 +922,7 @@ class NomcomViewsTest(TestCase):
|
|||
|
||||
def test_private_feedback(self):
|
||||
self.access_member_url(self.private_feedback_url)
|
||||
return self.feedback_view(public=False)
|
||||
self.feedback_view(public=False)
|
||||
|
||||
def feedback_view(self, *args, **kwargs):
|
||||
public = kwargs.pop('public', True)
|
||||
|
|
Loading…
Reference in a new issue