Merge lp:~daker/loco-team-portal/fix.tests-2 into lp:loco-team-portal

Proposed by Adnane Belmadiaf
Status: Merged
Approved by: Adnane Belmadiaf
Approved revision: 563
Merged at revision: 564
Proposed branch: lp:~daker/loco-team-portal/fix.tests-2
Merge into: lp:loco-team-portal
Diff against target: 171 lines (+80/-32)
2 files modified
loco_directory/common/launchpad.py (+1/-0)
loco_directory/teams/tests.py (+79/-32)
To merge this branch: bzr merge lp:~daker/loco-team-portal/fix.tests-2
Reviewer Review Type Date Requested Status
LoCo Team Portal Developers Pending
Review via email: mp+135982@code.launchpad.net

Commit message

Fixed the teams app tests

To post a comment you must log in.
Revision history for this message
Tarmac WebDev (tarmac-webdev) wrote :

Attempt to merge into lp:loco-team-portal failed due to conflicts:

text conflict in loco_directory/common/launchpad.py

563. By Adnane Belmadiaf

* Merged trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'loco_directory/common/launchpad.py'
--- loco_directory/common/launchpad.py 2012-11-18 22:02:56 +0000
+++ loco_directory/common/launchpad.py 2012-11-26 21:09:19 +0000
@@ -55,6 +55,7 @@
55 return True55 return True
56 if is_debug_user(username):56 if is_debug_user(username):
57 return True57 return True
58 return False
5859
59def get_mugshot_url(url):60def get_mugshot_url(url):
60 # Not ideal, but until LP #71387361 # Not ideal, but until LP #713873
6162
=== modified file 'loco_directory/teams/tests.py'
--- loco_directory/teams/tests.py 2011-07-22 16:26:13 +0000
+++ loco_directory/teams/tests.py 2012-11-26 21:09:19 +0000
@@ -1,29 +1,75 @@
1from django.test import TestCase1from django.test import TestCase
22from django.core.urlresolvers import reverse
3from urllib import urlencode
4
5from django.contrib.auth.models import User, Group
6
7from django_openid_auth.models import UserOpenID
8from userprofiles.models import UserProfile
3from teams.models import *9from teams.models import *
4from common import launchpad10from common import launchpad
511
6from django.core.urlresolvers import reverse12
713
814class TestBase(TestCase):
9class ACLChecksTestCase(TestCase):15
10# to create this, run: 16 def setUp(self):
11# mkdir teams/fixtures17 # setup test users
12# ./manage.py dumpdata --format xml teams > teams/fixtures/test_data.xml18 # user foo
13 fixtures = ["test_data.xml"]19 self.user_foo = User.objects.create(
14 20 username='foo',
21 )
22 self.user_foo.set_password('test')
23 self.user_foo.save()
24
25 self.useropenid_foo = UserOpenID(user=self.user_foo,
26 claimed_id='http://example.com/identity_foo',
27 display_id='http://example.com/identity_foo')
28 self.useropenid_foo.save()
29 self.userprofile_foo = UserProfile.objects.create(user=self.user_foo)
30
31 # user bar
32 self.user_bar = User.objects.create(
33 username='bar',
34 )
35 self.user_bar.set_password('test')
36 self.user_bar.save()
37 self.useropenid_bar = UserOpenID(user=self.user_bar,
38 claimed_id='http://example.com/identity_bar',
39 display_id='http://example.com/identity_bar')
40 self.useropenid_bar.save()
41 self.userprofile_bar = UserProfile.objects.create(user=self.user_bar)
42
43 # setup test country
44 self.country = Country.objects.create(name='Test Country')
45
46 # setup test team
47 self.team = Team.objects.create(
48 lp_name='test-team',
49 name='Test Team',
50 owner_profile=self.userprofile_foo,
51 )
52
53 # adding team to county
54 self.team.countries.add(self.country)
55 self.team_group = Group.objects.create(
56 name=self.team.lp_name,
57 )
58
59 # adding user foo to team_group
60 self.user_foo.groups.add(self.team_group)
61 self.user_foo.save()
62
63class ACLChecksTestCase(TestBase):
64
15 def testAdminIsATeamChecks(self):65 def testAdminIsATeamChecks(self):
16 """Test if check for a more complicated LoCo Team setup works66 """Test if check for a more complicated LoCo Team setup works
17 """67 """
18 teams = Team.objects.all()68 team = Team.objects.get(lp_name="test-team")
19 chile = teams.filter(lp_name="ubuntu-cl")[0]69 self.assertEquals(launchpad.is_admin_or_owner(self.user_foo.username, team), True)
20 self.assertEquals(launchpad.is_admin_or_owner("pvillavi", chile), True)70 self.assertEquals(launchpad.is_admin_or_owner(self.user_bar.username, team), False)
2171
22 venezuela = teams.filter(lp_name="ubuntu-ve")[0]72class EditTeamTestCase(TestBase):
23 self.assertEquals(launchpad.is_admin_or_owner("effie-jayx", venezuela), True)
24 self.assertEquals(launchpad.is_admin_or_owner("jorge", venezuela), False)
25
26class EditTeamTestCase(TestCase):
27 """73 """
28 test if team update works correct74 test if team update works correct
29 """75 """
@@ -32,19 +78,22 @@
32 test the team update as anonymous user (not logged in)78 test the team update as anonymous user (not logged in)
33 """79 """
34 #try to access team-update page as not logged in user80 #try to access team-update page as not logged in user
35 response = self.client.get(reverse( 'team-edit', args=['ubuntu-de-locoteam'] ), follow=True)81
36 self.assertRedirects(response, '/openid/login?next=/teams/ubuntu-de-locoteam/edit', status_code=302, target_status_code=200)82 data = { 'next' : '/teams/test-team/edit' }
83 response = self.client.get(reverse( 'team-edit', args=['test-team'] ), follow=True)
84 self.assertRedirects(response, '/openid/login/?%s' % urlencode(data), status_code=302, target_status_code=200)
85
37 #try to update team as not logged in user86 #try to update team as not logged in user
38 response = self.client.post(reverse('team-edit', args=['ubuntu-de-locoteam']), {'Country':'Germany', 'forum_url':'http://ubuntuusers.de', })87 response = self.client.post(reverse('team-edit', args=['test-team']), {'Country':'Germany', 'forum_url':'http://ubuntuusers.de'}, follow=True)
39 self.assertRedirects(response, '/openid/login?next=/teams/ubuntu-de-locoteam/edit', status_code=302, target_status_code=200)88 self.assertRedirects(response, '/openid/login/?%s' % urlencode(data), status_code=302, target_status_code=200)
40 89
41 def test_user_with_no_rights(self):90 def test_user_with_no_rights(self):
42 """91 """
43 test the team update with a user which has no rights92 test the team update with a user which has no rights
44 """93 """
45 pass94 pass
46 #FIXME How to use a user with no right with openid?95 #FIXME How to use a user with no right with openid?
47 96
48 def test_user_loco_council(self):97 def test_user_loco_council(self):
49 """98 """
50 test the team update with a user which is a member of loco council99 test the team update with a user which is a member of loco council
@@ -59,20 +108,17 @@
59 pass108 pass
60 #FIXME How to use a user with this rights with openid?109 #FIXME How to use a user with this rights with openid?
61110
62class DisplayNameTestCase(TestCase):111class DisplayNameTestCase(TestBase):
63
64 def setUp(self):
65 self.team = Team.objects.create(name='Test Team', lp_name='test-team')
66112
67 def test_override_name(self):113 def test_override_name(self):
68 # check without override_name114 # check without override_name
69 self.assertEquals(self.team.display_name, 'Test Team')115 self.assertEquals(self.team.display_name, 'Test Team')
70 116
71 # check wih override_name117 # check wih override_name
72 self.team.override_name = 'Override Name'118 self.team.override_name = 'Override Name'
73 self.team.save()119 self.team.save()
74 self.assertEquals(self.team.display_name, 'Override Name')120 self.assertEquals(self.team.display_name, 'Override Name')
75 121
76 def test_display_name_in_list(self):122 def test_display_name_in_list(self):
77 self.team.override_name = 'Override Name'123 self.team.override_name = 'Override Name'
78 self.team.save()124 self.team.save()
@@ -88,5 +134,6 @@
88134
89 response = self.client.get('/teams/test-team/')135 response = self.client.get('/teams/test-team/')
90 self.assertEquals(response.status_code, 200)136 self.assertEquals(response.status_code, 200)
137
91 self.assertContains(response, 'Override Name', 0) # No instances of override_name138 self.assertContains(response, 'Override Name', 0) # No instances of override_name
92 self.assertContains(response, 'Test Team', 3) # One instance of the team name139 self.assertContains(response, 'Test Team', 4) # One instance of the team name

Subscribers

People subscribed via source and target branches