* pwclient: add example scripts (eg, git post-commit hook) to online help
* pwclient: case-insensitive searches for author and project name
* changing primary email addresses for accounts
-* sed -i -e "s/\(assertEqual\)s/\1/g" $(git grep -l assertEquals)
- and all in: https://docs.python.org/2/library/unittest.html#deprecated-aliases
def testNoBundles(self):
response = self.client.get('/user/bundles/')
- self.failUnlessEqual(response.status_code, 200)
- self.failUnlessEqual(
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(
len(find_in_context(response.context, 'bundles')), 0)
def testSingleBundle(self):
bundle = Bundle(owner = self.user, project = defaults.project)
bundle.save()
response = self.client.get('/user/bundles/')
- self.failUnlessEqual(response.status_code, 200)
- self.failUnlessEqual(
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(
len(find_in_context(response.context, 'bundles')), 1)
def tearDown(self):
def testEmptyBundle(self):
response = self.client.get(bundle_url(self.bundle))
- self.failUnlessEqual(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
page = find_in_context(response.context, 'page')
- self.failUnlessEqual(len(page.object_list), 0)
+ self.assertEqual(len(page.object_list), 0)
def testNonEmptyBundle(self):
self.bundle.append_patch(self.patches[0])
response = self.client.get(bundle_url(self.bundle))
- self.failUnlessEqual(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
page = find_in_context(response.context, 'page')
- self.failUnlessEqual(len(page.object_list), 1)
+ self.assertEqual(len(page.object_list), 1)
def testBundleOrder(self):
for patch in self.patches:
for patch in self.patches:
next_pos = response.content.decode().find(patch.name)
# ensure that this patch is after the previous
- self.failUnless(next_pos > pos)
+ self.assertTrue(next_pos > pos)
pos = next_pos
# reorder and recheck
for patch in self.patches:
next_pos = response.content.decode().find(patch.name)
# ensure that this patch is now *before* the previous
- self.failUnless(next_pos < pos)
+ self.assertTrue(next_pos < pos)
pos = next_pos
class BundleUpdateTest(BundleTestBase):
form = response.context[formname]
if not form:
return
- self.assertEquals(form.errors, {})
+ self.assertEqual(form.errors, {})
def publicString(self, public):
if public:
count = 1)
bundle = Bundle.objects.get(name = newbundlename)
- self.failUnlessEqual(bundle.patches.count(), 1)
- self.failUnlessEqual(bundle.patches.all()[0], patch)
+ self.assertEqual(bundle.patches.count(), 1)
+ self.assertEqual(bundle.patches.all()[0], patch)
def testCreateNonEmptyBundleEmptyName(self):
newbundlename = 'testbundle-new'
status_code = 200)
# test that no new bundles are present
- self.failUnlessEqual(n_bundles, Bundle.objects.count())
+ self.assertEqual(n_bundles, Bundle.objects.count())
def testCreateDuplicateName(self):
newbundlename = 'testbundle-dup'
count = 1)
bundle = Bundle.objects.get(name = newbundlename)
- self.failUnlessEqual(bundle.patches.count(), 1)
- self.failUnlessEqual(bundle.patches.all()[0], patch)
+ self.assertEqual(bundle.patches.count(), 1)
+ self.assertEqual(bundle.patches.all()[0], patch)
response = self.client.post(
'/project/%s/list/' % defaults.project.linkname,
'Bundle %s created' % newbundlename)
bundle = Bundle.objects.get(name = newbundlename)
- self.failUnlessEqual(bundle.patches.count(), 1)
- self.failUnlessEqual(bundle.patches.all()[0], patch)
+ self.assertEqual(bundle.patches.count(), 1)
+ self.assertEqual(bundle.patches.all()[0], patch)
def testCreateWithExistingName(self):
newbundlename = self.bundle.name
'A bundle called %s already exists' % newbundlename)
count = Bundle.objects.count()
- self.failUnlessEqual(Bundle.objects.count(), 1)
+ self.assertEqual(Bundle.objects.count(), 1)
class BundleAddFromListTest(BundleTestBase):
def testAddToEmptyBundle(self):
self.assertContains(response, 'added to bundle %s' % self.bundle.name,
count = 1)
- self.failUnlessEqual(self.bundle.patches.count(), 1)
- self.failUnlessEqual(self.bundle.patches.all()[0], patch)
+ self.assertEqual(self.bundle.patches.count(), 1)
+ self.assertEqual(self.bundle.patches.all()[0], patch)
def testAddToNonEmptyBundle(self):
self.bundle.append_patch(self.patches[0])
self.assertContains(response, 'added to bundle %s' % self.bundle.name,
count = 1)
- self.failUnlessEqual(self.bundle.patches.count(), 2)
- self.failUnless(self.patches[0] in self.bundle.patches.all())
- self.failUnless(self.patches[1] in self.bundle.patches.all())
+ self.assertEqual(self.bundle.patches.count(), 2)
+ self.assertIn(self.patches[0], self.bundle.patches.all())
+ self.assertIn(self.patches[1], self.bundle.patches.all())
# check order
bps = [ BundlePatch.objects.get(bundle = self.bundle,
patch = self.patches[i]) \
for i in [0, 1] ]
- self.failUnless(bps[0].order < bps[1].order)
+ self.assertTrue(bps[0].order < bps[1].order)
def testAddDuplicate(self):
self.bundle.append_patch(self.patches[0])
self.assertContains(response, 'Patch '%s' already in bundle' \
% patch.name, count = 1, status_code = 200)
- self.assertEquals(count, self.bundle.patches.count())
+ self.assertEqual(count, self.bundle.patches.count())
def testAddNewAndDuplicate(self):
self.bundle.append_patch(self.patches[0])
self.assertContains(response, 'Patch '%s' added to bundle' \
% self.patches[1].name, count = 1,
status_code = 200)
- self.assertEquals(count + 1, self.bundle.patches.count())
+ self.assertEqual(count + 1, self.bundle.patches.count())
class BundleAddFromPatchTest(BundleTestBase):
def testAddToEmptyBundle(self):
'added to bundle "%s"' % self.bundle.name,
count = 1)
- self.failUnlessEqual(self.bundle.patches.count(), 1)
- self.failUnlessEqual(self.bundle.patches.all()[0], patch)
+ self.assertEqual(self.bundle.patches.count(), 1)
+ self.assertEqual(self.bundle.patches.all()[0], patch)
def testAddToNonEmptyBundle(self):
self.bundle.append_patch(self.patches[0])
'added to bundle "%s"' % self.bundle.name,
count = 1)
- self.failUnlessEqual(self.bundle.patches.count(), 2)
- self.failUnless(self.patches[0] in self.bundle.patches.all())
- self.failUnless(self.patches[1] in self.bundle.patches.all())
+ self.assertEqual(self.bundle.patches.count(), 2)
+ self.assertIn(self.patches[0], self.bundle.patches.all())
+ self.assertIn(self.patches[1], self.bundle.patches.all())
# check order
bps = [ BundlePatch.objects.get(bundle = self.bundle,
patch = self.patches[i]) \
for i in [0, 1] ]
- self.failUnless(bps[0].order < bps[1].order)
+ self.assertTrue(bps[0].order < bps[1].order)
class BundleInitialOrderTest(BundleTestBase):
"""When creating bundles from a patch list, ensure that the patches in the
response = self.client.post(bundle_url(self.bundle), params)
- self.failUnlessEqual(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
bps = BundlePatch.objects.filter(bundle = self.bundle) \
.order_by('order')
# check if patch IDs are in the expected order:
bundle_ids = [ bp.patch.id for bp in bps ]
- self.failUnlessEqual(neworder_ids, bundle_ids)
+ self.assertEqual(neworder_ids, bundle_ids)
# check if order field is still sequential:
order_numbers = [ bp.order for bp in bps ]
expected_order = list(range(1, len(neworder)+1)) # [1 ... len(neworder)]
- self.failUnlessEqual(order_numbers, expected_order)
+ self.assertEqual(order_numbers, expected_order)
def testBundleReorderAll(self):
# reorder all patches:
self.conf.active = False
self.conf.save()
response = self.client.get(_confirmation_url(self.conf))
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'patchwork/confirm-error.html')
self.assertEqual(response.context['error'], 'inactive')
self.assertEqual(response.context['conf'], self.conf)
self.conf.date -= self.conf.validity
self.conf.save()
response = self.client.get(_confirmation_url(self.conf))
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'patchwork/confirm-error.html')
self.assertEqual(response.context['error'], 'expired')
self.assertEqual(response.context['conf'], self.conf)
def testMboxView(self):
response = self.client.get('/patch/%d/mbox/' % self.patch.id)
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertTrue(self.patch.content in \
response.content.decode(self.patch_encoding))
def testRawView(self):
response = self.client.get('/patch/%d/raw/' % self.patch.id)
- self.assertEquals(response.status_code, 200)
- self.assertEquals(response.content.decode(self.patch_encoding),
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(response.content.decode(self.patch_encoding),
self.patch.content)
def tearDown(self):
defaults.project.save()
url = '/project/%s/list/?submitter=a%%26b=c' % project.linkname
response = self.client.get(url)
- self.failUnlessEqual(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertNotContains(response, 'submitter=a&b=c')
self.assertNotContains(response, 'submitter=a&b=c')
defaults.project.save()
url = '/project/%s/list/?submitter=%%E2%%98%%83' % project.linkname
response = self.client.get(url)
- self.failUnlessEqual(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
def testMailSettingsGET(self):
response = self.client.get(self.url)
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertTrue(response.context['form'])
def testMailSettingsPOST(self):
email = u'foo@example.com'
response = self.client.post(self.url, {'email': email})
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'patchwork/mail-settings.html')
- self.assertEquals(response.context['email'], email)
+ self.assertEqual(response.context['email'], email)
def testMailSettingsPOSTEmpty(self):
response = self.client.post(self.url, {'email': ''})
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'patchwork/mail-form.html')
self.assertFormError(response, 'form', 'email',
'This field is required.')
def testMailSettingsPOSTInvalid(self):
response = self.client.post(self.url, {'email': 'foo'})
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'patchwork/mail-form.html')
self.assertFormError(response, 'form', 'email', error_strings['email'])
def testMailSettingsPOSTOptedIn(self):
email = u'foo@example.com'
response = self.client.post(self.url, {'email': email})
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'patchwork/mail-settings.html')
- self.assertEquals(response.context['is_optout'], False)
+ self.assertEqual(response.context['is_optout'], False)
self.assertContains(response, '<strong>may</strong>')
optout_url = reverse('patchwork.views.mail.optout')
self.assertContains(response, ('action="%s"' % optout_url))
email = u'foo@example.com'
EmailOptout(email = email).save()
response = self.client.post(self.url, {'email': email})
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'patchwork/mail-settings.html')
- self.assertEquals(response.context['is_optout'], True)
+ self.assertEqual(response.context['is_optout'], True)
self.assertContains(response, '<strong>may not</strong>')
optin_url = reverse('patchwork.views.mail.optin')
self.assertContains(response, ('action="%s"' % optin_url))
response = self.client.post(self.url, {'email': email})
# check for a confirmation object
- self.assertEquals(EmailConfirmation.objects.count(), 1)
+ self.assertEqual(EmailConfirmation.objects.count(), 1)
conf = EmailConfirmation.objects.get(email = email)
# check confirmation page
- self.assertEquals(response.status_code, 200)
- self.assertEquals(response.context['confirmation'], conf)
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(response.context['confirmation'], conf)
self.assertContains(response, email)
# check email
url = reverse('patchwork.views.confirm', kwargs = {'key': conf.key})
- self.assertEquals(len(mail.outbox), 1)
+ self.assertEqual(len(mail.outbox), 1)
msg = mail.outbox[0]
- self.assertEquals(msg.to, [email])
- self.assertEquals(msg.subject, 'Patchwork opt-out confirmation')
- self.assertTrue(url in msg.body)
+ self.assertEqual(msg.to, [email])
+ self.assertEqual(msg.subject, 'Patchwork opt-out confirmation')
+ self.assertIn(url, msg.body)
def testOptoutRequestInvalidPOSTEmpty(self):
response = self.client.post(self.url, {'email': ''})
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertFormError(response, 'form', 'email',
'This field is required.')
self.assertTrue(response.context['error'])
- self.assertTrue('email_sent' not in response.context)
- self.assertEquals(len(mail.outbox), 0)
+ self.assertNotIn('email_sent', response.context)
+ self.assertEqual(len(mail.outbox), 0)
def testOptoutRequestInvalidPOSTNonEmail(self):
response = self.client.post(self.url, {'email': 'foo'})
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertFormError(response, 'form', 'email', error_strings['email'])
self.assertTrue(response.context['error'])
- self.assertTrue('email_sent' not in response.context)
- self.assertEquals(len(mail.outbox), 0)
+ self.assertNotIn('email_sent', response.context)
+ self.assertEqual(len(mail.outbox), 0)
class OptoutTest(TestCase):
kwargs = {'key': self.conf.key})
response = self.client.get(url)
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'patchwork/optout.html')
self.assertContains(response, self.email)
# check that we've got an optout in the list
- self.assertEquals(EmailOptout.objects.count(), 1)
- self.assertEquals(EmailOptout.objects.all()[0].email, self.email)
+ self.assertEqual(EmailOptout.objects.count(), 1)
+ self.assertEqual(EmailOptout.objects.all()[0].email, self.email)
# check that the confirmation is now inactive
self.assertFalse(EmailConfirmation.objects.get(
response = self.client.post(self.url, {'email': self.email})
# check for a confirmation object
- self.assertEquals(EmailConfirmation.objects.count(), 1)
+ self.assertEqual(EmailConfirmation.objects.count(), 1)
conf = EmailConfirmation.objects.get(email = self.email)
# check confirmation page
- self.assertEquals(response.status_code, 200)
- self.assertEquals(response.context['confirmation'], conf)
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(response.context['confirmation'], conf)
self.assertContains(response, self.email)
# check email
url = reverse('patchwork.views.confirm', kwargs = {'key': conf.key})
- self.assertEquals(len(mail.outbox), 1)
+ self.assertEqual(len(mail.outbox), 1)
msg = mail.outbox[0]
- self.assertEquals(msg.to, [self.email])
- self.assertEquals(msg.subject, 'Patchwork opt-in confirmation')
- self.assertTrue(url in msg.body)
+ self.assertEqual(msg.to, [self.email])
+ self.assertEqual(msg.subject, 'Patchwork opt-in confirmation')
+ self.assertIn(url, msg.body)
def testOptoutRequestInvalidPOSTEmpty(self):
response = self.client.post(self.url, {'email': ''})
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertFormError(response, 'form', 'email',
'This field is required.')
self.assertTrue(response.context['error'])
- self.assertTrue('email_sent' not in response.context)
- self.assertEquals(len(mail.outbox), 0)
+ self.assertNotIn('email_sent', response.context)
+ self.assertEqual(len(mail.outbox), 0)
def testOptoutRequestInvalidPOSTNonEmail(self):
response = self.client.post(self.url, {'email': 'foo'})
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertFormError(response, 'form', 'email', error_strings['email'])
self.assertTrue(response.context['error'])
- self.assertTrue('email_sent' not in response.context)
- self.assertEquals(len(mail.outbox), 0)
+ self.assertNotIn('email_sent', response.context)
+ self.assertEqual(len(mail.outbox), 0)
class OptinTest(TestCase):
kwargs = {'key': self.conf.key})
response = self.client.get(url)
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'patchwork/optin.html')
self.assertContains(response, self.email)
# check that there's no optout remaining
- self.assertEquals(EmailOptout.objects.count(), 0)
+ self.assertEqual(EmailOptout.objects.count(), 0)
# check that the confirmation is now inactive
self.assertFalse(EmailConfirmation.objects.get(
response = self.client.post(self.url, {'email': email})
# check for an error message
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertTrue(bool(response.context['error']))
self.assertContains(response, 'not on the patchwork opt-out list')
def testMainEmailOptoutForm(self):
form_re = self._form_re(self.optout_url, self.user.email)
response = self.client.get(self.url)
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertTrue(form_re.search(response.content.decode()) is not None)
def testMainEmailOptinForm(self):
EmailOptout(email = self.user.email).save()
form_re = self._form_re(self.optin_url, self.user.email)
response = self.client.get(self.url)
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertTrue(form_re.search(response.content.decode()) is not None)
def testSecondaryEmailOptoutForm(self):
p.save()
form_re = self._form_re(self.optout_url, p.email)
response = self.client.get(self.url)
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertTrue(form_re.search(response.content.decode()) is not None)
def testSecondaryEmailOptinForm(self):
form_re = self._form_re(self.optin_url, p.email)
response = self.client.get(self.url)
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertTrue(form_re.search(response.content.decode()) is not None)
qs.update(last_modified = timestamp)
def testNoNotifications(self):
- self.assertEquals(send_notifications(), [])
+ self.assertEqual(send_notifications(), [])
def testNoReadyNotifications(self):
""" We shouldn't see immediate notifications"""
orig_state = self.patch.state).save()
errors = send_notifications()
- self.assertEquals(errors, [])
- self.assertEquals(len(mail.outbox), 0)
+ self.assertEqual(errors, [])
+ self.assertEqual(len(mail.outbox), 0)
def testNotifications(self):
PatchChangeNotification(patch = self.patch,
self._expireNotifications()
errors = send_notifications()
- self.assertEquals(errors, [])
- self.assertEquals(len(mail.outbox), 1)
+ self.assertEqual(errors, [])
+ self.assertEqual(len(mail.outbox), 1)
msg = mail.outbox[0]
- self.assertEquals(msg.to, [self.submitter.email])
- self.assertTrue(self.patch.get_absolute_url() in msg.body)
+ self.assertEqual(msg.to, [self.submitter.email])
+ self.assertIn(self.patch.get_absolute_url(), msg.body)
def testNotificationEscaping(self):
self.patch.name = 'Patch name with " character'
self._expireNotifications()
errors = send_notifications()
- self.assertEquals(errors, [])
- self.assertEquals(len(mail.outbox), 1)
+ self.assertEqual(errors, [])
+ self.assertEqual(len(mail.outbox), 1)
msg = mail.outbox[0]
- self.assertEquals(msg.to, [self.submitter.email])
- self.assertFalse('"' in msg.body)
+ self.assertEqual(msg.to, [self.submitter.email])
+ self.assertNotIn('"', msg.body)
def testNotificationOptout(self):
"""ensure opt-out addresses don't get notifications"""
EmailOptout(email = self.submitter.email).save()
errors = send_notifications()
- self.assertEquals(errors, [])
- self.assertEquals(len(mail.outbox), 0)
+ self.assertEqual(errors, [])
+ self.assertEqual(len(mail.outbox), 0)
def testNotificationMerge(self):
patches = [self.patch,
PatchChangeNotification(patch = patch,
orig_state = patch.state).save()
- self.assertEquals(PatchChangeNotification.objects.count(), len(patches))
+ self.assertEqual(PatchChangeNotification.objects.count(), len(patches))
self._expireNotifications()
errors = send_notifications()
- self.assertEquals(errors, [])
- self.assertEquals(len(mail.outbox), 1)
+ self.assertEqual(errors, [])
+ self.assertEqual(len(mail.outbox), 1)
msg = mail.outbox[0]
- self.assertTrue(patches[0].get_absolute_url() in msg.body)
- self.assertTrue(patches[1].get_absolute_url() in msg.body)
+ self.assertIn(patches[0].get_absolute_url(), msg.body)
+ self.assertIn(patches[1].get_absolute_url(), msg.body)
def testUnexpiredNotificationMerge(self):
"""Test that when there are multiple pending notifications, with
PatchChangeNotification(patch = patch,
orig_state = patch.state).save()
- self.assertEquals(PatchChangeNotification.objects.count(), len(patches))
+ self.assertEqual(PatchChangeNotification.objects.count(), len(patches))
self._expireNotifications()
# update one notification, to bring it out of the notification delay
# the updated notification should prevent the other from being sent
errors = send_notifications()
- self.assertEquals(errors, [])
- self.assertEquals(len(mail.outbox), 0)
+ self.assertEqual(errors, [])
+ self.assertEqual(len(mail.outbox), 0)
# expire the updated notification
self._expireNotifications()
errors = send_notifications()
- self.assertEquals(errors, [])
- self.assertEquals(len(mail.outbox), 1)
+ self.assertEqual(errors, [])
+ self.assertEqual(len(mail.outbox), 1)
msg = mail.outbox[0]
- self.assertTrue(patches[0].get_absolute_url() in msg.body)
- self.assertTrue(patches[1].get_absolute_url() in msg.body)
+ self.assertIn(patches[0].get_absolute_url(), msg.body)
+ self.assertIn(patches[1].get_absolute_url(), msg.body)
self.assertTrue(self.patch is not None)
def testPatchContent(self):
- self.assertEquals(self.patch.content, self.orig_patch)
+ self.assertEqual(self.patch.content, self.orig_patch)
def testCommentPresence(self):
self.assertTrue(self.comment is not None)
def testCommentContent(self):
- self.assertEquals(self.comment.content, self.test_comment)
+ self.assertEqual(self.comment.content, self.test_comment)
class AttachmentPatchTest(InlinePatchTest):
self.person.delete()
def testName(self):
- self.assertEquals(self.person.name, self.sender_name)
+ self.assertEqual(self.person.name, self.sender_name)
def testEmail(self):
- self.assertEquals(self.person.email, self.sender_email)
+ self.assertEqual(self.person.email, self.sender_email)
def testDBQueryName(self):
db_person = Person.objects.get(name = self.sender_name)
- self.assertEquals(self.person, db_person)
+ self.assertEqual(self.person, db_person)
def testDBQueryEmail(self):
db_person = Person.objects.get(email = self.sender_email)
- self.assertEquals(self.person, db_person)
+ self.assertEqual(self.person, db_person)
class SenderUTF8QPEncodingTest(SenderEncodingTest):
def testSubjectEncoding(self):
(patch, comment) = find_content(self.project, self.email)
- self.assertEquals(patch.name, self.subject)
+ self.assertEqual(patch.name, self.subject)
class SubjectUTF8QPEncodingTest(SubjectEncodingTest):
subject = u'test s\xfcbject'
parse_mail(email)
def testParsedProjects(self):
- self.assertEquals(Patch.objects.filter(project = self.p1).count(), 1)
- self.assertEquals(Patch.objects.filter(project = self.p2).count(), 1)
+ self.assertEqual(Patch.objects.filter(project = self.p1).count(), 1)
+ self.assertEqual(Patch.objects.filter(project = self.p2).count(), 1)
def tearDown(self):
self.p1.delete()
patch = Patch.objects.filter(project = project)[0]
# we should see two comments now - the original mail with the patch,
# and the one we parsed in setUp()
- self.assertEquals(Comment.objects.filter(patch = patch).count(), 2)
+ self.assertEqual(Comment.objects.filter(patch = patch).count(), 2)
class ListIdHeaderTest(TestCase):
""" Test that we parse List-Id headers from mails correctly """
def testNoListId(self):
email = MIMEText('')
project = find_project_by_header(email)
- self.assertEquals(project, None)
+ self.assertEqual(project, None)
def testBlankListId(self):
email = MIMEText('')
email['List-Id'] = ''
project = find_project_by_header(email)
- self.assertEquals(project, None)
+ self.assertEqual(project, None)
def testWhitespaceListId(self):
email = MIMEText('')
email['List-Id'] = ' '
project = find_project_by_header(email)
- self.assertEquals(project, None)
+ self.assertEqual(project, None)
def testSubstringListId(self):
email = MIMEText('')
email['List-Id'] = 'example.com'
project = find_project_by_header(email)
- self.assertEquals(project, None)
+ self.assertEqual(project, None)
def testShortListId(self):
""" Some mailing lists have List-Id headers in short formats, where it
email = MIMEText('')
email['List-Id'] = self.project.listid
project = find_project_by_header(email)
- self.assertEquals(project, self.project)
+ self.assertEqual(project, self.project)
def testLongListId(self):
email = MIMEText('')
email['List-Id'] = 'Test text <%s>' % self.project.listid
project = find_project_by_header(email)
- self.assertEquals(project, self.project)
+ self.assertEqual(project, self.project)
def tearDown(self):
self.project.delete()
def _assertDelegate(self, delegate):
query = Patch.objects.filter(project=self.p1)
- self.assertEquals(query.count(), 1)
- self.assertEquals(query[0].delegate, delegate)
+ self.assertEqual(query.count(), 1)
+ self.assertEqual(query[0].delegate, delegate)
def testDelegate(self):
email = self.get_email()
def _assertState(self, state):
query = Patch.objects.filter(project=self.p1)
- self.assertEquals(query.count(), 1)
- self.assertEquals(query[0].state, state)
+ self.assertEqual(query.count(), 1)
+ self.assertEqual(query[0].state, state)
def testNonDefaultStateIsActuallyNotTheDefaultState(self):
self.assertNotEqual(self.default_state, self.nondefault_state)
parse_mail(email)
def testTags(self):
- self.assertEquals(Patch.objects.count(), 1)
+ self.assertEqual(Patch.objects.count(), 1)
patch = Patch.objects.all()[0]
- self.assertEquals(patch.patchtag_set.filter(
+ self.assertEqual(patch.patchtag_set.filter(
tag__name='Acked-by').count(), 0)
- self.assertEquals(patch.patchtag_set.get(
+ self.assertEqual(patch.patchtag_set.get(
tag__name='Reviewed-by').count, 1)
- self.assertEquals(patch.patchtag_set.get(
+ self.assertEqual(patch.patchtag_set.get(
tag__name='Tested-by').count, 1)
class PrefixTest(TestCase):
def testSplitPrefixes(self):
- self.assertEquals(split_prefixes('PATCH'), ['PATCH'])
- self.assertEquals(split_prefixes('PATCH,RFC'), ['PATCH', 'RFC'])
- self.assertEquals(split_prefixes(''), [])
- self.assertEquals(split_prefixes('PATCH,'), ['PATCH'])
- self.assertEquals(split_prefixes('PATCH '), ['PATCH'])
- self.assertEquals(split_prefixes('PATCH,RFC'), ['PATCH', 'RFC'])
- self.assertEquals(split_prefixes('PATCH 1/2'), ['PATCH', '1/2'])
+ self.assertEqual(split_prefixes('PATCH'), ['PATCH'])
+ self.assertEqual(split_prefixes('PATCH,RFC'), ['PATCH', 'RFC'])
+ self.assertEqual(split_prefixes(''), [])
+ self.assertEqual(split_prefixes('PATCH,'), ['PATCH'])
+ self.assertEqual(split_prefixes('PATCH '), ['PATCH'])
+ self.assertEqual(split_prefixes('PATCH,RFC'), ['PATCH', 'RFC'])
+ self.assertEqual(split_prefixes('PATCH 1/2'), ['PATCH', '1/2'])
class SubjectTest(TestCase):
def testCleanSubject(self):
- self.assertEquals(clean_subject('meep'), 'meep')
- self.assertEquals(clean_subject('Re: meep'), 'meep')
- self.assertEquals(clean_subject('[PATCH] meep'), 'meep')
- self.assertEquals(clean_subject('[PATCH] meep \n meep'), 'meep meep')
- self.assertEquals(clean_subject('[PATCH RFC] meep'), '[RFC] meep')
- self.assertEquals(clean_subject('[PATCH,RFC] meep'), '[RFC] meep')
- self.assertEquals(clean_subject('[PATCH,1/2] meep'), '[1/2] meep')
- self.assertEquals(clean_subject('[PATCH RFC 1/2] meep'),
+ self.assertEqual(clean_subject('meep'), 'meep')
+ self.assertEqual(clean_subject('Re: meep'), 'meep')
+ self.assertEqual(clean_subject('[PATCH] meep'), 'meep')
+ self.assertEqual(clean_subject('[PATCH] meep \n meep'), 'meep meep')
+ self.assertEqual(clean_subject('[PATCH RFC] meep'), '[RFC] meep')
+ self.assertEqual(clean_subject('[PATCH,RFC] meep'), '[RFC] meep')
+ self.assertEqual(clean_subject('[PATCH,1/2] meep'), '[1/2] meep')
+ self.assertEqual(clean_subject('[PATCH RFC 1/2] meep'),
'[RFC,1/2] meep')
- self.assertEquals(clean_subject('[PATCH] [RFC] meep'),
+ self.assertEqual(clean_subject('[PATCH] [RFC] meep'),
'[RFC] meep')
- self.assertEquals(clean_subject('[PATCH] [RFC,1/2] meep'),
+ self.assertEqual(clean_subject('[PATCH] [RFC,1/2] meep'),
'[RFC,1/2] meep')
- self.assertEquals(clean_subject('[PATCH] [RFC] [1/2] meep'),
+ self.assertEqual(clean_subject('[PATCH] [RFC] [1/2] meep'),
'[RFC,1/2] meep')
- self.assertEquals(clean_subject('[PATCH] rewrite [a-z] regexes'),
+ self.assertEqual(clean_subject('[PATCH] rewrite [a-z] regexes'),
'rewrite [a-z] regexes')
- self.assertEquals(clean_subject('[PATCH] [RFC] rewrite [a-z] regexes'),
+ self.assertEqual(clean_subject('[PATCH] [RFC] rewrite [a-z] regexes'),
'[RFC] rewrite [a-z] regexes')
- self.assertEquals(clean_subject('[foo] [bar] meep', ['foo']),
+ self.assertEqual(clean_subject('[foo] [bar] meep', ['foo']),
'[bar] meep')
- self.assertEquals(clean_subject('[FOO] [bar] meep', ['foo']),
+ self.assertEqual(clean_subject('[FOO] [bar] meep', ['foo']),
'[bar] meep')
def testNameComplete(self):
response = self.client.get('/submitter/', {'q': 'name'})
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
data = json.loads(response.content.decode())
- self.assertEquals(len(data), 1)
- self.assertEquals(data[0]['name'], 'Test Name')
+ self.assertEqual(len(data), 1)
+ self.assertEqual(data[0]['name'], 'Test Name')
def testEmailComplete(self):
response = self.client.get('/submitter/', {'q': 'test2'})
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
data = json.loads(response.content.decode())
- self.assertEquals(len(data), 1)
- self.assertEquals(data[0]['email'], 'test2@example.com')
+ self.assertEqual(len(data), 1)
+ self.assertEqual(data[0]['email'], 'test2@example.com')
def testCompleteLimit(self):
for i in range(3,10):
person = Person(email = 'test%d@example.com' % i)
person.save()
response = self.client.get('/submitter/', {'q': 'test', 'l': 5})
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
data = json.loads(response.content.decode())
- self.assertEquals(len(data), 5)
+ self.assertEqual(len(data), 5)
def testRegistrationForm(self):
response = self.client.get('/register/')
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'patchwork/registration_form.html')
def testBlankFields(self):
data = self.default_data.copy()
del data[field]
response = self.client.post('/register/', data)
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertFormError(response, 'form', field, self.required_error)
def testInvalidUsername(self):
data = self.default_data.copy()
data['username'] = 'invalid user'
response = self.client.post('/register/', data)
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertFormError(response, 'form', 'username', self.invalid_error)
def testExistingUsername(self):
data = self.default_data.copy()
data['username'] = user.username
response = self.client.post('/register/', data)
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertFormError(response, 'form', 'username',
'This username is already taken. Please choose another.')
data = self.default_data.copy()
data['email'] = user.email
response = self.client.post('/register/', data)
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertFormError(response, 'form', 'email',
'This email address is already in use ' + \
'for the account "%s".\n' % user.username)
def testValidRegistration(self):
response = self.client.post('/register/', self.default_data)
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertContains(response, 'confirmation email has been sent')
# check for presence of an inactive user object
users = User.objects.filter(username = self.user.username)
- self.assertEquals(users.count(), 1)
+ self.assertEqual(users.count(), 1)
user = users[0]
- self.assertEquals(user.username, self.user.username)
- self.assertEquals(user.email, self.user.email)
- self.assertEquals(user.is_active, False)
+ self.assertEqual(user.username, self.user.username)
+ self.assertEqual(user.email, self.user.email)
+ self.assertEqual(user.is_active, False)
# check for confirmation object
confs = EmailConfirmation.objects.filter(user = user,
type = 'registration')
- self.assertEquals(len(confs), 1)
+ self.assertEqual(len(confs), 1)
conf = confs[0]
- self.assertEquals(conf.email, self.user.email)
+ self.assertEqual(conf.email, self.user.email)
# check for a sent mail
- self.assertEquals(len(mail.outbox), 1)
+ self.assertEqual(len(mail.outbox), 1)
msg = mail.outbox[0]
- self.assertEquals(msg.subject, 'Patchwork account confirmation')
- self.assertTrue(self.user.email in msg.to)
- self.assertTrue(_confirmation_url(conf) in msg.body)
+ self.assertEqual(msg.subject, 'Patchwork account confirmation')
+ self.assertIn(self.user.email, msg.to)
+ self.assertIn(_confirmation_url(conf), msg.body)
# ...and that the URL is valid
response = self.client.get(_confirmation_url(conf))
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
class RegistrationConfirmationTest(TestCase):
def testRegistrationConfirmation(self):
self.assertEqual(EmailConfirmation.objects.count(), 0)
response = self.client.post('/register/', self.default_data)
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertContains(response, 'confirmation email has been sent')
self.assertEqual(EmailConfirmation.objects.count(), 1)
self.assertTrue(conf.active)
response = self.client.get(_confirmation_url(conf))
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'patchwork/registration-confirm.html')
conf = EmailConfirmation.objects.get(pk = conf.pk)
# register
self.assertEqual(EmailConfirmation.objects.count(), 0)
response = self.client.post('/register/', self.default_data)
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertFalse(Person.objects.exists())
# confirm
conf = EmailConfirmation.objects.filter()[0]
response = self.client.get(_confirmation_url(conf))
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
qs = Person.objects.filter(email = self.user.email)
self.assertTrue(qs.exists())
person = Person.objects.get(email = self.user.email)
- self.assertEquals(person.name,
+ self.assertEqual(person.name,
self.user.firstname + ' ' + self.user.lastname)
def testRegistrationExistingPersonSetup(self):
# register
self.assertEqual(EmailConfirmation.objects.count(), 0)
response = self.client.post('/register/', self.default_data)
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
# confirm
conf = EmailConfirmation.objects.filter()[0]
response = self.client.get(_confirmation_url(conf))
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
person = Person.objects.get(email = self.user.email)
- self.assertEquals(person.name, fullname)
+ self.assertEqual(person.name, fullname)
def testRegistrationExistingPersonUnmodified(self):
""" Check that an unconfirmed registration can't modify an existing
data = self.default_data.copy()
data['first_name'] = 'invalid'
data['last_name'] = 'invalid'
- self.assertEquals(data['email'], person.email)
+ self.assertEqual(data['email'], person.email)
response = self.client.post('/register/', data)
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
- self.assertEquals(Person.objects.get(pk = person.pk).name, fullname)
+ self.assertEqual(Person.objects.get(pk = person.pk).name, fullname)
def assertTagsEqual(self, str, acks, reviews, tests):
counts = extract_tags(str, Tag.objects.all())
- self.assertEquals((acks, reviews, tests),
+ self.assertEqual((acks, reviews, tests),
(counts[Tag.objects.get(name='Acked-by')],
counts[Tag.objects.get(name='Reviewed-by')],
counts[Tag.objects.get(name='Tested-by')]))
state = State.objects.exclude(pk__in = states)[0]
self._testStateChange(state.pk)
for p in self.patches:
- self.assertEquals(Patch.objects.get(pk = p.pk).state, state)
+ self.assertEqual(Patch.objects.get(pk = p.pk).state, state)
def testStateChangeInvalid(self):
state = max(State.objects.all().values_list('id', flat = True)) + 1
orig_states = [patch.state for patch in self.patches]
response = self._testStateChange(state)
- self.assertEquals( \
+ self.assertEqual( \
[Patch.objects.get(pk = p.pk).state for p in self.patches],
orig_states)
self.assertFormError(response, 'patchform', 'state',
delegate = create_maintainer(defaults.project)
response = self._testDelegateChange(str(delegate.pk))
for p in self.patches:
- self.assertEquals(Patch.objects.get(pk = p.pk).delegate, delegate)
+ self.assertEqual(Patch.objects.get(pk = p.pk).delegate, delegate)
def testDelegateClear(self):
response = self._testDelegateChange('')
for p in self.patches:
- self.assertEquals(Patch.objects.get(pk = p.pk).delegate, None)
+ self.assertEqual(Patch.objects.get(pk = p.pk).delegate, None)
def testUserPersonRequestForm(self):
response = self.client.get('/user/link/')
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertTrue(response.context['linkform'])
def testUserPersonRequestEmpty(self):
response = self.client.post('/user/link/', {'email': ''})
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertTrue(response.context['linkform'])
self.assertFormError(response, 'linkform', 'email',
'This field is required.')
def testUserPersonRequestInvalid(self):
response = self.client.post('/user/link/', {'email': 'foo'})
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertTrue(response.context['linkform'])
self.assertFormError(response, 'linkform', 'email',
error_strings['email'])
def testUserPersonRequestValid(self):
response = self.client.post('/user/link/',
{'email': self.user.secondary_email})
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertTrue(response.context['confirmation'])
# check that we have a confirmation saved
- self.assertEquals(EmailConfirmation.objects.count(), 1)
+ self.assertEqual(EmailConfirmation.objects.count(), 1)
conf = EmailConfirmation.objects.all()[0]
- self.assertEquals(conf.user, self.user.user)
- self.assertEquals(conf.email, self.user.secondary_email)
- self.assertEquals(conf.type, 'userperson')
+ self.assertEqual(conf.user, self.user.user)
+ self.assertEqual(conf.email, self.user.secondary_email)
+ self.assertEqual(conf.type, 'userperson')
# check that an email has gone out...
- self.assertEquals(len(mail.outbox), 1)
+ self.assertEqual(len(mail.outbox), 1)
msg = mail.outbox[0]
- self.assertEquals(msg.subject, 'Patchwork email address confirmation')
- self.assertTrue(self.user.secondary_email in msg.to)
- self.assertTrue(_confirmation_url(conf) in msg.body)
+ self.assertEqual(msg.subject, 'Patchwork email address confirmation')
+ self.assertIn(self.user.secondary_email, msg.to)
+ self.assertIn(_confirmation_url(conf), msg.body)
# ...and that the URL is valid
response = self.client.get(_confirmation_url(conf))
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'patchwork/user-link-confirm.html')
class UserPersonConfirmTest(TestCase):
self.conf.save()
def testUserPersonConfirm(self):
- self.assertEquals(Person.objects.count(), 0)
+ self.assertEqual(Person.objects.count(), 0)
response = self.client.get(_confirmation_url(self.conf))
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
# check that the Person object has been created and linked
- self.assertEquals(Person.objects.count(), 1)
+ self.assertEqual(Person.objects.count(), 1)
person = Person.objects.get(email = self.user.secondary_email)
- self.assertEquals(person.email, self.user.secondary_email)
- self.assertEquals(person.user, self.user.user)
+ self.assertEqual(person.email, self.user.secondary_email)
+ self.assertEqual(person.user, self.user.user)
# check that the confirmation has been marked as inactive. We
# need to reload the confirmation to check this.
conf = EmailConfirmation.objects.get(pk = self.conf.pk)
- self.assertEquals(conf.active, False)
+ self.assertEqual(conf.active, False)
class UserLoginRedirectTest(TestCase):
response = self.client.post('/user/', {'patches_per_page': new_ppp})
user_profile = UserProfile.objects.get(user=self.user.user.id)
- self.assertEquals(user_profile.patches_per_page, new_ppp)
+ self.assertEqual(user_profile.patches_per_page, new_ppp)
def testUserProfileInvalidPost(self):
user_profile = UserProfile.objects.get(user=self.user.user.id)
response = self.client.post('/user/', {'patches_per_page': new_ppp})
user_profile = UserProfile.objects.get(user=self.user.user.id)
- self.assertEquals(user_profile.patches_per_page, old_ppp)
+ self.assertEqual(user_profile.patches_per_page, old_ppp)
class UserPasswordChangeTest(TestCase):
self.assertRedirects(response, self.done_url)
person = Person.objects.get(email=user.email)
- self.assertEquals(person.user, user.user)
+ self.assertEqual(person.user, user.user)
def testUnlinkSecondaryEmail(self):
user = TestUser()
self.assertRedirects(response, self.done_url)
person = Person.objects.get(email=user.secondary_email)
- self.assertEquals(person.user, None)
+ self.assertEqual(person.user, None)
def testUnlinkAnotherUser(self):
user = TestUser()
self.assertRedirects(response, self.done_url)
person = Person.objects.get(email=other_user.email)
- self.assertEquals(person.user, None)
+ self.assertEqual(person.user, None)
def testUnlinkNonPost(self):
user = TestUser()
self.assertRedirects(response, self.done_url)
person = Person.objects.get(email=user.secondary_email)
- self.assertEquals(person.user, user.user)
+ self.assertEqual(person.user, user.user)
self.enter_text('password', self.user.password)
self.click('input[value="Login"]')
dropdown = self.wait_until_visible('a.dropdown-toggle strong')
- self.assertEquals(dropdown.text, 'testuser')
+ self.assertEqual(dropdown.text, 'testuser')