11692.3.1
by Curtis Hovey
Let the PollVoteView choose the template based on the type of poll. |
1 |
# Copyright 2010 Canonical Ltd. This software is licensed under the
|
2 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
|
3 |
||
4 |
"""Tests for IPoll views."""
|
|
5 |
||
6 |
__metaclass__ = type |
|
7 |
||
8 |
import os |
|
14550.1.1
by Steve Kowalik
Run format-imports over lib/lp and lib/canonical/launchpad |
9 |
|
11692.3.1
by Curtis Hovey
Let the PollVoteView choose the template based on the type of poll. |
10 |
from lp.registry.interfaces.poll import PollAlgorithm |
11 |
from lp.testing import TestCaseWithFactory |
|
14612.2.1
by William Grant
format-imports on lib/. So many imports. |
12 |
from lp.testing.layers import DatabaseFunctionalLayer |
11692.3.1
by Curtis Hovey
Let the PollVoteView choose the template based on the type of poll. |
13 |
from lp.testing.views import create_view |
14 |
||
15 |
||
16 |
class TestPollVoteView(TestCaseWithFactory): |
|
17 |
||
18 |
layer = DatabaseFunctionalLayer |
|
19 |
||
20 |
def setUp(self): |
|
21 |
super(TestPollVoteView, self).setUp() |
|
22 |
self.team = self.factory.makeTeam() |
|
23 |
||
24 |
def test_simple_poll_template(self): |
|
25 |
poll = self.factory.makePoll( |
|
26 |
self.team, 'name', 'title', 'proposition', |
|
27 |
poll_type=PollAlgorithm.SIMPLE) |
|
28 |
view = create_view(poll, name='+vote') |
|
29 |
self.assertEqual( |
|
30 |
'poll-vote-simple.pt', os.path.basename(view.template.filename)) |
|
31 |
||
32 |
def test_condorcet_poll_template(self): |
|
33 |
poll = self.factory.makePoll( |
|
34 |
self.team, 'name', 'title', 'proposition', |
|
35 |
poll_type=PollAlgorithm.CONDORCET) |
|
36 |
view = create_view(poll, name='+vote') |
|
37 |
self.assertEqual( |
|
38 |
'poll-vote-condorcet.pt', |
|
39 |
os.path.basename(view.template.filename)) |