1
1
# This file is part of Online Services Jenkaas.
3
# Copyright 2016 Canonical Ltd.
3
# Copyright 2016, 2017 Canonical Ltd.
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
20
from olstests import features
23
from olsjenkaas import (
27
from olsjenkaas.tests import (
28
features as oj_features,
33
@features.requires(oj_features.qastaging_token)
20
from olsjenkaas.tests import fixtures
34
23
class TestLaunchpad(unittest.TestCase):
37
26
super(TestLaunchpad, self).setUp()
38
fixtures.use_qastaging(self)
41
return launchpad.Launchpad(config.JenkaasStack())
27
self.lp = fixtures.use_qastaging(self)
43
29
def test_unknown_project(self):
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])
49
34
def test_known_project(self):
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)
57
41
def test_unknown_bzr_branch(self):
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)
62
45
def test_known_bzr_branch(self):
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)
67
50
def test_unknown_git_repo(self):
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)
72
54
def test_bogus_git_repo(self):
74
55
with self.assertRaises(ValueError):
75
lp.get_git_repo('bogus')
56
self.lp.get_git_repo('bogus')
77
58
def test_known_git_repo(self):
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',