2
# Copyright 2017 Canonical Ltd.
4
# This program is free software: you can redistribute it and/or modify it under
5
# the terms of the GNU General Public License version 3, as published by the
6
# Free Software Foundation.
8
# This program is distributed in the hope that it will be useful, but WITHOUT
9
# ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10
# SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
# General Public License for more details.
13
# You should have received a copy of the GNU General Public License along with
14
# this program. If not, see <http://www.gnu.org/licenses/>.
16
from __future__ import unicode_literals
21
from olstests import scenarii
24
from olsjenkaas import launchpad
25
from olsjenkaas.tests import fixtures
28
load_tests = scenarii.load_tests_with_scenarios
31
class TestProposals(unittest.TestCase):
33
scenarios = [('bzr', dict(branch_handler=fixtures.BzrBranchHandler(),
34
proposal_handler=fixtures.BzrProposalHandler())),
35
('git', dict(branch_handler=fixtures.GitRepositoryHandler(),
36
proposal_handler=fixtures.GitProposalHandler()))]
39
super(TestProposals, self).setUp()
40
self.lp = fixtures.use_qastaging(self)
41
self.branch_handler.set_identity(self)
42
self.branch_handler.set_launchpad_access(self)
43
fixtures.setup_proposal_target(self)
45
def test_no_mps(self):
46
self.assertEqual([], list(self.target_lp_branch.landing_candidates))
48
def test_create_simple_mp(self):
49
proposal = fixtures.create_proposal(self, 'proposal-1')
50
self.assertEqual('Needs review', proposal.queue_status)
53
class TestVotes(unittest.TestCase):
55
scenarios = [('bzr', dict(branch_handler=fixtures.BzrBranchHandler(),
56
proposal_handler=fixtures.BzrProposalHandler())),
57
('git', dict(branch_handler=fixtures.GitRepositoryHandler(),
58
proposal_handler=fixtures.GitProposalHandler()))]
61
super(TestVotes, self).setUp()
62
self.lp = fixtures.use_qastaging(self)
63
self.branch_handler.set_identity(self)
64
self.branch_handler.set_launchpad_access(self)
65
fixtures.setup_proposal_target(self)
66
self.proposal = fixtures.create_proposal(self, 'wip')
68
def assertApproved(self):
69
approved = launchpad.is_approved(self.proposal, self.target_lp_branch)
70
self.assertTrue(approved)
72
def assertNotApproved(self):
73
approved = launchpad.is_approved(self.proposal, self.target_lp_branch)
74
self.assertFalse(approved)
76
def test_no_votes(self):
77
# No vote means the proposal is not approved
78
self.assertNotApproved()
80
def test_last_vote_wins(self):
81
# Only the last vote is taken into account
82
self.proposal.createComment(subject='subject1', vote='Approve',
85
self.proposal.createComment(subject='subject2', vote='Needs Fixing',
87
self.assertNotApproved()
89
def test_outsider_vote(self):
90
# Fake an outsider vote
92
# outsiders can't approve
95
def test_pending_vote(self):
96
# A pending vote blocks proposal approval
97
# FIXME: A better test would be to add a review request for another
98
# user -- vila 2017-01-26
99
self.assertNotApproved()
101
def test_approve_vote(self):
102
# One authorized approved vote approves the proposal
103
self.proposal.createComment(subject='subject1', vote='Approve',
105
self.assertApproved()