Tests nomcom confirmation receipts. Fixes bug in submission blackout test where test was using local time, but view was using utc
- Legacy-Id: 10034
This commit is contained in:
parent
e545f5e131
commit
83753dd24e
|
@ -14,7 +14,7 @@ from django.contrib.auth.models import User
|
|||
import debug # pyflakes:ignore
|
||||
|
||||
from ietf.utils.test_utils import login_testing_unauthorized, TestCase
|
||||
from ietf.utils.mail import outbox
|
||||
from ietf.utils.mail import outbox, empty_outbox
|
||||
|
||||
from ietf.person.models import Email, Person
|
||||
from ietf.group.models import Group
|
||||
|
@ -466,8 +466,35 @@ class NomcomViewsTest(TestCase):
|
|||
|
||||
def test_public_nominate(self):
|
||||
login_testing_unauthorized(self, COMMUNITY_USER, self.public_nominate_url)
|
||||
return self.nominate_view(public=True)
|
||||
self.client.logout()
|
||||
|
||||
messages_before = len(outbox)
|
||||
|
||||
self.nominate_view(public=True,confirmation=True)
|
||||
|
||||
self.assertEqual(len(outbox), messages_before + 4)
|
||||
|
||||
self.assertTrue('New person' in outbox[-4]['Subject'])
|
||||
self.assertTrue('nomcomchair' in outbox[-4]['To'])
|
||||
self.assertTrue('secretariat' in outbox[-4]['To'])
|
||||
|
||||
self.assertEqual('IETF Nomination Information', outbox[-3]['Subject'])
|
||||
self.assertTrue('nominee' in outbox[-3]['To'])
|
||||
|
||||
self.assertEqual('Nomination Information', outbox[-2]['Subject'])
|
||||
self.assertTrue('nomcomchair' in outbox[-2]['To'])
|
||||
|
||||
self.assertEqual('Nomination receipt', outbox[-1]['Subject'])
|
||||
self.assertTrue('plain' in outbox[-1]['To'])
|
||||
self.assertTrue(u'Comments with accents äöå' in unicode(outbox[-1].get_payload(decode=True),"utf-8","replace"))
|
||||
|
||||
# Nominate the same person for the same position again without asking for confirmation
|
||||
|
||||
messages_before = len(outbox)
|
||||
|
||||
self.nominate_view(public=True)
|
||||
self.assertEqual(len(outbox), messages_before + 1)
|
||||
self.assertEqual('Nomination Information', outbox[-1]['Subject'])
|
||||
self.assertTrue('nomcomchair' in outbox[-1]['To'])
|
||||
|
||||
def test_private_nominate(self):
|
||||
self.access_member_url(self.private_nominate_url)
|
||||
|
@ -479,6 +506,7 @@ class NomcomViewsTest(TestCase):
|
|||
nominee_email = kwargs.pop('nominee_email', u'nominee@example.com')
|
||||
nominator_email = kwargs.pop('nominator_email', "%s%s" % (COMMUNITY_USER, EMAIL_DOMAIN))
|
||||
position_name = kwargs.pop('position', 'IAOC')
|
||||
confirmation = kwargs.pop('confirmation', False)
|
||||
|
||||
if public:
|
||||
nominate_url = self.public_nominate_url
|
||||
|
@ -511,7 +539,8 @@ class NomcomViewsTest(TestCase):
|
|||
'candidate_email': candidate_email,
|
||||
'candidate_phone': candidate_phone,
|
||||
'position': position.id,
|
||||
'comments': comments}
|
||||
'comments': comments,
|
||||
'confirmation': confirmation}
|
||||
if not public:
|
||||
test_data['nominator_email'] = nominator_email
|
||||
|
||||
|
@ -599,8 +628,20 @@ class NomcomViewsTest(TestCase):
|
|||
|
||||
def test_public_feedback(self):
|
||||
login_testing_unauthorized(self, COMMUNITY_USER, self.public_feedback_url)
|
||||
return self.feedback_view(public=True)
|
||||
self.client.logout()
|
||||
|
||||
empty_outbox()
|
||||
self.feedback_view(public=True,confirmation=True)
|
||||
# feedback_view does a nomination internally: there is a lot of email related to that - tested elsewhere
|
||||
# We're interested in the confirmation receipt here
|
||||
self.assertEqual(len(outbox),4)
|
||||
self.assertEqual('NomCom comment confirmation', outbox[3]['Subject'])
|
||||
self.assertTrue('plain' in outbox[3]['To'])
|
||||
self.assertTrue(u'Comments with accents äöå' in unicode(outbox[3].get_payload(decode=True),"utf-8","replace"))
|
||||
|
||||
empty_outbox()
|
||||
self.feedback_view(public=True)
|
||||
self.assertTrue(len(outbox),1)
|
||||
self.assertFalse('confirmation' in outbox[0]['Subject'])
|
||||
|
||||
def test_private_feedback(self):
|
||||
self.access_member_url(self.private_feedback_url)
|
||||
|
@ -612,6 +653,7 @@ class NomcomViewsTest(TestCase):
|
|||
nominee_email = kwargs.pop('nominee_email', u'nominee@example.com')
|
||||
nominator_email = kwargs.pop('nominator_email', "%s%s" % (COMMUNITY_USER, EMAIL_DOMAIN))
|
||||
position_name = kwargs.pop('position', 'IAOC')
|
||||
confirmation = kwargs.pop('confirmation', False)
|
||||
|
||||
self.nominate_view(public=public,
|
||||
nominee_email=nominee_email,
|
||||
|
@ -645,7 +687,8 @@ class NomcomViewsTest(TestCase):
|
|||
test_data = {'comments': comments,
|
||||
'position_name': position.name,
|
||||
'nominee_name': nominee.email.person.name,
|
||||
'nominee_email': nominee.email.address}
|
||||
'nominee_email': nominee.email.address,
|
||||
'confirmation': confirmation}
|
||||
|
||||
if public:
|
||||
test_data['nominator_email'] = nominator_email
|
||||
|
|
|
@ -710,7 +710,7 @@ class SubmitTests(TestCase):
|
|||
url = urlreverse('submit_upload_submission')
|
||||
# set meeting to today so we're in blackout period
|
||||
meeting = Meeting.get_current_meeting()
|
||||
meeting.date = datetime.datetime.today()
|
||||
meeting.date = datetime.datetime.utcnow()
|
||||
meeting.save()
|
||||
|
||||
# regular user, no access
|
||||
|
|
Loading…
Reference in a new issue