Merge lp:~mhall119/loco-team-portal/fix.806005 into lp:~daker/loco-team-portal/fix.806005

Proposed by Michael Hall
Status: Merged
Merge reported by: Adnane Belmadiaf
Merged at revision: not available
Proposed branch: lp:~mhall119/loco-team-portal/fix.806005
Merge into: lp:~daker/loco-team-portal/fix.806005
Diff against target: 91 lines (+67/-15)
1 file modified
loco_directory/events/tests.py (+67/-15)
To merge this branch: bzr merge lp:~mhall119/loco-team-portal/fix.806005
Reviewer Review Type Date Requested Status
Adnane Belmadiaf Pending
Review via email: mp+68181@code.launchpad.net

Description of the change

Adds a test case to show that the validation works

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'loco_directory/events/tests.py'
--- loco_directory/events/tests.py 2009-12-21 20:45:43 +0000
+++ loco_directory/events/tests.py 2011-07-17 18:14:28 +0000
@@ -4,20 +4,72 @@
44
5Replace these with more appropriate tests for your application.5Replace these with more appropriate tests for your application.
6"""6"""
7import datetime
78
8from django.test import TestCase9from django.test import TestCase
910from django.contrib.auth.models import User, Group
10class SimpleTest(TestCase):11from teams.models import Country, Team
11 def test_basic_addition(self):12from venues.models import Venue
12 """13from events.models import TeamEvent
13 Tests that 1 + 1 always equals 2.14
14 """15
15 self.failUnlessEqual(1 + 1, 2)16class FormTests(TestCase):
1617
17__test__ = {"doctest": """18 def setUp(self):
18Another way to test that 1 + 1 is equal to 2.19 # setup country record for testing
1920 self.country = Country.objects.create(name='Test Country')
20>>> 1 + 1 == 221
21True22 # setup team record for testing
22"""}23 self.team = Team.objects.create(
2324 lp_name='test-team',
25 name='Test Team',
26 )
27 self.team.countries.add(self.country)
28
29 # setup venue record for testing
30 self.venue = Venue.objects.create(
31 name='Test Venue',
32 country=self.country,
33 )
34
35 # setup event record for testing
36 self.event = TeamEvent.objects.create(
37 name='Test Event',
38 date_begin=datetime.datetime.now(),
39 date_end=datetime.datetime.now() + datetime.timedelta(hours=1),
40 venue=self.venue,
41 )
42 self.event.teams.add(self.team)
43
44 # setup user record for testing
45 self.team_group = Group.objects.create(
46 name=self.team.lp_name,
47 )
48 self.user = User.objects.create(
49 username='testuser',
50 )
51 self.user.set_password('test')
52 self.user.groups.add(self.team_group)
53 self.user.save()
54
55
56 def test_large_guest_validation(self):
57 'Validate the guests size and show friendly error message when too big'
58
59 # register attendence form data
60 path = '/events/%s/%s/register/' % (self.team.lp_name, self.event.id)
61 data = {
62 'promise': 'sure',
63 'guests': 1000000,
64 }
65 # login so we're not redirected when posting the form data
66 self.client.login(username='testuser', password='test')
67
68 # post the form data
69 response = self.client.post(path, data)
70
71 # should get a 200 if the integer size is caught by form validation
72 self.assertEquals(response.status_code, 200)
73
74 # check that the user friendly error message exists in the response
75 self.assertContains(response, 'Ensure this value is less than or equal to 100.')

Subscribers

People subscribed via source and target branches

to all changes: