~lamont/loco-team-portal/production-merge-urt18784

« back to all changes in this revision

Viewing changes to loco_directory/teams/tests.py

  • Committer: Daniel Holbach
  • Date: 2009-12-21 11:03:49 UTC
  • Revision ID: daniel.holbach@canonical.com-20091221110349-bo2zmme5i2e4egif
start at revision 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from django.test import TestCase
 
2
 
 
3
from teams.models import *
 
4
from common import launchpad
 
5
 
 
6
from django.core.urlresolvers import reverse
 
7
 
 
8
 
 
9
class LoCoCouncilACLTestCase(TestCase):
 
10
    def testACLs(self):
 
11
        """Test if LoCo Council check works
 
12
        """
 
13
        self.assertEquals(launchpad.is_user_on_loco_council("popey"), True)
 
14
        self.assertEquals(launchpad.is_user_on_loco_council("jonobacon"), False)
 
15
 
 
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"]
 
21
    
 
22
    def testAdminIsATeamChecks(self):
 
23
        """Test if check for a more complicated LoCo Team setup works
 
24
        """
 
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)
 
28
 
 
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)
 
32
 
 
33
class EditTeamTestCase(TestCase):
 
34
    """
 
35
    test if team update works correct
 
36
    """
 
37
    def test_anonymous_user(self):
 
38
        """
 
39
        test the team update as anonymous user (not logged in)
 
40
        """
 
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)
 
47
    
 
48
    def test_user_with_no_rights(self):
 
49
        """
 
50
        test the team update with a user which has no rights
 
51
        """
 
52
        pass
 
53
        #FIXME How to use a user with no right with openid?
 
54
    
 
55
    def test_user_loco_council(self):
 
56
        """
 
57
        test the team update with a user which is a member of loco council
 
58
        """
 
59
        pass
 
60
        #FIXME How to use a user with this rights with openid?
 
61
 
 
62
    def test_user_admin_or_owner(self):
 
63
        """
 
64
        test the team update with a user which is owner or admin
 
65
        """
 
66
        pass
 
67
        #FIXME How to use a user with this rights with openid?
 
68
 
 
69
 
 
70
 
 
71