~verterok/ols-jenkaas/dd-siab-dependencies

« back to all changes in this revision

Viewing changes to olsjenkaas/tests/test_proposals.py

  • Committer: Vincent Ladeuil
  • Date: 2017-02-09 16:12:35 UTC
  • mfrom: (323.2.109 lander)
  • Revision ID: vila+ols@canonical.com-20170209161235-8igi05uo09s638fv
Unify lander with tests and jobs tags for validation without service interruption

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Copyright 2017 Canonical Ltd.
 
3
#
 
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.
 
7
#
 
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.
 
12
#
 
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/>.
 
15
 
 
16
from __future__ import unicode_literals
 
17
 
 
18
import unittest
 
19
 
 
20
 
 
21
from olstests import scenarii
 
22
 
 
23
 
 
24
from olsjenkaas import launchpad
 
25
from olsjenkaas.tests import fixtures
 
26
 
 
27
 
 
28
load_tests = scenarii.load_tests_with_scenarios
 
29
 
 
30
 
 
31
class TestProposals(unittest.TestCase):
 
32
 
 
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()))]
 
37
 
 
38
    def setUp(self):
 
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)
 
44
 
 
45
    def test_no_mps(self):
 
46
        self.assertEqual([], list(self.target_lp_branch.landing_candidates))
 
47
 
 
48
    def test_create_simple_mp(self):
 
49
        proposal = fixtures.create_proposal(self, 'proposal-1')
 
50
        self.assertEqual('Needs review', proposal.queue_status)
 
51
 
 
52
 
 
53
class TestVotes(unittest.TestCase):
 
54
 
 
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()))]
 
59
 
 
60
    def setUp(self):
 
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')
 
67
 
 
68
    def assertApproved(self):
 
69
        approved = launchpad.is_approved(self.proposal, self.target_lp_branch)
 
70
        self.assertTrue(approved)
 
71
 
 
72
    def assertNotApproved(self):
 
73
        approved = launchpad.is_approved(self.proposal, self.target_lp_branch)
 
74
        self.assertFalse(approved)
 
75
 
 
76
    def test_no_votes(self):
 
77
        # No vote means the proposal is not approved
 
78
        self.assertNotApproved()
 
79
 
 
80
    def test_last_vote_wins(self):
 
81
        # Only the last vote is taken into account
 
82
        self.proposal.createComment(subject='subject1', vote='Approve',
 
83
                                    content='content1')
 
84
        self.assertApproved()
 
85
        self.proposal.createComment(subject='subject2', vote='Needs Fixing',
 
86
                                    content='content1')
 
87
        self.assertNotApproved()
 
88
 
 
89
    def test_outsider_vote(self):
 
90
        # Fake an outsider vote
 
91
 
 
92
        # outsiders can't approve
 
93
        pass
 
94
 
 
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()
 
100
 
 
101
    def test_approve_vote(self):
 
102
        # One authorized approved vote approves the proposal
 
103
        self.proposal.createComment(subject='subject1', vote='Approve',
 
104
                                    content='content1')
 
105
        self.assertApproved()