~summit-hackers/summit/1.x

« back to all changes in this revision

Viewing changes to summit/sponsor/tests.py

  • Committer: Michael Hall
  • Date: 2011-08-22 15:51:55 UTC
  • mfrom: (141.1.4 1.x)
  • Revision ID: mhall119@ubuntu.com-20110822155155-pn0j2lmit25yadkv
Fix errors when converting sponsorship scores to unicode strings

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Ubuntu Developer Summit web application
 
2
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
 
3
#
 
4
# This program is free software: you can redistribute it and/or modify
 
5
# it under the terms of the GNU Affero General Public License as
 
6
# published by the Free Software Foundation, either version 3 of the
 
7
# License, or (at your option) any later version.
 
8
#
 
9
# This program is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU Affero General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU Affero General Public License
 
15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
 
 
17
 
 
18
import datetime
 
19
import unittest
 
20
from django import test as djangotest
 
21
from django.core.urlresolvers import reverse
 
22
 
 
23
from django.contrib.auth.models import User
 
24
from summit.schedule.models import Summit
 
25
from summit.sponsor.models import (
 
26
    SponsorshipSuggestion,
 
27
    SponsorshipSuggestionScore,
 
28
    NonLaunchpadSponsorship,
 
29
    NonLaunchpadSponsorshipScore,
 
30
)
 
31
 
 
32
class SponsorshipDisplayTestCase(djangotest.TestCase):
 
33
    """Tests for the 'reschedule' management command."""
 
34
 
 
35
    def setUp(self):
 
36
        self.summit = Summit.objects.create(
 
37
            name='test-summit',
 
38
            title='Test Summit',
 
39
            location='Test Location',
 
40
            description='Test Summit Description',
 
41
            timezone='UTC',
 
42
            last_update=datetime.datetime.now(),
 
43
            state='sponsor',
 
44
            date_start=(datetime.datetime.now() + datetime.timedelta(days=1)),
 
45
            date_end=(datetime.datetime.now() + datetime.timedelta(days=6)),
 
46
        )
 
47
        
 
48
        self.user = User.objects.create(
 
49
            username='testuser',
 
50
            first_name='Test',
 
51
            last_name='User',
 
52
        )
 
53
        
 
54
    def test_sponsorship_display(self):
 
55
        sponsorship = SponsorshipSuggestion.objects.create(
 
56
            suggested_by=self.user,
 
57
            name='Test Suggestion',
 
58
            launchpad_name='testsuggestion',
 
59
            summit=self.summit,
 
60
            location='Test Location',
 
61
            country='Test Country',
 
62
            about='Test About Description',
 
63
            needs_travel=False,
 
64
            needs_accomodation=False,
 
65
            would_crew=True,
 
66
            diet='Test Diet',
 
67
            further_info='Test Further Info',
 
68
        )
 
69
        
 
70
        scorer = User.objects.create(
 
71
            username='testscorer',
 
72
            first_name='Test',
 
73
            last_name='Scorer',
 
74
        )
 
75
        score = SponsorshipSuggestionScore.objects.create(
 
76
            sponsorship=sponsorship,
 
77
            user=scorer,
 
78
            score=1,
 
79
            comment='Test Comment',
 
80
        )
 
81
        
 
82
        self.assertEquals(unicode(score), "testsuggestion by testscorer: 1")
 
83
 
 
84
    def test_nonlaunchpad_display(self):
 
85
        sponsorship = NonLaunchpadSponsorship.objects.create(
 
86
            requested_by=self.user,
 
87
            name='Test Sponsorship',
 
88
            company='Test Company',
 
89
            email='test@example.org',
 
90
            summit=self.summit,
 
91
            location='Test Location',
 
92
            country='Test Country',
 
93
            about='Test About Description',
 
94
            needs_travel=False,
 
95
            needs_accomodation=False,
 
96
            would_crew=True,
 
97
            diet='Test Diet',
 
98
            further_info='Test Further Info',
 
99
        )
 
100
        
 
101
        scorer = User.objects.create(
 
102
            username='testscorer',
 
103
            first_name='Test',
 
104
            last_name='Scorer',
 
105
        )
 
106
        score = NonLaunchpadSponsorshipScore.objects.create(
 
107
            sponsorship=sponsorship,
 
108
            user=scorer,
 
109
            score=1,
 
110
            comment='Test Comment',
 
111
        )
 
112
        
 
113
        self.assertEquals(unicode(score), "Test Sponsorship by testscorer: 1")
 
114