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

« back to all changes in this revision

Viewing changes to olsjenkaas/tests/test_launchpad.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
1
# This file is part of Online Services Jenkaas.
2
2
#
3
 
# Copyright 2016 Canonical Ltd.
 
3
# Copyright 2016, 2017 Canonical Ltd.
4
4
#
5
5
# This program is free software: you can redistribute it and/or modify it under
6
6
# the terms of the GNU General Public License version 3, as published by the
17
17
import unittest
18
18
 
19
19
 
20
 
from olstests import features
21
 
 
22
 
 
23
 
from olsjenkaas import (
24
 
    config,
25
 
    launchpad,
26
 
)
27
 
from olsjenkaas.tests import (
28
 
    features as oj_features,
29
 
    fixtures,
30
 
)
31
 
 
32
 
 
33
 
@features.requires(oj_features.qastaging_token)
 
20
from olsjenkaas.tests import fixtures
 
21
 
 
22
 
34
23
class TestLaunchpad(unittest.TestCase):
35
24
 
36
25
    def setUp(self):
37
26
        super(TestLaunchpad, self).setUp()
38
 
        fixtures.use_qastaging(self)
39
 
 
40
 
    def get_lp(self):
41
 
        return launchpad.Launchpad(config.JenkaasStack())
 
27
        self.lp = fixtures.use_qastaging(self)
42
28
 
43
29
    def test_unknown_project(self):
44
 
        lp = self.get_lp()
45
30
        with self.assertRaises(KeyError) as cm:
46
 
            lp.get_project('I-dont-exist')
 
31
            self.lp.get_project('I-dont-exist')
47
32
        self.assertEqual('I-dont-exist', cm.exception.args[0])
48
33
 
49
34
    def test_known_project(self):
50
 
        lp = self.get_lp()
51
 
        project = lp.get_project('ols-jenkaas-test-project')
 
35
        project = self.lp.get_project('ols-jenkaas-test-project')
52
36
        self.assertEqual('ols-jenkaas-test-project', project.display_name)
53
37
        # FIXME: This means we need a different project for bzr tests
54
38
        # -- vila 2016-11-10
55
39
        self.assertEqual('Git', project.vcs)
56
40
 
57
41
    def test_unknown_bzr_branch(self):
58
 
        lp = self.get_lp()
59
 
        branch = lp.get_bzr_branch('lp:I-dont-exist')
 
42
        branch = self.lp.get_bzr_branch('lp:I-dont-exist')
60
43
        self.assertIs(None, branch)
61
44
 
62
45
    def test_known_bzr_branch(self):
63
 
        lp = self.get_lp()
64
 
        branch = lp.get_bzr_branch('lp:bzr')
 
46
        branch = self.lp.get_bzr_branch(
 
47
            'lp:~ubuntuone-hackers/ols-jenkaas-test-project/trunk')
65
48
        self.assertIsNot(None, branch)
66
49
 
67
50
    def test_unknown_git_repo(self):
68
 
        lp = self.get_lp()
69
 
        git_repo = lp.get_git_repo('lp:I-dont-exist')
 
51
        git_repo = self.lp.get_git_repo('lp:I-dont-exist')
70
52
        self.assertIs(None, git_repo)
71
53
 
72
54
    def test_bogus_git_repo(self):
73
 
        lp = self.get_lp()
74
55
        with self.assertRaises(ValueError):
75
 
            lp.get_git_repo('bogus')
 
56
            self.lp.get_git_repo('bogus')
76
57
 
77
58
    def test_known_git_repo(self):
78
 
        lp = self.get_lp()
79
59
        # This relies on manually seeded data (see doc/tests.rst) and can fail
80
60
        # if qastaging is reset
81
 
        git_repo = lp.get_git_repo('lp:ols-jenkaas-test-project')
 
61
        git_repo = self.lp.get_git_repo('lp:ols-jenkaas-test-project')
82
62
        self.assertIsNot(None, git_repo)
83
63
        self.assertEqual('~ubuntuone-hackers/ols-jenkaas-test-project/'
84
64
                         '+git/ols-jenkaas-test-project',