Commit 70e3f3c0 authored by Claude Paroz's avatar Claude Paroz

Minor code sanitizing in tests

parent e9ae0daa
......@@ -3,7 +3,6 @@
from datetime import datetime, timedelta
from django.test import TestCase
from django.test.client import Client
from django.core.urlresolvers import reverse
from django.core import mail
from people.models import Person
......@@ -130,38 +129,38 @@ class TeamTest(TeamsAndRolesTests):
self.run_roles_test(Team.objects.all_with_roles()[0])
def test_join_team(self):
c = Client()
response = c.post('/login/', {'username': self.pn.username, 'password': 'password'})
response = self.client.post('/login/',
{'username': self.pn.username, 'password': 'password'})
# Display team join page
team_join_url = reverse('person_team_join', current_app='people')
response = c.get(team_join_url)
response = self.client.get(team_join_url)
self.assertContains(response, "<select ")
# Post for joining
response = c.post(team_join_url, {'teams':[str(self.t.pk)]})
response = self.client.post(team_join_url, {'teams':[str(self.t.pk)]})
# Test user is member of team
self.assertTrue(self.pn.is_translator(self.t))
# Test coordinator receives email
self.assertEquals(len(mail.outbox), 1)
self.assertEquals(mail.outbox[0].recipients()[0], self.pcoo.email)
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(mail.outbox[0].recipients()[0], self.pcoo.email)
# Mail should be sent in the target team's language (i.e. French here)
self.assertTrue(u"rejoindre" in mail.outbox[0].body)
self.assertTrue("rejoindre" in mail.outbox[0].body)
def test_edit_team(self):
""" Test team edit form """
c = Client()
edit_url = reverse('team_edit', args = ['fr'], current_app='teams')
response = c.get(edit_url)
self.assertEquals(response.status_code, 403)
response = self.client.get(edit_url)
self.assertEqual(response.status_code, 403)
# Login as team coordinator
response = c.post('/login/', {'username': self.pcoo.username, 'password': 'password'})
response = self.client.post('/login/',
{'username': self.pcoo.username, 'password': 'password'})
# Try team modification
response = c.post(edit_url, {
'webpage_url' : u"http://www.gnomefr.org/",
'mailing_list' : u"gnomefr@traduc.org",
'mailing_list_subscribe': u""
response = self.client.post(edit_url, {
'webpage_url' : "http://www.gnomefr.org/",
'mailing_list' : "gnomefr@traduc.org",
'mailing_list_subscribe': ""
})
team = Team.objects.get(name='fr')
self.assertEquals(team.webpage_url, u"http://www.gnomefr.org/")
self.assertEqual(team.webpage_url, "http://www.gnomefr.org/")
class JSONTeamsTest(TeamsAndRolesTests):
def setUp(self):
......@@ -176,8 +175,7 @@ class JSONTeamsTest(TeamsAndRolesTests):
def test_json_teams(self):
"""Test JSON teams interface"""
c = Client()
response = c.get(reverse('teams', args=['json']))
response = self.client.get(reverse('teams', args=['json']))
self.assertEqual(response.status_code, 200)
expected_JSON = """[
{
......
......@@ -245,9 +245,9 @@ class VertimusTest(TeamsAndRolesTests):
self.assertTrue(isinstance(state, StateTranslated))
# Mail sent to mailing list
self.assertEquals(len(mail.outbox), 1)
self.assertEquals(mail.outbox[0].recipients(), [self.l.team.mailing_list])
self.assertEquals(mail.outbox[0].subject, u"gedit - gnome-2-24")
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(mail.outbox[0].recipients(), [self.l.team.mailing_list])
self.assertEqual(mail.outbox[0].subject, "gedit - gnome-2-24")
# Testing if the role was activated
role = Role.objects.get(person=self.pt, team=self.l.team)
......@@ -299,7 +299,7 @@ class VertimusTest(TeamsAndRolesTests):
action = Action.new_by_name('UP', person=self.pr, comment="Done.", file=test_file)
action.apply_on(state, action.send_mail_to_ml)
self.assertEquals(len(mail.outbox), 1) # Mail sent to mailing list
self.assertEqual(len(mail.outbox), 1) # Mail sent to mailing list
mail.outbox = []
file_path = os.path.join(settings.MEDIA_ROOT, action.file.name)
......@@ -307,7 +307,7 @@ class VertimusTest(TeamsAndRolesTests):
action = Action.new_by_name('TC', person=self.pc, comment="To commit.")
action.apply_on(state, action.send_mail_to_ml)
self.assertEquals(len(mail.outbox), 1) # Mail sent to committers
self.assertEqual(len(mail.outbox), 1) # Mail sent to committers
mail.outbox = []
action = Action.new_by_name('RC', person=self.pc, comment="Reserved commit.")
......@@ -316,8 +316,8 @@ class VertimusTest(TeamsAndRolesTests):
action = Action.new_by_name('IC', person=self.pc, comment="Committed.")
action.apply_on(state, action.send_mail_to_ml)
# Mail sent to mailing list
self.assertEquals(len(mail.outbox), 1)
self.assertEquals(mail.outbox[0].recipients(), [self.l.team.mailing_list])
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(mail.outbox[0].recipients(), [self.l.team.mailing_list])
# Team is French (but translations may not be compiled/up-to-date)
self.assertTrue(u'Commité' in mail.outbox[0].body or "Committed" in mail.outbox[0].body)
......@@ -347,7 +347,7 @@ class VertimusTest(TeamsAndRolesTests):
state = State.objects.get(branch=self.b, domain=self.d, language=self.l)
self.assertTrue(isinstance(state, StateNone))
self.assertEquals(state.action_set.count(), 0)
self.assertEqual(state.action_set.count(), 0)
def test_action_undo(self):
state = StateNone(branch=self.b, domain=self.d, language=self.l)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment