Use the test mode in the mail code when running automated tests instead of
reinventing the wheel in test_runner - Legacy-Id: 3620
This commit is contained in:
parent
3c2293d4e8
commit
ce74be89ef
|
@ -4,8 +4,8 @@ from django.conf import settings
|
|||
import django.test
|
||||
|
||||
from ietf.utils.test_utils import SimpleUrlTestCase, canonicalize_sitemap
|
||||
from ietf.utils.test_runner import mail_outbox
|
||||
from ietf.utils.test_data import make_test_data
|
||||
from ietf.utils.mail import outbox
|
||||
|
||||
from ietf.announcements.models import ScheduledAnnouncement
|
||||
|
||||
|
@ -31,13 +31,13 @@ class SendScheduledAnnouncementsTestCase(django.test.TestCase):
|
|||
content_type="",
|
||||
)
|
||||
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
from ietf.announcements.send_scheduled import send_scheduled_announcement
|
||||
send_scheduled_announcement(a)
|
||||
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("This is a test" in mail_outbox[-1]["Subject"])
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("This is a test" in outbox[-1]["Subject"])
|
||||
self.assertTrue(ScheduledAnnouncement.objects.get(id=a.id).mail_sent)
|
||||
|
||||
def test_send_mime_announcement(self):
|
||||
|
@ -52,14 +52,14 @@ class SendScheduledAnnouncementsTestCase(django.test.TestCase):
|
|||
content_type='Multipart/Mixed; Boundary="NextPart"',
|
||||
)
|
||||
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
from ietf.announcements.send_scheduled import send_scheduled_announcement
|
||||
send_scheduled_announcement(a)
|
||||
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("This is a test" in mail_outbox[-1]["Subject"])
|
||||
self.assertTrue("--NextPart" in mail_outbox[-1].as_string())
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("This is a test" in outbox[-1]["Subject"])
|
||||
self.assertTrue("--NextPart" in outbox[-1].as_string())
|
||||
self.assertTrue(ScheduledAnnouncement.objects.get(id=a.id).mail_sent)
|
||||
|
||||
|
||||
|
@ -87,13 +87,13 @@ class SendScheduledAnnouncementsTestCaseREDESIGN(django.test.TestCase):
|
|||
send_at=datetime.datetime.now() + datetime.timedelta(hours=12)
|
||||
)
|
||||
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
from ietf.announcements.send_scheduled import send_scheduled_announcement
|
||||
send_scheduled_announcement(q)
|
||||
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("This is a test" in mail_outbox[-1]["Subject"])
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("This is a test" in outbox[-1]["Subject"])
|
||||
self.assertTrue(SendQueue.objects.get(id=q.id).sent_at)
|
||||
|
||||
def test_send_mime_announcement(self):
|
||||
|
@ -119,14 +119,14 @@ class SendScheduledAnnouncementsTestCaseREDESIGN(django.test.TestCase):
|
|||
send_at=datetime.datetime.now() + datetime.timedelta(hours=12)
|
||||
)
|
||||
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
from ietf.announcements.send_scheduled import send_scheduled_announcement
|
||||
send_scheduled_announcement(q)
|
||||
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("This is a test" in mail_outbox[-1]["Subject"])
|
||||
self.assertTrue("--NextPart" in mail_outbox[-1].as_string())
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("This is a test" in outbox[-1]["Subject"])
|
||||
self.assertTrue("--NextPart" in outbox[-1].as_string())
|
||||
self.assertTrue(SendQueue.objects.get(id=q.id).sent_at)
|
||||
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
|
|
|
@ -44,7 +44,7 @@ from pyquery import PyQuery
|
|||
from ietf.idrfc.models import *
|
||||
from ietf.idtracker.models import *
|
||||
from ietf.utils.test_utils import SimpleUrlTestCase, RealDatabaseTest, login_testing_unauthorized
|
||||
from ietf.utils.test_runner import mail_outbox
|
||||
from ietf.utils.mail import outbox
|
||||
|
||||
class IdRfcUrlTestCase(SimpleUrlTestCase):
|
||||
def testUrls(self):
|
||||
|
@ -85,7 +85,7 @@ class ChangeStateTestCase(django.test.TestCase):
|
|||
|
||||
# change state
|
||||
comments_before = draft.idinternal.comments().count()
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
r = self.client.post(url,
|
||||
dict(state="12", substate=""))
|
||||
|
@ -98,9 +98,9 @@ class ChangeStateTestCase(django.test.TestCase):
|
|||
self.assertEquals(draft.idinternal.cur_sub_state, None)
|
||||
self.assertEquals(draft.idinternal.comments().count(), comments_before + 1)
|
||||
self.assertTrue("State changed" in draft.idinternal.comments()[0].comment_text)
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 2)
|
||||
self.assertTrue("State Update Notice" in mail_outbox[-2]['Subject'])
|
||||
self.assertTrue(draft.filename in mail_outbox[-1]['Subject'])
|
||||
self.assertEquals(len(outbox), mailbox_before + 2)
|
||||
self.assertTrue("State Update Notice" in outbox[-2]['Subject'])
|
||||
self.assertTrue(draft.filename in outbox[-1]['Subject'])
|
||||
|
||||
|
||||
def test_request_last_call(self):
|
||||
|
@ -109,7 +109,7 @@ class ChangeStateTestCase(django.test.TestCase):
|
|||
self.client.login(remote_user="klm")
|
||||
url = urlreverse('doc_change_state', kwargs=dict(name=draft.filename))
|
||||
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
self.assertRaises(BallotInfo.DoesNotExist, lambda: draft.idinternal.ballot)
|
||||
r = self.client.post(url,
|
||||
|
@ -131,8 +131,8 @@ class ChangeStateTestCase(django.test.TestCase):
|
|||
self.assertTrue("Technical Summary" in draft.idinternal.ballot.ballot_writeup)
|
||||
|
||||
# mail notice
|
||||
self.assertTrue(len(mail_outbox) > mailbox_before)
|
||||
self.assertTrue("Last Call:" in mail_outbox[-1]['Subject'])
|
||||
self.assertTrue(len(outbox) > mailbox_before)
|
||||
self.assertTrue("Last Call:" in outbox[-1]['Subject'])
|
||||
|
||||
# comment
|
||||
self.assertTrue("Last Call was requested" in draft.idinternal.comments()[0].comment_text)
|
||||
|
@ -164,7 +164,7 @@ class EditInfoTestCase(django.test.TestCase):
|
|||
|
||||
# edit info
|
||||
comments_before = draft.idinternal.comments().count()
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
draft.group = Acronym.objects.get(acronym_id=Acronym.INDIVIDUAL_SUBMITTER)
|
||||
draft.save()
|
||||
new_job_owner = IESGLogin.objects.exclude(id__in=[IESGLogin.objects.get(login_name="klm").id, draft.idinternal.job_owner_id])[0]
|
||||
|
@ -189,8 +189,8 @@ class EditInfoTestCase(django.test.TestCase):
|
|||
self.assertEquals(draft.idinternal.note, "")
|
||||
self.assertTrue(not draft.idinternal.agenda)
|
||||
self.assertEquals(draft.idinternal.comments().count(), comments_before + 3)
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue(draft.filename in mail_outbox[-1]['Subject'])
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue(draft.filename in outbox[-1]['Subject'])
|
||||
|
||||
def test_edit_telechat_date(self):
|
||||
draft = InternetDraft.objects.get(filename="draft-ietf-mipshop-pfmipv6")
|
||||
|
@ -251,7 +251,7 @@ class EditInfoTestCase(django.test.TestCase):
|
|||
self.assertTrue('@' in q('form input[name=state_change_notice_to]')[0].get('value'))
|
||||
|
||||
# add
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
job_owner = IESGLogin.objects.filter(user_level=1)[0]
|
||||
area = Area.active_areas()[0]
|
||||
|
@ -277,7 +277,7 @@ class EditInfoTestCase(django.test.TestCase):
|
|||
self.assertEquals(draft.idinternal.comments().count(), 2)
|
||||
self.assertTrue("Draft added" in draft.idinternal.comments()[0].comment_text)
|
||||
self.assertTrue("This is a note" in draft.idinternal.comments()[1].comment_text)
|
||||
self.assertEquals(len(mail_outbox), mailbox_before)
|
||||
self.assertEquals(len(outbox), mailbox_before)
|
||||
|
||||
|
||||
class ResurrectTestCase(django.test.TestCase):
|
||||
|
@ -302,7 +302,7 @@ class ResurrectTestCase(django.test.TestCase):
|
|||
|
||||
# request resurrect
|
||||
comments_before = draft.idinternal.comments().count()
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
r = self.client.post(url, dict())
|
||||
self.assertEquals(r.status_code, 302)
|
||||
|
@ -311,8 +311,8 @@ class ResurrectTestCase(django.test.TestCase):
|
|||
self.assertEquals(draft.idinternal.resurrect_requested_by, IESGLogin.objects.get(login_name=login_as))
|
||||
self.assertEquals(draft.idinternal.comments().count(), comments_before + 1)
|
||||
self.assertTrue("Resurrection" in draft.idinternal.comments()[0].comment_text)
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("Resurrection" in mail_outbox[-1]['Subject'])
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("Resurrection" in outbox[-1]['Subject'])
|
||||
|
||||
def test_resurrect(self):
|
||||
draft = InternetDraft.objects.get(filename="draft-ietf-mip6-cn-ipsec")
|
||||
|
@ -332,7 +332,7 @@ class ResurrectTestCase(django.test.TestCase):
|
|||
|
||||
# request resurrect
|
||||
comments_before = draft.idinternal.comments().count()
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
r = self.client.post(url, dict())
|
||||
self.assertEquals(r.status_code, 302)
|
||||
|
@ -342,7 +342,7 @@ class ResurrectTestCase(django.test.TestCase):
|
|||
self.assertEquals(draft.idinternal.comments().count(), comments_before + 1)
|
||||
self.assertTrue("completed" in draft.idinternal.comments()[0].comment_text)
|
||||
self.assertEquals(draft.status.status, "Active")
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
|
||||
class AddCommentTestCase(django.test.TestCase):
|
||||
fixtures = ['base', 'draft']
|
||||
|
@ -360,16 +360,16 @@ class AddCommentTestCase(django.test.TestCase):
|
|||
|
||||
# request resurrect
|
||||
comments_before = draft.idinternal.comments().count()
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
r = self.client.post(url, dict(comment="This is a test."))
|
||||
self.assertEquals(r.status_code, 302)
|
||||
|
||||
self.assertEquals(draft.idinternal.comments().count(), comments_before + 1)
|
||||
self.assertTrue("This is a test." in draft.idinternal.comments()[0].comment_text)
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("updated" in mail_outbox[-1]['Subject'])
|
||||
self.assertTrue(draft.filename in mail_outbox[-1]['Subject'])
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("updated" in outbox[-1]['Subject'])
|
||||
self.assertTrue(draft.filename in outbox[-1]['Subject'])
|
||||
|
||||
class EditPositionTestCase(django.test.TestCase):
|
||||
fixtures = ['base', 'draft', 'ballot']
|
||||
|
@ -462,7 +462,7 @@ class EditPositionTestCase(django.test.TestCase):
|
|||
self.assertTrue(len(q('form input[name="cc"]')) > 0)
|
||||
|
||||
# send
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
IESGComment.objects.create(ballot=draft.idinternal.ballot,
|
||||
ad=IESGLogin.objects.get(login_name=login_as),
|
||||
text="Test!", date=date.today(),
|
||||
|
@ -471,8 +471,8 @@ class EditPositionTestCase(django.test.TestCase):
|
|||
r = self.client.post(url, dict(cc="test@example.com", cc_state_change="1"))
|
||||
self.assertEquals(r.status_code, 302)
|
||||
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("COMMENT" in mail_outbox[-1]['Subject'])
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("COMMENT" in outbox[-1]['Subject'])
|
||||
|
||||
|
||||
class DeferBallotTestCase(django.test.TestCase):
|
||||
|
@ -489,7 +489,7 @@ class DeferBallotTestCase(django.test.TestCase):
|
|||
|
||||
# defer
|
||||
self.assertTrue(not draft.idinternal.ballot.defer)
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
r = self.client.post(url, dict())
|
||||
self.assertEquals(r.status_code, 302)
|
||||
|
@ -498,9 +498,9 @@ class DeferBallotTestCase(django.test.TestCase):
|
|||
self.assertTrue(draft.idinternal.ballot.defer)
|
||||
self.assertTrue(draft.idinternal.cur_state_id == IDState.IESG_EVALUATION_DEFER)
|
||||
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 2)
|
||||
self.assertTrue("Deferred" in mail_outbox[-2]['Subject'])
|
||||
self.assertTrue(draft.file_tag() in mail_outbox[-2]['Subject'])
|
||||
self.assertEquals(len(outbox), mailbox_before + 2)
|
||||
self.assertTrue("Deferred" in outbox[-2]['Subject'])
|
||||
self.assertTrue(draft.file_tag() in outbox[-2]['Subject'])
|
||||
|
||||
def test_undefer_ballot(self):
|
||||
draft = InternetDraft.objects.get(filename="draft-ietf-mipshop-pfmipv6")
|
||||
|
@ -569,7 +569,7 @@ class BallotWriteupsTestCase(django.test.TestCase):
|
|||
url = urlreverse('doc_ballot_lastcall', kwargs=dict(name=draft.filename))
|
||||
login_testing_unauthorized(self, "klm", url)
|
||||
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
r = self.client.post(url, dict(
|
||||
last_call_text=draft.idinternal.ballot.last_call_text,
|
||||
|
@ -577,9 +577,9 @@ class BallotWriteupsTestCase(django.test.TestCase):
|
|||
draft = InternetDraft.objects.get(filename="draft-ietf-mipshop-pfmipv6")
|
||||
self.assertEquals(draft.idinternal.cur_state_id, IDState.LAST_CALL_REQUESTED)
|
||||
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 3)
|
||||
self.assertEquals(len(outbox), mailbox_before + 3)
|
||||
|
||||
self.assertTrue("Last Call" in mail_outbox[-1]['Subject'])
|
||||
self.assertTrue("Last Call" in outbox[-1]['Subject'])
|
||||
|
||||
def test_edit_ballot_writeup(self):
|
||||
draft = InternetDraft.objects.get(filename="draft-ietf-mipshop-pfmipv6")
|
||||
|
@ -622,7 +622,7 @@ class BallotWriteupsTestCase(django.test.TestCase):
|
|||
IESGDiscuss.objects.create(ad=active[3], active=True, date=datetime.date.today(), text="test " * 20, ballot=draft.idinternal.ballot)
|
||||
IESGComment.objects.create(ad=active[3], active=True, date=datetime.date.today(), text="test " * 20, ballot=draft.idinternal.ballot)
|
||||
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
r = self.client.post(url, dict(
|
||||
ballot_writeup=draft.idinternal.ballot.ballot_writeup,
|
||||
|
@ -632,8 +632,8 @@ class BallotWriteupsTestCase(django.test.TestCase):
|
|||
draft = InternetDraft.objects.get(filename="draft-ietf-mipshop-pfmipv6")
|
||||
|
||||
self.assertTrue(draft.idinternal.ballot.ballot_issued)
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 2)
|
||||
self.assertTrue("Evaluation:" in mail_outbox[-2]['Subject'])
|
||||
self.assertEquals(len(outbox), mailbox_before + 2)
|
||||
self.assertTrue("Evaluation:" in outbox[-2]['Subject'])
|
||||
|
||||
|
||||
def test_edit_approval_text(self):
|
||||
|
@ -689,7 +689,7 @@ class ApproveBallotTestCase(django.test.TestCase):
|
|||
self.assertEquals(len(q('pre')), 1)
|
||||
|
||||
# approve
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
r = self.client.post(url, dict())
|
||||
self.assertEquals(r.status_code, 302)
|
||||
|
@ -697,11 +697,11 @@ class ApproveBallotTestCase(django.test.TestCase):
|
|||
draft = InternetDraft.objects.get(filename="draft-ietf-mipshop-pfmipv6")
|
||||
self.assertEquals(draft.idinternal.cur_state_id, IDState.APPROVED_ANNOUNCEMENT_SENT)
|
||||
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 4)
|
||||
self.assertEquals(len(outbox), mailbox_before + 4)
|
||||
|
||||
self.assertTrue("Protocol Action" in mail_outbox[-2]['Subject'])
|
||||
self.assertTrue("Protocol Action" in outbox[-2]['Subject'])
|
||||
# the IANA copy
|
||||
self.assertTrue("Protocol Action" in mail_outbox[-1]['Subject'])
|
||||
self.assertTrue("Protocol Action" in outbox[-1]['Subject'])
|
||||
|
||||
class MakeLastCallTestCase(django.test.TestCase):
|
||||
fixtures = ['base', 'draft', 'ballot']
|
||||
|
@ -723,7 +723,7 @@ class MakeLastCallTestCase(django.test.TestCase):
|
|||
self.assertEquals(len(q('input[name=last_call_sent_date]')), 1)
|
||||
|
||||
# make last call
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
expire_date = q('input[name=last_call_expiration_date]')[0].get("value")
|
||||
|
||||
|
@ -736,11 +736,11 @@ class MakeLastCallTestCase(django.test.TestCase):
|
|||
draft = InternetDraft.objects.get(filename="draft-ietf-mipshop-pfmipv6")
|
||||
self.assertEquals(draft.idinternal.cur_state_id, IDState.IN_LAST_CALL)
|
||||
self.assertEquals(draft.lc_expiration_date.strftime("%Y-%m-%d"), expire_date)
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 4)
|
||||
self.assertEquals(len(outbox), mailbox_before + 4)
|
||||
|
||||
self.assertTrue("Last Call" in mail_outbox[-4]['Subject'])
|
||||
self.assertTrue("Last Call" in outbox[-4]['Subject'])
|
||||
# the IANA copy
|
||||
self.assertTrue("Last Call" in mail_outbox[-3]['Subject'])
|
||||
self.assertTrue("Last Call" in outbox[-3]['Subject'])
|
||||
|
||||
class ExpireIDsTestCase(django.test.TestCase):
|
||||
fixtures = ['base', 'draft']
|
||||
|
@ -796,12 +796,12 @@ class ExpireIDsTestCase(django.test.TestCase):
|
|||
self.assertEquals(len(documents), 1)
|
||||
|
||||
# test send warning
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
send_expire_warning_for_id(documents[0])
|
||||
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("author@example.com" in str(mail_outbox[-1]))
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("author@example.com" in str(outbox[-1]))
|
||||
|
||||
def test_expire_ids(self):
|
||||
from ietf.idrfc.expire import get_expired_ids, send_expire_notice_for_id, expire_id
|
||||
|
@ -828,14 +828,14 @@ class ExpireIDsTestCase(django.test.TestCase):
|
|||
|
||||
for d in documents:
|
||||
# test notice
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
send_expire_notice_for_id(d)
|
||||
|
||||
self.assertEquals(InternetDraft.objects.get(filename=d.filename).dunn_sent_date, datetime.date.today())
|
||||
if d.idinternal:
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("expired" in mail_outbox[-1]["Subject"])
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("expired" in outbox[-1]["Subject"])
|
||||
|
||||
# test expiry
|
||||
txt = "%s-%s.txt" % (d.filename, d.revision_display())
|
||||
|
@ -960,7 +960,7 @@ class ExpireLastCallTestCase(django.test.TestCase):
|
|||
drafts = get_expired_last_calls()
|
||||
self.assertEquals(len(drafts), 1)
|
||||
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
comments_before = draft.idinternal.comments().count()
|
||||
|
||||
expire_last_call(drafts[0])
|
||||
|
@ -968,8 +968,8 @@ class ExpireLastCallTestCase(django.test.TestCase):
|
|||
draft = InternetDraft.objects.get(filename="draft-ietf-mipshop-pfmipv6")
|
||||
self.assertEquals(draft.idinternal.cur_state.document_state_id, IDState.WAITING_FOR_WRITEUP)
|
||||
self.assertEquals(draft.idinternal.comments().count(), comments_before + 1)
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("Last Call Expired" in mail_outbox[-1]["Subject"])
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("Last Call Expired" in outbox[-1]["Subject"])
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -48,8 +48,8 @@ from redesign.group.models import *
|
|||
from redesign.person.models import *
|
||||
from ietf.iesg.models import TelechatDates
|
||||
from ietf.utils.test_utils import SimpleUrlTestCase, RealDatabaseTest, login_testing_unauthorized
|
||||
from ietf.utils.test_runner import mail_outbox
|
||||
from ietf.utils.test_data import make_test_data
|
||||
from ietf.utils.mail import outbox
|
||||
|
||||
class IdRfcUrlTestCase(SimpleUrlTestCase):
|
||||
def testUrls(self):
|
||||
|
@ -92,7 +92,7 @@ class ChangeStateTestCase(django.test.TestCase):
|
|||
|
||||
# change state
|
||||
events_before = draft.docevent_set.count()
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
r = self.client.post(url, dict(state="review-e"))
|
||||
self.assertEquals(r.status_code, 302)
|
||||
|
@ -101,9 +101,9 @@ class ChangeStateTestCase(django.test.TestCase):
|
|||
self.assertEquals(draft.iesg_state_id, "review-e")
|
||||
self.assertEquals(draft.docevent_set.count(), events_before + 1)
|
||||
self.assertTrue("State changed" in draft.docevent_set.all()[0].desc)
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 2)
|
||||
self.assertTrue("State Update Notice" in mail_outbox[-2]['Subject'])
|
||||
self.assertTrue(draft.name in mail_outbox[-1]['Subject'])
|
||||
self.assertEquals(len(outbox), mailbox_before + 2)
|
||||
self.assertTrue("State Update Notice" in outbox[-2]['Subject'])
|
||||
self.assertTrue(draft.name in outbox[-1]['Subject'])
|
||||
|
||||
|
||||
# check that we got a previous state now
|
||||
|
@ -121,7 +121,7 @@ class ChangeStateTestCase(django.test.TestCase):
|
|||
self.client.login(remote_user="secretary")
|
||||
url = urlreverse('doc_change_state', kwargs=dict(name=draft.name))
|
||||
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
self.assertTrue(not draft.latest_event(type="changed_ballot_writeup_text"))
|
||||
r = self.client.post(url, dict(state="lc-req"))
|
||||
|
@ -147,8 +147,8 @@ class ChangeStateTestCase(django.test.TestCase):
|
|||
self.assertTrue("Technical Summary" in e.text)
|
||||
|
||||
# mail notice
|
||||
self.assertTrue(len(mail_outbox) > mailbox_before)
|
||||
self.assertTrue("Last Call:" in mail_outbox[-1]['Subject'])
|
||||
self.assertTrue(len(outbox) > mailbox_before)
|
||||
self.assertTrue("Last Call:" in outbox[-1]['Subject'])
|
||||
|
||||
# comment
|
||||
self.assertTrue("Last call was requested" in draft.latest_event().desc)
|
||||
|
@ -180,7 +180,7 @@ class EditInfoTestCase(django.test.TestCase):
|
|||
|
||||
# edit info
|
||||
events_before = draft.docevent_set.count()
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
new_ad = Person.objects.get(name="Ad No1")
|
||||
|
||||
|
@ -202,8 +202,8 @@ class EditInfoTestCase(django.test.TestCase):
|
|||
self.assertEquals(draft.note, "New note")
|
||||
self.assertTrue(not draft.latest_event(TelechatDocEvent, type="telechat_date"))
|
||||
self.assertEquals(draft.docevent_set.count(), events_before + 4)
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue(draft.name in mail_outbox[-1]['Subject'])
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue(draft.name in outbox[-1]['Subject'])
|
||||
|
||||
def test_edit_telechat_date(self):
|
||||
draft = make_test_data()
|
||||
|
@ -266,7 +266,7 @@ class EditInfoTestCase(django.test.TestCase):
|
|||
|
||||
# add
|
||||
events_before = draft.docevent_set.count()
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
ad = Person.objects.get(name="Aread Irector")
|
||||
|
||||
|
@ -291,7 +291,7 @@ class EditInfoTestCase(django.test.TestCase):
|
|||
self.assertEquals(draft.docevent_set.count(), events_before + 4)
|
||||
events = list(draft.docevent_set.order_by('time', 'id'))
|
||||
self.assertEquals(events[-4].type, "started_iesg_process")
|
||||
self.assertEquals(len(mail_outbox), mailbox_before)
|
||||
self.assertEquals(len(outbox), mailbox_before)
|
||||
|
||||
|
||||
class ResurrectTestCase(django.test.TestCase):
|
||||
|
@ -315,7 +315,7 @@ class ResurrectTestCase(django.test.TestCase):
|
|||
|
||||
# request resurrect
|
||||
events_before = draft.docevent_set.count()
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
r = self.client.post(url, dict())
|
||||
self.assertEquals(r.status_code, 302)
|
||||
|
@ -326,8 +326,8 @@ class ResurrectTestCase(django.test.TestCase):
|
|||
self.assertTrue(e)
|
||||
self.assertEquals(e.by, Person.objects.get(name="Aread Irector"))
|
||||
self.assertTrue("Resurrection" in e.desc)
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("Resurrection" in mail_outbox[-1]['Subject'])
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("Resurrection" in outbox[-1]['Subject'])
|
||||
|
||||
def test_resurrect(self):
|
||||
draft = make_test_data()
|
||||
|
@ -349,7 +349,7 @@ class ResurrectTestCase(django.test.TestCase):
|
|||
|
||||
# request resurrect
|
||||
events_before = draft.docevent_set.count()
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
r = self.client.post(url, dict())
|
||||
self.assertEquals(r.status_code, 302)
|
||||
|
@ -358,7 +358,7 @@ class ResurrectTestCase(django.test.TestCase):
|
|||
self.assertEquals(draft.docevent_set.count(), events_before + 1)
|
||||
self.assertEquals(draft.latest_event().type, "completed_resurrect")
|
||||
self.assertEquals(draft.state_id, "active")
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
|
||||
class AddCommentTestCase(django.test.TestCase):
|
||||
fixtures = ['names']
|
||||
|
@ -376,7 +376,7 @@ class AddCommentTestCase(django.test.TestCase):
|
|||
|
||||
# request resurrect
|
||||
events_before = draft.docevent_set.count()
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
r = self.client.post(url, dict(comment="This is a test."))
|
||||
self.assertEquals(r.status_code, 302)
|
||||
|
@ -384,9 +384,9 @@ class AddCommentTestCase(django.test.TestCase):
|
|||
self.assertEquals(draft.docevent_set.count(), events_before + 1)
|
||||
self.assertEquals("This is a test.", draft.latest_event().desc)
|
||||
self.assertEquals("added_comment", draft.latest_event().type)
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("updated" in mail_outbox[-1]['Subject'])
|
||||
self.assertTrue(draft.name in mail_outbox[-1]['Subject'])
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("updated" in outbox[-1]['Subject'])
|
||||
self.assertTrue(draft.name in outbox[-1]['Subject'])
|
||||
|
||||
class EditPositionTestCase(django.test.TestCase):
|
||||
fixtures = ['names']
|
||||
|
@ -498,13 +498,13 @@ class EditPositionTestCase(django.test.TestCase):
|
|||
self.assertTrue(len(q('form input[name="cc"]')) > 0)
|
||||
|
||||
# send
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
r = self.client.post(url, dict(cc="test@example.com", cc_state_change="1"))
|
||||
self.assertEquals(r.status_code, 302)
|
||||
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
m = mail_outbox[-1]
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
m = outbox[-1]
|
||||
self.assertTrue("COMMENT" in m['Subject'])
|
||||
self.assertTrue(draft.name in m['Subject'])
|
||||
self.assertTrue("Test!" in str(m))
|
||||
|
@ -526,7 +526,7 @@ class DeferBallotTestCase(django.test.TestCase):
|
|||
self.assertEquals(r.status_code, 200)
|
||||
|
||||
# defer
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
r = self.client.post(url, dict())
|
||||
self.assertEquals(r.status_code, 302)
|
||||
|
@ -534,10 +534,10 @@ class DeferBallotTestCase(django.test.TestCase):
|
|||
draft = Document.objects.get(name=draft.name)
|
||||
self.assertEquals(draft.iesg_state_id, "defer")
|
||||
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 2)
|
||||
self.assertTrue("State Update" in mail_outbox[-2]['Subject'])
|
||||
self.assertTrue("Deferred" in mail_outbox[-1]['Subject'])
|
||||
self.assertTrue(draft.file_tag() in mail_outbox[-1]['Subject'])
|
||||
self.assertEquals(len(outbox), mailbox_before + 2)
|
||||
self.assertTrue("State Update" in outbox[-2]['Subject'])
|
||||
self.assertTrue("Deferred" in outbox[-1]['Subject'])
|
||||
self.assertTrue(draft.file_tag() in outbox[-1]['Subject'])
|
||||
|
||||
def test_undefer_ballot(self):
|
||||
draft = make_test_data()
|
||||
|
@ -610,7 +610,7 @@ class BallotWriteupsTestCase(django.test.TestCase):
|
|||
r = self.client.post(url, dict(regenerate_last_call_text="1"))
|
||||
self.assertEquals(r.status_code, 200)
|
||||
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
# send
|
||||
r = self.client.post(url, dict(
|
||||
|
@ -618,9 +618,9 @@ class BallotWriteupsTestCase(django.test.TestCase):
|
|||
send_last_call_request="1"))
|
||||
draft = Document.objects.get(name=draft.name)
|
||||
self.assertEquals(draft.iesg_state_id, "lc-req")
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 3)
|
||||
self.assertTrue("Last Call" in mail_outbox[-1]['Subject'])
|
||||
self.assertTrue(draft.name in mail_outbox[-1]['Subject'])
|
||||
self.assertEquals(len(outbox), mailbox_before + 3)
|
||||
self.assertTrue("Last Call" in outbox[-1]['Subject'])
|
||||
self.assertTrue(draft.name in outbox[-1]['Subject'])
|
||||
|
||||
def test_edit_ballot_writeup(self):
|
||||
draft = make_test_data()
|
||||
|
@ -681,7 +681,7 @@ class BallotWriteupsTestCase(django.test.TestCase):
|
|||
e.text = "The document has been approved."
|
||||
e.save()
|
||||
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
r = self.client.post(url, dict(
|
||||
ballot_writeup="This is a test.",
|
||||
|
@ -690,8 +690,8 @@ class BallotWriteupsTestCase(django.test.TestCase):
|
|||
draft = Document.objects.get(name=draft.name)
|
||||
|
||||
self.assertTrue(draft.latest_event(type="sent_ballot_announcement"))
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 2)
|
||||
issue_email = mail_outbox[-2]
|
||||
self.assertEquals(len(outbox), mailbox_before + 2)
|
||||
issue_email = outbox[-2]
|
||||
self.assertTrue("Evaluation:" in issue_email['Subject'])
|
||||
self.assertTrue("comment1" not in str(issue_email))
|
||||
self.assertTrue("comment2" in str(issue_email))
|
||||
|
@ -753,17 +753,17 @@ class ApproveBallotTestCase(django.test.TestCase):
|
|||
self.assertEquals(len(q('.announcement pre:contains("Subject: Protocol Action")')), 1)
|
||||
|
||||
# approve
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
r = self.client.post(url, dict())
|
||||
self.assertEquals(r.status_code, 302)
|
||||
|
||||
draft = Document.objects.get(name=draft.name)
|
||||
self.assertEquals(draft.iesg_state_id, "ann")
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 4)
|
||||
self.assertTrue("Protocol Action" in mail_outbox[-2]['Subject'])
|
||||
self.assertEquals(len(outbox), mailbox_before + 4)
|
||||
self.assertTrue("Protocol Action" in outbox[-2]['Subject'])
|
||||
# the IANA copy
|
||||
self.assertTrue("Protocol Action" in mail_outbox[-1]['Subject'])
|
||||
self.assertTrue("Protocol Action" in outbox[-1]['Subject'])
|
||||
|
||||
def test_disapprove_ballot(self):
|
||||
draft = make_test_data()
|
||||
|
@ -774,15 +774,15 @@ class ApproveBallotTestCase(django.test.TestCase):
|
|||
login_testing_unauthorized(self, "secretary", url)
|
||||
|
||||
# disapprove (the Martians aren't going to be happy)
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
r = self.client.post(url, dict())
|
||||
self.assertEquals(r.status_code, 302)
|
||||
|
||||
draft = Document.objects.get(name=draft.name)
|
||||
self.assertEquals(draft.iesg_state_id, "dead")
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 3)
|
||||
self.assertTrue("NOT be published" in str(mail_outbox[-1]))
|
||||
self.assertEquals(len(outbox), mailbox_before + 3)
|
||||
self.assertTrue("NOT be published" in str(outbox[-1]))
|
||||
|
||||
class MakeLastCallTestCase(django.test.TestCase):
|
||||
fixtures = ['names']
|
||||
|
@ -802,7 +802,7 @@ class MakeLastCallTestCase(django.test.TestCase):
|
|||
self.assertEquals(len(q('input[name=last_call_sent_date]')), 1)
|
||||
|
||||
# make last call
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
expire_date = q('input[name=last_call_expiration_date]')[0].get("value")
|
||||
|
||||
|
@ -815,11 +815,11 @@ class MakeLastCallTestCase(django.test.TestCase):
|
|||
draft = Document.objects.get(name=draft.name)
|
||||
self.assertEquals(draft.iesg_state.slug, "lc")
|
||||
self.assertEquals(draft.latest_event(LastCallDocEvent, "sent_last_call").expires.strftime("%Y-%m-%d"), expire_date)
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 4)
|
||||
self.assertEquals(len(outbox), mailbox_before + 4)
|
||||
|
||||
self.assertTrue("Last Call" in mail_outbox[-4]['Subject'])
|
||||
self.assertTrue("Last Call" in outbox[-4]['Subject'])
|
||||
# the IANA copy
|
||||
self.assertTrue("Last Call" in mail_outbox[-3]['Subject'])
|
||||
self.assertTrue("Last Call" in outbox[-3]['Subject'])
|
||||
|
||||
class ExpireIDsTestCase(django.test.TestCase):
|
||||
fixtures = ['names']
|
||||
|
@ -881,13 +881,13 @@ class ExpireIDsTestCase(django.test.TestCase):
|
|||
self.assertEquals(len(list(get_soon_to_expire_ids(14))), 1)
|
||||
|
||||
# test send warning
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
send_expire_warning_for_id(draft)
|
||||
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("aread@ietf.org" in str(mail_outbox[-1])) # author
|
||||
self.assertTrue("wgchairman@ietf.org" in str(mail_outbox[-1]))
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("aread@ietf.org" in str(outbox[-1])) # author
|
||||
self.assertTrue("wgchairman@ietf.org" in str(outbox[-1]))
|
||||
|
||||
def test_expire_ids(self):
|
||||
from ietf.idrfc.expire import get_expired_ids, send_expire_notice_for_id, expire_id, INTERNET_DRAFT_DAYS_TO_EXPIRE
|
||||
|
@ -917,12 +917,12 @@ class ExpireIDsTestCase(django.test.TestCase):
|
|||
self.assertEquals(len(list(get_expired_ids())), 1)
|
||||
|
||||
# test notice
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
|
||||
send_expire_notice_for_id(draft)
|
||||
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("expired" in mail_outbox[-1]["Subject"])
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("expired" in outbox[-1]["Subject"])
|
||||
|
||||
# test expiry
|
||||
txt = "%s-%s.txt" % (draft.name, draft.rev)
|
||||
|
@ -1061,7 +1061,7 @@ class ExpireLastCallTestCase(django.test.TestCase):
|
|||
self.assertEquals(len(drafts), 1)
|
||||
|
||||
# expire it
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
events_before = draft.docevent_set.count()
|
||||
|
||||
expire_last_call(drafts[0])
|
||||
|
@ -1069,8 +1069,8 @@ class ExpireLastCallTestCase(django.test.TestCase):
|
|||
draft = Document.objects.get(name=draft.name)
|
||||
self.assertEquals(draft.iesg_state.slug, "writeupw")
|
||||
self.assertEquals(draft.docevent_set.count(), events_before + 1)
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("Last Call Expired" in mail_outbox[-1]["Subject"])
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("Last Call Expired" in outbox[-1]["Subject"])
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ from StringIO import StringIO
|
|||
from pyquery import PyQuery
|
||||
|
||||
from ietf.utils.test_utils import login_testing_unauthorized
|
||||
from ietf.utils.test_runner import mail_outbox
|
||||
from ietf.utils.test_data import make_test_data
|
||||
from ietf.utils.mail import outbox
|
||||
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
from redesign.person.models import Person, Email
|
||||
|
@ -39,7 +39,7 @@ class EditStreamInfoTestCase(django.test.TestCase):
|
|||
self.assertEquals(len(q('form select[name="wg"] option')), 1) # we can only select "mars"
|
||||
|
||||
# adopt in mars WG
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
events_before = draft.docevent_set.count()
|
||||
r = self.client.post(url,
|
||||
dict(comment="some comment",
|
||||
|
@ -51,10 +51,10 @@ class EditStreamInfoTestCase(django.test.TestCase):
|
|||
self.assertEquals(draft.group.acronym, "mars")
|
||||
self.assertEquals(draft.stream_id, "ietf")
|
||||
self.assertEquals(draft.docevent_set.count() - events_before, 4)
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("state changed" in mail_outbox[-1]["Subject"].lower())
|
||||
self.assertTrue("wgchairman@ietf.org" in unicode(mail_outbox[-1]))
|
||||
self.assertTrue("wgdelegate@ietf.org" in unicode(mail_outbox[-1]))
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("state changed" in outbox[-1]["Subject"].lower())
|
||||
self.assertTrue("wgchairman@ietf.org" in unicode(outbox[-1]))
|
||||
self.assertTrue("wgdelegate@ietf.org" in unicode(outbox[-1]))
|
||||
|
||||
def test_set_tags(self):
|
||||
draft = make_test_data()
|
||||
|
@ -75,7 +75,7 @@ class EditStreamInfoTestCase(django.test.TestCase):
|
|||
self.assertEquals(len(q('form input[type=submit][name=only_tags]')), 1)
|
||||
|
||||
# set tags
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
events_before = draft.docevent_set.count()
|
||||
r = self.client.post(url,
|
||||
dict(comment="some comment",
|
||||
|
@ -93,11 +93,11 @@ class EditStreamInfoTestCase(django.test.TestCase):
|
|||
self.assertEquals(draft.tags.filter(slug="need-aut").count(), 1)
|
||||
self.assertEquals(draft.tags.filter(slug="sheph-u").count(), 1)
|
||||
self.assertEquals(draft.docevent_set.count() - events_before, 2)
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("tags changed" in mail_outbox[-1]["Subject"].lower())
|
||||
self.assertTrue("wgchairman@ietf.org" in unicode(mail_outbox[-1]))
|
||||
self.assertTrue("wgdelegate@ietf.org" in unicode(mail_outbox[-1]))
|
||||
self.assertTrue("plain@example.com" in unicode(mail_outbox[-1]))
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("tags changed" in outbox[-1]["Subject"].lower())
|
||||
self.assertTrue("wgchairman@ietf.org" in unicode(outbox[-1]))
|
||||
self.assertTrue("wgdelegate@ietf.org" in unicode(outbox[-1]))
|
||||
self.assertTrue("plain@example.com" in unicode(outbox[-1]))
|
||||
|
||||
def test_set_state(self):
|
||||
draft = make_test_data()
|
||||
|
@ -117,7 +117,7 @@ class EditStreamInfoTestCase(django.test.TestCase):
|
|||
|
||||
# set state
|
||||
new_state = State.objects.get(type="draft-stream-%s" % draft.stream_id, slug="parked")
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
events_before = draft.docevent_set.count()
|
||||
r = self.client.post(url,
|
||||
dict(comment="some comment",
|
||||
|
@ -134,10 +134,10 @@ class EditStreamInfoTestCase(django.test.TestCase):
|
|||
self.assertEquals(len(reminder), 1)
|
||||
due = datetime.datetime.now() + datetime.timedelta(weeks=10)
|
||||
self.assertTrue(due - datetime.timedelta(days=1) <= reminder[0].due <= due + datetime.timedelta(days=1))
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("state changed" in mail_outbox[-1]["Subject"].lower())
|
||||
self.assertTrue("wgchairman@ietf.org" in unicode(mail_outbox[-1]))
|
||||
self.assertTrue("wgdelegate@ietf.org" in unicode(mail_outbox[-1]))
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("state changed" in outbox[-1]["Subject"].lower())
|
||||
self.assertTrue("wgchairman@ietf.org" in unicode(outbox[-1]))
|
||||
self.assertTrue("wgdelegate@ietf.org" in unicode(outbox[-1]))
|
||||
|
||||
def test_set_stream(self):
|
||||
draft = make_test_data()
|
||||
|
@ -152,7 +152,7 @@ class EditStreamInfoTestCase(django.test.TestCase):
|
|||
self.assertEquals(len(q('select[name=stream]')), 1)
|
||||
|
||||
# set state
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
events_before = draft.docevent_set.count()
|
||||
r = self.client.post(url,
|
||||
dict(comment="some comment",
|
||||
|
@ -163,10 +163,10 @@ class EditStreamInfoTestCase(django.test.TestCase):
|
|||
draft = Document.objects.get(pk=draft.pk)
|
||||
self.assertEquals(draft.stream_id, "irtf")
|
||||
self.assertEquals(draft.docevent_set.count() - events_before, 2)
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("stream changed" in mail_outbox[-1]["Subject"].lower())
|
||||
self.assertTrue("wgchairman@ietf.org" in unicode(mail_outbox[-1]))
|
||||
self.assertTrue("wgdelegate@ietf.org" in unicode(mail_outbox[-1]))
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("stream changed" in outbox[-1]["Subject"].lower())
|
||||
self.assertTrue("wgchairman@ietf.org" in unicode(outbox[-1]))
|
||||
self.assertTrue("wgdelegate@ietf.org" in unicode(outbox[-1]))
|
||||
|
||||
if not settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
# the above tests only work with the new schema
|
||||
|
|
|
@ -35,7 +35,7 @@ import unittest
|
|||
from django.test.client import Client
|
||||
from django.conf import settings
|
||||
from ietf.utils.test_utils import SimpleUrlTestCase, RealDatabaseTest, canonicalize_feed, canonicalize_sitemap
|
||||
import ietf.utils.test_runner as test_runner
|
||||
from ietf.utils.mail import outbox, empty_outbox
|
||||
|
||||
class IprUrlTestCase(SimpleUrlTestCase):
|
||||
def testUrls(self):
|
||||
|
@ -77,12 +77,12 @@ class NewIprTestCase(unittest.TestCase,RealDatabaseTest):
|
|||
|
||||
def testNewSpecific(self):
|
||||
print " Testing IPR disclosure submission"
|
||||
test_runner.mail_outbox = []
|
||||
empty_outbox
|
||||
c = Client()
|
||||
response = c.post('/ipr/new-specific/', self.SPECIFIC_DISCLOSURE)
|
||||
self.assertEquals(response.status_code, 200)
|
||||
self.assert_("Your IPR disclosure has been submitted" in response.content)
|
||||
self.assertEquals(len(test_runner.mail_outbox), 1)
|
||||
self.assertEquals(len(outbox), 1)
|
||||
print "OK (1 email found in test outbox)"
|
||||
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ from StringIO import StringIO
|
|||
from pyquery import PyQuery
|
||||
|
||||
from ietf.utils.test_utils import SimpleUrlTestCase, canonicalize_feed, canonicalize_sitemap, login_testing_unauthorized
|
||||
from ietf.utils.test_runner import mail_outbox
|
||||
from ietf.utils.test_data import make_test_data
|
||||
from ietf.utils.mail import outbox
|
||||
|
||||
class LiaisonsUrlTestCase(SimpleUrlTestCase):
|
||||
def testUrls(self):
|
||||
|
@ -149,14 +149,14 @@ class LiaisonManagementTestCase(django.test.TestCase):
|
|||
self.assertEquals(len(q('form input[name=do_approval]')), 1)
|
||||
|
||||
# approve
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
r = self.client.post(url, dict(do_approval="1"))
|
||||
self.assertEquals(r.status_code, 302)
|
||||
|
||||
liaison = LiaisonStatement.objects.get(id=liaison.id)
|
||||
self.assertTrue(liaison.approved)
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("Liaison Statement" in mail_outbox[-1]["Subject"])
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("Liaison Statement" in outbox[-1]["Subject"])
|
||||
|
||||
def test_edit_liaison(self):
|
||||
make_test_data()
|
||||
|
@ -230,7 +230,7 @@ class LiaisonManagementTestCase(django.test.TestCase):
|
|||
self.assertEquals(len(q('form textarea[name=body]')), 1)
|
||||
|
||||
# add new
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
test_file = StringIO("hello world")
|
||||
test_file.name = "unnamed"
|
||||
from_group = Group.objects.filter(type="sdo")[0]
|
||||
|
@ -283,8 +283,8 @@ class LiaisonManagementTestCase(django.test.TestCase):
|
|||
test_file.seek(0)
|
||||
self.assertEquals(written_content, test_file.read())
|
||||
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("Liaison Statement" in mail_outbox[-1]["Subject"])
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("Liaison Statement" in outbox[-1]["Subject"])
|
||||
|
||||
def test_add_outgoing_liaison(self):
|
||||
make_test_data()
|
||||
|
@ -300,7 +300,7 @@ class LiaisonManagementTestCase(django.test.TestCase):
|
|||
self.assertEquals(len(q('form textarea[name=body]')), 1)
|
||||
|
||||
# add new
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
test_file = StringIO("hello world")
|
||||
test_file.name = "unnamed"
|
||||
from_group = Group.objects.get(acronym="mars")
|
||||
|
@ -357,8 +357,8 @@ class LiaisonManagementTestCase(django.test.TestCase):
|
|||
test_file.seek(0)
|
||||
self.assertEquals(written_content, test_file.read())
|
||||
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("Liaison Statement" in mail_outbox[-1]["Subject"])
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("Liaison Statement" in outbox[-1]["Subject"])
|
||||
|
||||
# try adding statement to non-predefined organization
|
||||
r = self.client.post(url,
|
||||
|
@ -391,10 +391,10 @@ class LiaisonManagementTestCase(django.test.TestCase):
|
|||
|
||||
from ietf.liaisons.mails import send_sdo_reminder
|
||||
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
send_sdo_reminder(Group.objects.filter(type="sdo")[0])
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("authorized individuals" in mail_outbox[-1]["Subject"])
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("authorized individuals" in outbox[-1]["Subject"])
|
||||
|
||||
def test_send_liaison_deadline_reminder(self):
|
||||
make_test_data()
|
||||
|
@ -405,18 +405,18 @@ class LiaisonManagementTestCase(django.test.TestCase):
|
|||
|
||||
l = LiaisonDetail.objects.all()[0]
|
||||
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
possibly_send_deadline_reminder(l)
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("deadline" in mail_outbox[-1]["Subject"])
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("deadline" in outbox[-1]["Subject"])
|
||||
|
||||
# try pushing the deadline
|
||||
l.deadline = l.deadline + datetime.timedelta(days=30)
|
||||
l.save()
|
||||
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
possibly_send_deadline_reminder(l)
|
||||
self.assertEquals(len(mail_outbox), mailbox_before)
|
||||
self.assertEquals(len(outbox), mailbox_before)
|
||||
|
||||
|
||||
if not settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
|
|
|
@ -8,8 +8,8 @@ from StringIO import StringIO
|
|||
from pyquery import PyQuery
|
||||
|
||||
from ietf.utils.test_utils import login_testing_unauthorized
|
||||
from ietf.utils.test_runner import mail_outbox
|
||||
from ietf.utils.test_data import make_test_data
|
||||
from ietf.utils.mail import outbox
|
||||
|
||||
from redesign.person.models import Person, Email
|
||||
from redesign.group.models import Group, Role
|
||||
|
@ -103,14 +103,14 @@ class SubmitTestCase(django.test.TestCase):
|
|||
supply_submitter_url = self.do_submission(name, rev)
|
||||
|
||||
# supply submitter info, then draft should be in and ready for approval
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
r = self.supply_submitter(name, supply_submitter_url)
|
||||
|
||||
self.assertEquals(r.status_code, 302)
|
||||
status_url = r["Location"]
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("New draft waiting for approval" in mail_outbox[-1]["Subject"])
|
||||
self.assertTrue(name in mail_outbox[-1]["Subject"])
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("New draft waiting for approval" in outbox[-1]["Subject"])
|
||||
self.assertTrue(name in outbox[-1]["Subject"])
|
||||
|
||||
# as chair of WG, we should see approval button
|
||||
self.client.login(remote_user="marschairman")
|
||||
|
@ -122,7 +122,7 @@ class SubmitTestCase(django.test.TestCase):
|
|||
self.assertEquals(len(approve_submit), 1)
|
||||
|
||||
# approve submission
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
approve_url = approve_submit.parents("form").attr("action")
|
||||
r = self.client.post(approve_url, dict())
|
||||
self.assertEquals(r.status_code, 302)
|
||||
|
@ -140,12 +140,12 @@ class SubmitTestCase(django.test.TestCase):
|
|||
self.assertEquals(draft.authors.count(), 1)
|
||||
self.assertEquals(draft.authors.all()[0].get_name(), "Test Name")
|
||||
self.assertEquals(draft.authors.all()[0].address, "testname@example.com")
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 2)
|
||||
self.assertTrue((u"I-D Action: %s" % name) in mail_outbox[-2]["Subject"])
|
||||
self.assertTrue("Test Name" in unicode(mail_outbox[-2]))
|
||||
self.assertTrue("New Version Notification" in mail_outbox[-1]["Subject"])
|
||||
self.assertTrue(name in unicode(mail_outbox[-1]))
|
||||
self.assertTrue("mars" in unicode(mail_outbox[-1]))
|
||||
self.assertEquals(len(outbox), mailbox_before + 2)
|
||||
self.assertTrue((u"I-D Action: %s" % name) in outbox[-2]["Subject"])
|
||||
self.assertTrue("Test Name" in unicode(outbox[-2]))
|
||||
self.assertTrue("New Version Notification" in outbox[-1]["Subject"])
|
||||
self.assertTrue(name in unicode(outbox[-1]))
|
||||
self.assertTrue("mars" in unicode(outbox[-1]))
|
||||
|
||||
def test_submit_existing(self):
|
||||
# submit new revision of existing -> supply submitter info -> confirm
|
||||
|
@ -165,14 +165,14 @@ class SubmitTestCase(django.test.TestCase):
|
|||
supply_submitter_url = self.do_submission(name, rev)
|
||||
|
||||
# supply submitter info, then we get a confirmation email
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
r = self.supply_submitter(name, supply_submitter_url)
|
||||
|
||||
self.assertEquals(r.status_code, 200)
|
||||
self.assertTrue("Your submission is pending email authentication" in r.content)
|
||||
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
confirmation = mail_outbox[-1]
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
confirmation = outbox[-1]
|
||||
self.assertTrue("Confirmation for" in confirmation["Subject"])
|
||||
self.assertTrue(name in confirmation["Subject"])
|
||||
|
||||
|
@ -191,7 +191,7 @@ class SubmitTestCase(django.test.TestCase):
|
|||
self.assertEquals(len(q('input[type=submit][value=Auto-Post]')), 1)
|
||||
|
||||
# confirm
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
r = self.client.post(confirm_url)
|
||||
self.assertEquals(r.status_code, 200)
|
||||
self.assertTrue('Authorization key accepted' in r.content)
|
||||
|
@ -209,17 +209,17 @@ class SubmitTestCase(django.test.TestCase):
|
|||
self.assertEquals(draft.authors.count(), 1)
|
||||
self.assertEquals(draft.authors.all()[0].get_name(), "Test Name")
|
||||
self.assertEquals(draft.authors.all()[0].address, "testname@example.com")
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 3)
|
||||
self.assertTrue((u"I-D Action: %s" % name) in mail_outbox[-3]["Subject"])
|
||||
self.assertTrue("Test Name" in unicode(mail_outbox[-3]))
|
||||
self.assertTrue("New Version Notification" in mail_outbox[-2]["Subject"])
|
||||
self.assertTrue(name in unicode(mail_outbox[-2]))
|
||||
self.assertTrue("mars" in unicode(mail_outbox[-2]))
|
||||
self.assertTrue(draft.ad.email_address().address in unicode(mail_outbox[-2]))
|
||||
self.assertTrue(ballot_position.ad.email_address().address in unicode(mail_outbox[-2]))
|
||||
self.assertTrue("New Version Notification" in mail_outbox[-1]["Subject"])
|
||||
self.assertTrue(name in unicode(mail_outbox[-1]))
|
||||
self.assertTrue("mars" in unicode(mail_outbox[-1]))
|
||||
self.assertEquals(len(outbox), mailbox_before + 3)
|
||||
self.assertTrue((u"I-D Action: %s" % name) in outbox[-3]["Subject"])
|
||||
self.assertTrue("Test Name" in unicode(outbox[-3]))
|
||||
self.assertTrue("New Version Notification" in outbox[-2]["Subject"])
|
||||
self.assertTrue(name in unicode(outbox[-2]))
|
||||
self.assertTrue("mars" in unicode(outbox[-2]))
|
||||
self.assertTrue(draft.ad.email_address().address in unicode(outbox[-2]))
|
||||
self.assertTrue(ballot_position.ad.email_address().address in unicode(outbox[-2]))
|
||||
self.assertTrue("New Version Notification" in outbox[-1]["Subject"])
|
||||
self.assertTrue(name in unicode(outbox[-1]))
|
||||
self.assertTrue("mars" in unicode(outbox[-1]))
|
||||
|
||||
def test_cancel_submission(self):
|
||||
# submit -> cancel
|
||||
|
@ -270,7 +270,7 @@ class SubmitTestCase(django.test.TestCase):
|
|||
self.assertEquals(len(q('input[name=title]')), 1)
|
||||
|
||||
# edit
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
creation_date = datetime.date.today() - datetime.timedelta(days=-3)
|
||||
r = self.client.post(edit_url,
|
||||
dict(title="some title",
|
||||
|
@ -305,9 +305,9 @@ class SubmitTestCase(django.test.TestCase):
|
|||
self.assertEquals(authors.get(author_order=2).first_name, "Person 2")
|
||||
self.assertEquals(authors.get(author_order=2).email_address, "person2@example.com")
|
||||
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("Manual Post Requested" in mail_outbox[-1]["Subject"])
|
||||
self.assertTrue(name in mail_outbox[-1]["Subject"])
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("Manual Post Requested" in outbox[-1]["Subject"])
|
||||
self.assertTrue(name in outbox[-1]["Subject"])
|
||||
|
||||
def test_request_full_url(self):
|
||||
# submit -> request full URL to be sent
|
||||
|
@ -331,13 +331,13 @@ class SubmitTestCase(django.test.TestCase):
|
|||
request_url = request_button.parents("form").attr("action")
|
||||
|
||||
# request URL to be sent
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
r = self.client.post(request_url)
|
||||
self.assertEquals(r.status_code, 200)
|
||||
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 1)
|
||||
self.assertTrue("Full URL for managing submission" in mail_outbox[-1]["Subject"])
|
||||
self.assertTrue(name in mail_outbox[-1]["Subject"])
|
||||
self.assertEquals(len(outbox), mailbox_before + 1)
|
||||
self.assertTrue("Full URL for managing submission" in outbox[-1]["Subject"])
|
||||
self.assertTrue(name in outbox[-1]["Subject"])
|
||||
|
||||
|
||||
if not settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
|
|
|
@ -58,7 +58,7 @@ def send_smtp(msg, bcc=None):
|
|||
log("No addressees for email from '%s', subject '%s'. Nothing sent." % (frm, msg.get('Subject', '[no subject]')))
|
||||
else:
|
||||
if test_mode:
|
||||
outbox.append((msg, to, msg.as_string()))
|
||||
outbox.append(msg)
|
||||
return
|
||||
server = None
|
||||
try:
|
||||
|
|
|
@ -35,8 +35,9 @@
|
|||
import socket
|
||||
from django.conf import settings
|
||||
from django.template import TemplateDoesNotExist
|
||||
import ietf.utils.mail
|
||||
from ietf.utils.mail import outbox as outbox
|
||||
|
||||
mail_outbox = []
|
||||
loaded_templates = set()
|
||||
test_database_name = None
|
||||
old_destroy = None
|
||||
|
@ -58,10 +59,6 @@ def safe_destroy_0_1(*args, **kwargs):
|
|||
settings.DATABASE_NAME = test_database_name
|
||||
return old_destroy(*args, **kwargs)
|
||||
|
||||
def test_send_smtp(msg, bcc=None):
|
||||
global mail_outbox
|
||||
mail_outbox.append(msg)
|
||||
|
||||
def template_coverage_loader(template_name, dirs):
|
||||
loaded_templates.add(str(template_name))
|
||||
raise TemplateDoesNotExist
|
||||
|
@ -88,8 +85,6 @@ def run_tests(*args, **kwargs):
|
|||
# against the production database
|
||||
if socket.gethostname().startswith("core3"):
|
||||
raise EnvironmentError("Refusing to run tests on core3")
|
||||
import ietf.utils.mail
|
||||
ietf.utils.mail.send_smtp = test_send_smtp
|
||||
ietf.utils.mail.test_mode = True
|
||||
run_tests_1(*args, **kwargs)
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ from StringIO import StringIO
|
|||
from pyquery import PyQuery
|
||||
|
||||
from ietf.utils.test_utils import login_testing_unauthorized
|
||||
from ietf.utils.test_runner import mail_outbox
|
||||
from ietf.utils.test_data import make_test_data
|
||||
from ietf.utils.mail import outbox
|
||||
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
from redesign.person.models import Person, Email
|
||||
|
@ -66,13 +66,13 @@ class ManageDelegatesTestCase(django.test.TestCase):
|
|||
self.assertEquals(len(q('form input[type=submit][value*="Send email"]')), 1)
|
||||
|
||||
# we get back a warning and offer to send email, do that
|
||||
mailbox_before = len(mail_outbox)
|
||||
mailbox_before = len(outbox)
|
||||
r = self.client.post(url,
|
||||
dict(email="unknown@example.com",
|
||||
form_type="notexist"))
|
||||
self.assertEquals(r.status_code, 200)
|
||||
self.assertTrue("Email sent" in r.content)
|
||||
self.assertEquals(len(mail_outbox), mailbox_before + 3)
|
||||
self.assertEquals(len(outbox), mailbox_before + 3)
|
||||
|
||||
def test_add_delegate(self):
|
||||
make_test_data()
|
||||
|
|
Loading…
Reference in a new issue