1
from django.test import TestCase
3
from teams.models import *
4
from common import launchpad
6
from django.core.urlresolvers import reverse
9
class LoCoCouncilACLTestCase(TestCase):
11
"""Test if LoCo Council check works
13
self.assertEquals(launchpad.is_user_on_loco_council("popey"), True)
14
self.assertEquals(launchpad.is_user_on_loco_council("jonobacon"), False)
16
class ACLChecksTestCase(TestCase):
17
# to create this, run:
18
# mkdir teams/fixtures
19
# ./manage.py dumpdata --format xml teams > teams/fixtures/test_data.xml
20
fixtures = ["test_data.xml"]
22
def testAdminIsATeamChecks(self):
23
"""Test if check for a more complicated LoCo Team setup works
25
teams = Team.objects.all()
26
chile = teams.filter(lp_name="ubuntu-cl")[0]
27
self.assertEquals(launchpad.is_admin_or_owner("pvillavi", chile), True)
29
venezuela = teams.filter(lp_name="ubuntu-ve")[0]
30
self.assertEquals(launchpad.is_admin_or_owner("effie-jayx", venezuela), True)
31
self.assertEquals(launchpad.is_admin_or_owner("jorge", venezuela), False)
33
class EditTeamTestCase(TestCase):
35
test if team update works correct
37
def test_anonymous_user(self):
39
test the team update as anonymous user (not logged in)
41
#try to access team-update page as not logged in user
42
response = self.client.get(reverse( 'team-edit', args=['ubuntu-de-locoteam'] ), follow=True)
43
self.assertRedirects(response, '/openid/login?next=/teams/ubuntu-de-locoteam/edit', status_code=302, target_status_code=200)
44
#try to update team as not logged in user
45
response = self.client.post(reverse('team-edit', args=['ubuntu-de-locoteam']), {'Country':'Germany', 'forum_url':'http://ubuntuusers.de', })
46
self.assertRedirects(response, '/openid/login?next=/teams/ubuntu-de-locoteam/edit', status_code=302, target_status_code=200)
48
def test_user_with_no_rights(self):
50
test the team update with a user which has no rights
53
#FIXME How to use a user with no right with openid?
55
def test_user_loco_council(self):
57
test the team update with a user which is a member of loco council
60
#FIXME How to use a user with this rights with openid?
62
def test_user_admin_or_owner(self):
64
test the team update with a user which is owner or admin
67
#FIXME How to use a user with this rights with openid?