~daker/loco-team-portal/fix.960695.events-app2

« back to all changes in this revision

Viewing changes to loco_directory/events/tests.py

  • Committer: Adnane Belmadiaf
  • Date: 2012-06-30 23:44:14 UTC
  • Revision ID: daker@ubuntu.com-20120630234414-r2brllxyn52o24oy
Fixed the events app to passe pylint checkers

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
    def setUp(self):
19
19
        # setup country record for testing
20
20
        self.country = Country.objects.create(name='Test Country')
21
 
        
22
21
        # setup team record for testing
23
22
        self.team = Team.objects.create(
24
23
            lp_name='test-team',
25
24
            name='Test Team',
26
25
        )
27
26
        self.team.countries.add(self.country)
28
 
        
29
27
        # setup venue record for testing
30
28
        self.venue = Venue.objects.create(
31
29
            name='Test Venue',
32
30
            country=self.country,
33
31
        )
34
 
        
35
32
        # setup event record for testing
36
33
        self.event = TeamEvent.objects.create(
37
34
            name='Test Event',
40
37
            venue=self.venue,
41
38
        )
42
39
        self.event.teams.add(self.team)
43
 
        
44
40
        # setup user record for testing
45
41
        self.team_group = Group.objects.create(
46
42
            name=self.team.lp_name,
51
47
        self.user.set_password('test')
52
48
        self.user.groups.add(self.team_group)
53
49
        self.user.save()
54
 
        
55
50
 
56
51
    def test_large_guest_validation(self):
57
52
        'Validate the guests size and show friendly error message when too big'
58
 
        
 
53
 
59
54
        # register attendence form data
60
55
        path = '/events/%s/%s/register/' % (self.team.lp_name, self.event.id)
61
56
        data = {
64
59
        }
65
60
        # login so we're not redirected when posting the form data
66
61
        self.client.login(username='testuser', password='test')
67
 
        
68
62
        # post the form data
69
63
        response = self.client.post(path, data)
70
64
 
71
65
        # should get a 200 if the integer size is caught by form validation
72
66
        self.assertEquals(response.status_code, 200)
73
 
        
 
67
 
74
68
        # check that the user friendly error message exists in the response
75
69
        self.assertContains(response, 'Ensure this value is less than or equal to 100.')