Merge ~paride/jenkins-launchpad-plugin:py3 into jenkins-launchpad-plugin:master

Proposed by Paride Legovini
Status: Merged
Approved by: Joshua Powers
Approved revision: 13a579d13a9737bf7fbc713e081e8779b6b8cd77
Merged at revision: eaed6b64dac253eb20c5754af5092eddc7c298fb
Proposed branch: ~paride/jenkins-launchpad-plugin:py3
Merge into: jenkins-launchpad-plugin:master
Diff against target: 1189 lines (+155/-161)
29 files modified
.gitignore (+10/-7)
dev/null (+0/-1)
jlp/__init__.py (+1/-1)
jlp/branch.py (+2/-2)
jlp/commands/autoland.py (+2/-2)
jlp/commands/voteOnMergeProposal.py (+1/-2)
jlp/dputrunner.py (+1/-1)
jlp/jenkinsutils.py (+6/-8)
jlp/jsonjenkins.py (+6/-6)
jlp/launchpadagent.py (+2/-2)
jlp/launchpadutils.py (+3/-3)
scripts/autoland (+1/-1)
scripts/dput (+1/-1)
scripts/getMergeProposals (+1/-1)
scripts/launchpadTrigger (+1/-1)
scripts/voteOnMergeProposal (+1/-1)
setup.py (+2/-1)
tests/__init__.py (+1/-1)
tests/test_autoland.py (+21/-16)
tests/test_bzrrecipe.py (+17/-17)
tests/test_dput.py (+1/-1)
tests/test_dputrunner.py (+5/-15)
tests/test_getMergeProposals.py (+7/-7)
tests/test_jenkinsutils.py (+13/-16)
tests/test_jlp.py (+15/-15)
tests/test_launchpadTrigger.py (+5/-4)
tests/test_launchpadutils.py (+10/-11)
tests/test_voteOnMergeProposal.py (+18/-16)
tests/util.py (+1/-1)
Reviewer Review Type Date Requested Status
Joshua Powers (community) Approve
Review via email: mp+376145@code.launchpad.net

Commit message

Convert package to Python 3

To post a comment you must log in.
Revision history for this message
Paride Legovini (paride) wrote :

All the tests are passing. Can be tested with:

 $ python3 setup.py build test clean

As for tarmac I have a branch with a overhauled debian/ directory, but let's take care of the Python 3 conversion first.

Revision history for this message
Joshua Powers (powersj) wrote :

Can you show an example of this working using some test LP project please? Otherwise 2 in-line questions?

Revision history for this message
Paride Legovini (paride) wrote :

Thanks for reviewing. I'll setup a test project. On the inline questions: both the lines are left overs from me debugging the test, they are to be removed.

Revision history for this message
Paride Legovini (paride) wrote :

Lines removed; all tests still passing.

Revision history for this message
Paride Legovini (paride) wrote :

Tested against the lp:paride-test-project project. This is the MP I used for testing:

https://code.launchpad.net/~legovini/paride-test-project/+git/paride-test-project/+merge/376785

voteOnMergeProposal marked it as Needs Fixing when the result was not PASSED, otherwise it approved it. The autoland script did nothing until I manually set the MP status to Approved. Once I did so it correctly merged the MP. The merged branch is visible in the commit history here:

https://code.launchpad.net/~legovini/paride-test-project/+git/paride-test-project/+ref/master

The allowed_users list in jlp.config works as expected.

I faked the test a little but as I didn't setup a full CI set of jobs to test JLP, instead I pointed it to the curtin-ci Jenkins jobs. I'll do another few tests before merging, but so far it seems to be working fine.

Revision history for this message
Paride Legovini (paride) wrote :

The root of the problem seems to be:

[ 267.086787] cloud-init[1461]: Processing triggers for linux-image-4.4.0-170-generic (4.4.0-170.199) ...
[ 267.410038] cloud-init[1461]: /etc/kernel/postinst.d/zz-flash-kernel:
[ 267.411989] cloud-init[1461]: flash-kernel: deferring update (trigger activated)
[ 267.423883] cloud-init[1461]: Processing triggers for flash-kernel (3.0~rc.4ubuntu62.2) ...
[ 267.563889] cloud-init[1461]: Can't find /boot/vmlinuz-4.4.0-170-generic or /boot/initrd.img-4.4.0-170-generic
[ 267.579645] cloud-init[1461]: dpkg: error processing package flash-kernel (--configure):
[ 267.591371] cloud-init[1461]: subprocess installed post-installation script returned error exit status 1
[ 267.596234] cloud-init[1461]: Errors were encountered while processing:
[ 267.599077] cloud-init[1461]: flash-kernel

Likely to be caused by this commit:

https://git.launchpad.net/curtin/commit/?id=04adfd9a83964ccec944b0f015143ea3b5b21473

Possible workaround: restrict the "run update-initramfs once" logic to arm64 until we find what goes wrong on arm64 and s390x.

Revision history for this message
Paride Legovini (paride) wrote :

Wrong brower tab :)

Revision history for this message
Joshua Powers (powersj) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/.gitignore b/.gitignore
index bf01a23..9379187 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,11 @@
1docs/_build/*1docs/_build/*
2./bin2/bin
3./share3/share
4./local4/local
5./lib5/lib
6./include6/include
7./jenkins_launchpad_plugin.egg-info7/jenkins_launchpad_plugin.egg-info
8./man8/man
9__pycache__
10*.pyc
11build
diff --git a/HACKING b/HACKING
9deleted file mode 10064412deleted file mode 100644
index b0555b8..0000000
--- a/HACKING
+++ /dev/null
@@ -1,23 +0,0 @@
1If you are not running Ubuntu raring or later you will need run the
2following in order to install pyruntest:
3 * sudo add-apt-repository ppa:autopilot/ppa
4
5
6You need the following if you want to make changes/run this project:
7 * sudo apt-get install -y python-launchpadlib python-bzrlib python-mock python-testtools python-jenkins python-lockfile python-testscenarios python-pyruntest python-yaml python-git python-jinja2
8 * install tarmac:
9 bzr branch lp:tarmac
10 cd tarmac
11 sudo python setup.py install
12
13To run the tests:
14 * pyruntest tests
15
16Virtualenv instructions:
17$ sudo apt-get install python-virtualenv
18$ virtualenv . --system-site-packages
19$ bin/python setup.py develop
20$ bzr branch lp:tarmac ../tarmac
21$ jlp=$(pwd)
22$ cd ../tarmac
23$ $jlp/bin/python setup.py install
diff --git a/autoland.py b/autoland.py
24deleted file mode 1200000deleted file mode 120000
index f8abc68..0000000
--- a/autoland.py
+++ /dev/null
@@ -1 +0,0 @@
1scripts/autoland
2\ No newline at end of file0\ No newline at end of file
diff --git a/dput b/dput
3deleted file mode 1200001deleted file mode 120000
index f63205d..0000000
--- a/dput
+++ /dev/null
@@ -1 +0,0 @@
1scripts/dput
2\ No newline at end of file0\ No newline at end of file
diff --git a/getMergeProposals.py b/getMergeProposals.py
3deleted file mode 1200001deleted file mode 120000
index 80e275c..0000000
--- a/getMergeProposals.py
+++ /dev/null
@@ -1 +0,0 @@
1scripts/getMergeProposals
2\ No newline at end of file0\ No newline at end of file
diff --git a/jlp/__init__.py b/jlp/__init__.py
index 00d6adc..9802aea 100644
--- a/jlp/__init__.py
+++ b/jlp/__init__.py
@@ -8,7 +8,7 @@ jlp
8"""8"""
99
10__name__ = 'jlp'10__name__ = 'jlp'
11__version__ = '0.1'11__version__ = '3.1'
12__author__ = 'Martin Mrazik'12__author__ = 'Martin Mrazik'
1313
14import jinja214import jinja2
diff --git a/jlp/branch.py b/jlp/branch.py
index 5334d6f..9462f88 100644
--- a/jlp/branch.py
+++ b/jlp/branch.py
@@ -1,7 +1,7 @@
1import logging1import logging
2from bzrlib.plugin import load_plugins2from breezy.plugin import load_plugins
3load_plugins()3load_plugins()
4from bzrlib import branch as bzr_branch4from breezy import branch as bzr_branch
5from tarmac.branch import Branch as TarmacBranch5from tarmac.branch import Branch as TarmacBranch
6from tarmac.branch import BranchConfig6from tarmac.branch import BranchConfig
7from jlp import get_config_option7from jlp import get_config_option
diff --git a/jlp/commands/__init__.py b/jlp/commands/__init__.py
8deleted file mode 1006448deleted file mode 100644
index e69de29..0000000
--- a/jlp/commands/__init__.py
+++ /dev/null
diff --git a/jlp/commands/autoland.py b/jlp/commands/autoland.py
index ba95372..a4552f0 100644
--- a/jlp/commands/autoland.py
+++ b/jlp/commands/autoland.py
@@ -7,10 +7,10 @@ from jlp.launchpadutils import (LaunchpadVote, get_vote_subject,
7 get_target_branch, get_source_branch,7 get_target_branch, get_source_branch,
8 is_git_project)8 is_git_project)
9from jlp import (launchpadutils, Branch,9from jlp import (launchpadutils, Branch,
10 DputRunner, jenkinsutils, get_launchpad,10 DputRunner, get_launchpad,
11 get_config_option, logger, get_jinja_environment)11 get_config_option, logger, get_jinja_environment)
12from tarmac.exceptions import TarmacMergeError, BranchHasConflicts12from tarmac.exceptions import TarmacMergeError, BranchHasConflicts
13from bzrlib.errors import LockFailed13from breezy.errors import LockFailed
14import os14import os
15from shutil import rmtree15from shutil import rmtree
16import tempfile16import tempfile
diff --git a/jlp/commands/voteOnMergeProposal.py b/jlp/commands/voteOnMergeProposal.py
index dab10ef..bf9f008 100644
--- a/jlp/commands/voteOnMergeProposal.py
+++ b/jlp/commands/voteOnMergeProposal.py
@@ -1,7 +1,6 @@
1from argparse import ArgumentParser1from argparse import ArgumentParser
2import atexit2import atexit
3import jinja23from jlp import launchpadutils, get_launchpad, logger, get_jinja_environment
4from jlp import launchpadutils, get_launchpad, logger, get_config_option, get_jinja_environment
5import re4import re
6import os5import os
7from shutil import rmtree6from shutil import rmtree
diff --git a/jlp/dputrunner.py b/jlp/dputrunner.py
index cfce696..d096d77 100644
--- a/jlp/dputrunner.py
+++ b/jlp/dputrunner.py
@@ -37,7 +37,7 @@ class DputRunner:
37 return self.versionFormat.format(**kwargs)37 return self.versionFormat.format(**kwargs)
38 except KeyError as error:38 except KeyError as error:
39 logger.error('Unkown variable used in format string: ' +39 logger.error('Unkown variable used in format string: ' +
40 error.message)40 str(error))
41 return None41 return None
4242
43 def _run_hooks(self, hooks, cwd):43 def _run_hooks(self, hooks, cwd):
diff --git a/jlp/jenkinsutils.py b/jlp/jenkinsutils.py
index 2083d45..8b94b1b 100644
--- a/jlp/jenkinsutils.py
+++ b/jlp/jenkinsutils.py
@@ -2,18 +2,16 @@ import re
2import os2import os
3from xml.dom.minidom import parseString3from xml.dom.minidom import parseString
4import jenkins4import jenkins
5import urlparse5import urllib
6import urllib26from . import launchpadutils
7import launchpadutils
8from textwrap import dedent
9from . import get_json_jenkins7from . import get_json_jenkins
10from lazr.restfulclient.errors import Unauthorized8from lazr.restfulclient.errors import Unauthorized
11from jlp import logger, get_config_option, get_jinja_environment9from jlp import logger, get_config_option, get_jinja_environment
1210
1311
14def normalize_url(url):12def normalize_url(url):
15 return urlparse.urljoin(url,13 return urllib.parse.urljoin(url,
16 urlparse.urlparse(url).path.replace('//', '/'))14 urllib.parse.urlparse(url).path.replace('//', '/'))
1715
1816
19def _actions_has_param(actions, param, value):17def _actions_has_param(actions, param, value):
@@ -427,7 +425,7 @@ def is_pipeline_job(jenkins, job_url):
427 try:425 try:
428 data = jenkins.get_json_data(job_url + 'wfapi',426 data = jenkins.get_json_data(job_url + 'wfapi',
429 append_api=False)427 append_api=False)
430 except urllib2.HTTPError:428 except urllib.error.HTTPError:
431 data = None429 data = None
432430
433 if data:431 if data:
@@ -755,7 +753,7 @@ def start_jenkins_job(lp_handle, launchpaduser, jenkins_url, jenkins_job, mp,
755 try:753 try:
756 is_merge_only = launchpadutils.is_merge_only(mp)754 is_merge_only = launchpadutils.is_merge_only(mp)
757 except LookupError as error:755 except LookupError as error:
758 logger.error(error.message)756 logger.error(str(error))
759 logger.debug('Skipping this merge proposal')757 logger.debug('Skipping this merge proposal')
760 return False758 return False
761759
diff --git a/jlp/jsonjenkins.py b/jlp/jsonjenkins.py
index 98ab1e4..353043f 100644
--- a/jlp/jsonjenkins.py
+++ b/jlp/jsonjenkins.py
@@ -1,5 +1,5 @@
1import json1import json
2import urllib22import urllib
33
44
5class JSONJenkins():5class JSONJenkins():
@@ -9,11 +9,11 @@ class JSONJenkins():
9 self.jenkins_url = jenkins_url9 self.jenkins_url = jenkins_url
10 self.jenkins_proxy_url = jenkins_proxy_url10 self.jenkins_proxy_url = jenkins_proxy_url
1111
12 passman = urllib2.HTTPPasswordMgrWithDefaultRealm()12 passman = urllib.request.HTTPPasswordMgrWithDefaultRealm()
13 passman.add_password(None, jenkins_url, username, password)13 passman.add_password(None, jenkins_url, username, password)
14 authhandler = urllib2.HTTPBasicAuthHandler(passman)14 authhandler = urllib.request.HTTPBasicAuthHandler(passman)
15 self.urllib_opener = urllib2.build_opener(authhandler)15 self.urllib_opener = urllib.request.build_opener(authhandler)
16 urllib2.install_opener(self.urllib_opener)16 urllib.request.install_opener(self.urllib_opener)
1717
18 def patch_url(self, url):18 def patch_url(self, url):
19 # Test for presence of a url that needs to be patched.19 # Test for presence of a url that needs to be patched.
@@ -30,5 +30,5 @@ class JSONJenkins():
30 url = self.patch_url(url)30 url = self.patch_url(url)
31 if append_api:31 if append_api:
32 url = url + '/api/json'32 url = url + '/api/json'
33 data = urllib2.urlopen(url)33 data = urllib.request.urlopen(url)
34 return json.load(data)34 return json.load(data)
diff --git a/jlp/launchpadagent.py b/jlp/launchpadagent.py
index 65e0621..fd29d81 100644
--- a/jlp/launchpadagent.py
+++ b/jlp/launchpadagent.py
@@ -31,7 +31,7 @@ class AuthorizeRequestTokenWithConsole(RequestTokenAuthorizationEngine):
3131
32 """32 """
33 authorization_url = self.authorization_url(request_token)33 authorization_url = self.authorization_url(request_token)
34 print WAITING_FOR_USER.format(authorization_url)34 print(WAITING_FOR_USER.format(authorization_url))
35 # if we don't flush we may not see the message35 # if we don't flush we may not see the message
36 sys.stdout.flush()36 sys.stdout.flush()
37 while credentials.access_token is None:37 while credentials.access_token is None:
@@ -40,7 +40,7 @@ class AuthorizeRequestTokenWithConsole(RequestTokenAuthorizationEngine):
40 credentials.exchange_request_token_for_access_token(40 credentials.exchange_request_token_for_access_token(
41 self.web_root)41 self.web_root)
42 break42 break
43 except HTTPError, e:43 except HTTPError as e:
44 if e.response.status == 403:44 if e.response.status == 403:
45 # The user decided not to authorize this45 # The user decided not to authorize this
46 # application.46 # application.
diff --git a/jlp/launchpadutils.py b/jlp/launchpadutils.py
index 7197180..4c50bba 100644
--- a/jlp/launchpadutils.py
+++ b/jlp/launchpadutils.py
@@ -1,6 +1,6 @@
1import os, re1import re
2from jlp import logger, get_config_option2from jlp import logger, get_config_option
3import jenkinsutils3from jlp import jenkinsutils
4from . import get_json_jenkins4from . import get_json_jenkins
55
6RE_LP_BUG_IDS = r'LP:(,? #\d+)+\s*$'6RE_LP_BUG_IDS = r'LP:(,? #\d+)+\s*$'
@@ -283,7 +283,7 @@ def users_allowed_to_trigger_jobs(lp_users):
283 try:283 try:
284 allowed_person = lp.people[allowed]284 allowed_person = lp.people[allowed]
285 except KeyError:285 except KeyError:
286 logger.warn('User {} from the allowed_users list is not in '286 logger.warning('User {} from the allowed_users list is not in '
287 'launchpad!'.format(allowed))287 'launchpad!'.format(allowed))
288 continue288 continue
289 if not allowed_person.is_team:289 if not allowed_person.is_team:
diff --git a/launchpadTrigger.py b/launchpadTrigger.py
290deleted file mode 120000290deleted file mode 120000
index 128f211..0000000
--- a/launchpadTrigger.py
+++ /dev/null
@@ -1 +0,0 @@
1scripts/launchpadTrigger
2\ No newline at end of file0\ No newline at end of file
diff --git a/scripts/autoland b/scripts/autoland
index 7ffac75..6279088 100755
--- a/scripts/autoland
+++ b/scripts/autoland
@@ -1,4 +1,4 @@
1#!/usr/bin/env python1#!/usr/bin/env python3
2import sys2import sys
3# this is to keep backwards compatibility with deployments directly from3# this is to keep backwards compatibility with deployments directly from
4# bzr branch4# bzr branch
diff --git a/scripts/dput b/scripts/dput
index 5d4e952..7bef560 100755
--- a/scripts/dput
+++ b/scripts/dput
@@ -1,4 +1,4 @@
1#!/usr/bin/env python1#!/usr/bin/env python3
2import sys2import sys
3# this is to keep backwards compatibility with deployments directly from3# this is to keep backwards compatibility with deployments directly from
4# bzr branch4# bzr branch
diff --git a/scripts/getMergeProposals b/scripts/getMergeProposals
index f21ffaf..c2b072b 100755
--- a/scripts/getMergeProposals
+++ b/scripts/getMergeProposals
@@ -1,4 +1,4 @@
1#!/usr/bin/env python1#!/usr/bin/env python3
2import sys2import sys
3# this is to keep backwards compatibility with deployments directly from3# this is to keep backwards compatibility with deployments directly from
4# bzr branch4# bzr branch
diff --git a/scripts/launchpadTrigger b/scripts/launchpadTrigger
index e62d7fc..28aa2e3 100755
--- a/scripts/launchpadTrigger
+++ b/scripts/launchpadTrigger
@@ -1,4 +1,4 @@
1#!/usr/bin/env python1#!/usr/bin/env python3
2import sys2import sys
3# this is to keep backwards compatibility with deployments directly from3# this is to keep backwards compatibility with deployments directly from
4# bzr branch4# bzr branch
diff --git a/scripts/voteOnMergeProposal b/scripts/voteOnMergeProposal
index c9274a6..61f099c 100755
--- a/scripts/voteOnMergeProposal
+++ b/scripts/voteOnMergeProposal
@@ -1,4 +1,4 @@
1#!/usr/bin/env python1#!/usr/bin/env python3
2import sys2import sys
3# this is to keep backwards compatibility with deployments directly from3# this is to keep backwards compatibility with deployments directly from
4# bzr branch4# bzr branch
diff --git a/setup.py b/setup.py
index db40a0b..346810d 100644
--- a/setup.py
+++ b/setup.py
@@ -1,9 +1,10 @@
1from distutils.core import setup1from distutils.core import setup
2from setuptools import find_packages2from setuptools import find_packages
3from jlp import __version__
3import glob4import glob
4setup(5setup(
5 name='jenkins-launchpad-plugin',6 name='jenkins-launchpad-plugin',
6 version='0.1',7 version=__version__,
7 url='https://launchpad.net/jenkins-launchpad-plugin',8 url='https://launchpad.net/jenkins-launchpad-plugin',
8 packages=find_packages(),9 packages=find_packages(),
9 include_package_data=True,10 include_package_data=True,
diff --git a/tests/__init__.py b/tests/__init__.py
index 2cce6c0..2843c1f 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -160,7 +160,7 @@ class JenkinsJSONData():
160160
161 def get_json_data(self, url, append_api=True):161 def get_json_data(self, url, append_api=True):
162 url = url.rstrip('/')162 url = url.rstrip('/')
163 print url163 print(url)
164 if url == 'http://10.0.0.1:8080/job/my-job':164 if url == 'http://10.0.0.1:8080/job/my-job':
165 return self.job_data165 return self.job_data
166 elif url == 'http://10.0.0.1:8080/job/my-job/3':166 elif url == 'http://10.0.0.1:8080/job/my-job/3':
diff --git a/tests/test_autoland.py b/tests/test_autoland.py
index e6d1aef..e82de4f 100644
--- a/tests/test_autoland.py
+++ b/tests/test_autoland.py
@@ -1,10 +1,10 @@
1import unittest1import unittest
2from mock import patch2from unittest.mock import patch
3from mock import MagicMock3from unittest.mock import MagicMock
4import tests.util as util4import tests.util as util
5from jlp import get_config_option5from jlp import get_config_option
6from tarmac.exceptions import TarmacMergeError, BranchHasConflicts6from tarmac.exceptions import TarmacMergeError, BranchHasConflicts
7from bzrlib.errors import LockFailed7from breezy.errors import LockFailed
8from jlp.launchpadutils import LaunchpadVote8from jlp.launchpadutils import LaunchpadVote
9import jlp.commands.autoland as autoland9import jlp.commands.autoland as autoland
1010
@@ -18,7 +18,7 @@ class TestGetFixesCommitMessage(unittest.TestCase):
18 b.web_link = 'http://' + str(i)18 b.web_link = 'http://' + str(i)
19 mp.source_branch.linked_bugs_collection.append(b)19 mp.source_branch.linked_bugs_collection.append(b)
20 ret = autoland.get_fixes_commit_message(mp)20 ret = autoland.get_fixes_commit_message(mp)
21 expected = ' Fixes: http://0, http://1, http://2, http://3.'21 expected = ' Fixes: http://0, http://1, http://2, http://3'
22 self.assertEqual(ret, expected)22 self.assertEqual(ret, expected)
2323
24 def test_no_bugs(self):24 def test_no_bugs(self):
@@ -198,7 +198,7 @@ class TestAutolandVoting(TestAutolandForMergeAndCommit):
198 def test_last_vote_was_needs_fixing(self):198 def test_last_vote_was_needs_fixing(self):
199 sys_argv = ['autoland.py', '-r', 'PASSED',199 sys_argv = ['autoland.py', '-r', 'PASSED',
200 '-v', '123', '-m', 'url']200 '-v', '123', '-m', 'url']
201 merge_and_commit = lambda x, y: 0201 merge_and_commit = lambda x, y, z: 0
202 get_last_mp_vote = lambda x: LaunchpadVote.NEEDS_FIXING202 get_last_mp_vote = lambda x: LaunchpadVote.NEEDS_FIXING
203 with patch('sys.argv', sys_argv), \203 with patch('sys.argv', sys_argv), \
204 patch(204 patch(
@@ -215,7 +215,7 @@ class TestAutolandVoting(TestAutolandForMergeAndCommit):
215 def test_last_vote_was_approved(self):215 def test_last_vote_was_approved(self):
216 sys_argv = ['autoland.py', '-r', 'PASSED',216 sys_argv = ['autoland.py', '-r', 'PASSED',
217 '-v', '123', '-m', 'url']217 '-v', '123', '-m', 'url']
218 merge_and_commit = lambda y, z: 0218 merge_and_commit = lambda x, y, z: 0
219 get_last_mp_vote = lambda x: LaunchpadVote.APPROVE219 get_last_mp_vote = lambda x: LaunchpadVote.APPROVE
220 with patch('sys.argv', sys_argv), \220 with patch('sys.argv', sys_argv), \
221 patch('jlp.commands.autoland.get_last_mp_vote',221 patch('jlp.commands.autoland.get_last_mp_vote',
@@ -223,7 +223,7 @@ class TestAutolandVoting(TestAutolandForMergeAndCommit):
223 patch('jlp.commands.autoland.merge_and_commit',223 patch('jlp.commands.autoland.merge_and_commit',
224 merge_and_commit):224 merge_and_commit):
225 autoland.autoland()225 autoland.autoland()
226 self.assertEquals(self.mp.createComment.call_count, 0)226 self.assertEqual(self.mp.createComment.call_count, 0)
227227
228228
229class TestAutolandMergeAndCommitWithDescription(TestAutolandForMergeAndCommit):229class TestAutolandMergeAndCommitWithDescription(TestAutolandForMergeAndCommit):
@@ -250,12 +250,13 @@ class TestAutolandWithMultipleDputs(TestAutolandForMergeAndCommit):
250 '-d', 'quantal,precise']250 '-d', 'quantal,precise']
251 dputRunner = MagicMock()251 dputRunner = MagicMock()
252 with patch('sys.argv', sys_argv), \252 with patch('sys.argv', sys_argv), \
253 patch('jlp.commands.autoland.DputRunner', new=dputRunner):253 patch('jlp.commands.autoland.DputRunner', new=dputRunner), \
254 patch('jlp.commands.autoland.get_config_option'):
254 self.assertTrue(autoland.autoland() == 0)255 self.assertTrue(autoland.autoland() == 0)
255 ppas_expected = ['ppa:myppa', 'ppa:myppa2']256 ppas_expected = ['ppa:myppa', 'ppa:myppa2']
256 distributions_expected = ['quantal', 'precise']257 distributions_expected = ['quantal', 'precise']
257 self.assertEquals(ppas_expected, dputRunner.call_args[1]['ppas'])258 self.assertEqual(ppas_expected, dputRunner.call_args[1]['ppas'])
258 self.assertEquals(distributions_expected,259 self.assertEqual(distributions_expected,
259 dputRunner.call_args[1]['distributions'])260 dputRunner.call_args[1]['distributions'])
260261
261262
@@ -266,7 +267,8 @@ class TestAutolandWithReleaseOnly(TestAutolandForMergeAndCommit):
266 '-d', 'quantal', '--release-only']267 '-d', 'quantal', '--release-only']
267 dputRunner = MagicMock()268 dputRunner = MagicMock()
268 with patch('sys.argv', sys_argv), \269 with patch('sys.argv', sys_argv), \
269 patch('jlp.commands.autoland.DputRunner', new=dputRunner):270 patch('jlp.commands.autoland.DputRunner', new=dputRunner), \
271 patch('jlp.commands.autoland.get_config_option'):
270 autoland.autoland()272 autoland.autoland()
271 self.assertTrue(dputRunner.call_args[1]['release_only'])273 self.assertTrue(dputRunner.call_args[1]['release_only'])
272274
@@ -278,10 +280,11 @@ class TestAutolandWithVersionFormatString(TestAutolandForMergeAndCommit):
278 '-d', 'quantal', '-f', '{PACKAGE_VERSION}0']280 '-d', 'quantal', '-f', '{PACKAGE_VERSION}0']
279 dputRunner = MagicMock()281 dputRunner = MagicMock()
280 with patch('sys.argv', sys_argv), \282 with patch('sys.argv', sys_argv), \
281 patch('jlp.commands.autoland.DputRunner', new=dputRunner):283 patch('jlp.commands.autoland.DputRunner', new=dputRunner), \
284 patch('jlp.commands.autoland.get_config_option'):
282 self.assertTrue(autoland.autoland() == 0)285 self.assertTrue(autoland.autoland() == 0)
283 version_format_expected = '{PACKAGE_VERSION}0'286 version_format_expected = '{PACKAGE_VERSION}0'
284 self.assertEquals(version_format_expected,287 self.assertEqual(version_format_expected,
285 dputRunner.call_args[1]['versionFormat'])288 dputRunner.call_args[1]['versionFormat'])
286289
287 def test_quoted_string(self):290 def test_quoted_string(self):
@@ -290,10 +293,11 @@ class TestAutolandWithVersionFormatString(TestAutolandForMergeAndCommit):
290 '-d', 'quantal', '-f', '"{PACKAGE_VERSION}"']293 '-d', 'quantal', '-f', '"{PACKAGE_VERSION}"']
291 dputRunner = MagicMock()294 dputRunner = MagicMock()
292 with patch('sys.argv', sys_argv), \295 with patch('sys.argv', sys_argv), \
293 patch('jlp.commands.autoland.DputRunner', new=dputRunner):296 patch('jlp.commands.autoland.DputRunner', new=dputRunner), \
297 patch('jlp.commands.autoland.get_config_option'):
294 self.assertTrue(autoland.autoland() == 0)298 self.assertTrue(autoland.autoland() == 0)
295 version_format_expected = '{PACKAGE_VERSION}'299 version_format_expected = '{PACKAGE_VERSION}'
296 self.assertEquals(version_format_expected,300 self.assertEqual(version_format_expected,
297 dputRunner.call_args[1]['versionFormat'])301 dputRunner.call_args[1]['versionFormat'])
298302
299303
@@ -317,7 +321,8 @@ class TestAutolandMergeCommitAndDput(TestAutolandForMergeAndCommit):
317 '-a', 'packaging_branch', '-b',321 '-a', 'packaging_branch', '-b',
318 'http://10.0.0.1:8080/job/unity-daily/17/', '-d',322 'http://10.0.0.1:8080/job/unity-daily/17/', '-d',
319 'precise']323 'precise']
320 with patch('sys.argv', sys_argv):324 with patch('sys.argv', sys_argv), \
325 patch('jlp.commands.autoland.get_config_option'):
321 self.assertTrue(autoland.autoland() == 0)326 self.assertTrue(autoland.autoland() == 0)
322 self.assertTrue(self.target.merge.call_count == 1)327 self.assertTrue(self.target.merge.call_count == 1)
323 self.assertTrue(self.target.commit.call_count == 1)328 self.assertTrue(self.target.commit.call_count == 1)
diff --git a/tests/test_bzrrecipe.py b/tests/test_bzrrecipe.py
index be211ea..b31c564 100644
--- a/tests/test_bzrrecipe.py
+++ b/tests/test_bzrrecipe.py
@@ -1,6 +1,6 @@
1import unittest1import unittest
2from mock import patch2from unittest.mock import patch
3from mock import MagicMock3from unittest.mock import MagicMock
4from jlp import BzrRecipe4from jlp import BzrRecipe
5from textwrap import dedent5from textwrap import dedent
66
@@ -15,8 +15,8 @@ class TestBzrRecipeInstantiation(unittest.TestCase):
15 nest-part ubuntu lp:dummy/packaging debian15 nest-part ubuntu lp:dummy/packaging debian
16 ''')16 ''')
17 recipe.generateRecipe()17 recipe.generateRecipe()
18 self.assertEquals(recipe.recipe, expected)18 self.assertEqual(recipe.recipe, expected)
19 self.assertEquals(recipe.getTrunkRevno(), 14)19 self.assertEqual(recipe.getTrunkRevno(), 14)
2020
21 def test_check_recipe_without_explicit_revision(self):21 def test_check_recipe_without_explicit_revision(self):
22 bzr = MagicMock()22 bzr = MagicMock()
@@ -29,8 +29,8 @@ class TestBzrRecipeInstantiation(unittest.TestCase):
29 nest-part ubuntu lp:dummy/packaging debian29 nest-part ubuntu lp:dummy/packaging debian
30 ''')30 ''')
31 recipe.generateRecipe()31 recipe.generateRecipe()
32 self.assertEquals(recipe.recipe, expected)32 self.assertEqual(recipe.recipe, expected)
33 self.assertEquals(recipe.getTrunkRevno(), 10)33 self.assertEqual(recipe.getTrunkRevno(), 10)
3434
35 def test_check_recipe_without_packaging_branch(self):35 def test_check_recipe_without_packaging_branch(self):
36 bzr = MagicMock()36 bzr = MagicMock()
@@ -43,8 +43,8 @@ class TestBzrRecipeInstantiation(unittest.TestCase):
43 # No packaging branch43 # No packaging branch
44 ''')44 ''')
45 recipe.generateRecipe()45 recipe.generateRecipe()
46 self.assertEquals(recipe.recipe, expected)46 self.assertEqual(recipe.recipe, expected)
47 self.assertEquals(recipe.getTrunkRevno(), 10)47 self.assertEqual(recipe.getTrunkRevno(), 10)
4848
49 def test_check_recipe_with_inline_packaging(self):49 def test_check_recipe_with_inline_packaging(self):
50 bzr = MagicMock()50 bzr = MagicMock()
@@ -57,15 +57,15 @@ class TestBzrRecipeInstantiation(unittest.TestCase):
57 # No packaging branch57 # No packaging branch
58 ''')58 ''')
59 recipe.generateRecipe()59 recipe.generateRecipe()
60 self.assertEquals(recipe.recipe, expected)60 self.assertEqual(recipe.recipe, expected)
61 self.assertEquals(recipe.getTrunkRevno(), 10)61 self.assertEqual(recipe.getTrunkRevno(), 10)
6262
63 def test_get_packaging_branch_revno(self):63 def test_get_packaging_branch_revno(self):
64 bzr = MagicMock()64 bzr = MagicMock()
65 bzr.revno = lambda self: 1065 bzr.revno = lambda self: 10
66 with patch('jlp.bzrrecipe.Bazaar', new=MagicMock(return_value=bzr)):66 with patch('jlp.bzrrecipe.Bazaar', new=MagicMock(return_value=bzr)):
67 recipe = BzrRecipe('lp:dummy', 'lp:dummy/packaging', 14)67 recipe = BzrRecipe('lp:dummy', 'lp:dummy/packaging', 14)
68 self.assertEquals(recipe.getPackagingBranchRevno(), 10)68 self.assertEqual(recipe.getPackagingBranchRevno(), 10)
6969
70 def test_getDir_before_tree_building(self):70 def test_getDir_before_tree_building(self):
71 with patch('jlp.bzrrecipe.Bazaar'):71 with patch('jlp.bzrrecipe.Bazaar'):
@@ -219,10 +219,10 @@ class TestBzrRecipe(unittest.TestCase):
219class TestBzrRecipeBuildTree(TestBzrRecipe):219class TestBzrRecipeBuildTree(TestBzrRecipe):
220 def test_buildTree(self):220 def test_buildTree(self):
221 self.recipe.buildTree()221 self.recipe.buildTree()
222 self.assertEquals(222 self.assertEqual(
223 self.open_file.__enter__.return_value.write.call_count, 1)223 self.open_file.__enter__.return_value.write.call_count, 1)
224 self.assertEquals(self.recipe.getBuildDir(), self.temp_dir)224 self.assertEqual(self.recipe.getBuildDir(), self.temp_dir)
225 self.assertEquals(self.recipe.getTrunkDir(),225 self.assertEqual(self.recipe.getTrunkDir(),
226 self.temp_dir + '/trunk')226 self.temp_dir + '/trunk')
227227
228228
@@ -230,10 +230,10 @@ class TestBzrRecipeBuildTreeTwice(TestBzrRecipe):
230 def test_buildTree_twice(self):230 def test_buildTree_twice(self):
231 self.recipe.buildTree()231 self.recipe.buildTree()
232 self.recipe.buildTree()232 self.recipe.buildTree()
233 self.assertEquals(233 self.assertEqual(
234 self.open_file.__enter__.return_value.write.call_count, 1)234 self.open_file.__enter__.return_value.write.call_count, 1)
235 self.assertEquals(self.recipe.getBuildDir(), self.temp_dir)235 self.assertEqual(self.recipe.getBuildDir(), self.temp_dir)
236 self.assertEquals(self.recipe.getTrunkDir(),236 self.assertEqual(self.recipe.getTrunkDir(),
237 self.temp_dir + '/trunk')237 self.temp_dir + '/trunk')
238238
239239
diff --git a/tests/test_dput.py b/tests/test_dput.py
index b9267d9..3977d70 100644
--- a/tests/test_dput.py
+++ b/tests/test_dput.py
@@ -1,6 +1,6 @@
1import jlp.commands.dput as dput1import jlp.commands.dput as dput
2import unittest2import unittest
3from mock import patch, MagicMock3from unittest.mock import patch, MagicMock
44
55
6class TestDput(unittest.TestCase):6class TestDput(unittest.TestCase):
diff --git a/tests/test_dputrunner.py b/tests/test_dputrunner.py
index 80c35bd..8c51f38 100644
--- a/tests/test_dputrunner.py
+++ b/tests/test_dputrunner.py
@@ -1,8 +1,8 @@
1import unittest1import unittest
2from mock import patch, MagicMock2from unittest.mock import patch, MagicMock
3import mock3from unittest import mock
4try:4try:
5 from mock import call5 from unittest.mock import call
6except ImportError:6except ImportError:
7 pass7 pass
8from jlp import DputRunner8from jlp import DputRunner
@@ -69,8 +69,6 @@ class TestDputRunner(TestDputBase):
69 release_only=release_only))69 release_only=release_only))
70 return calls70 return calls
7171
72 @unittest.skipIf(StrictVersion(mock.__version__) < StrictVersion('0.8'),
73 "assert_has_calls not suppored by mock < 0.8")
74 def test_dput(self):72 def test_dput(self):
75 recipe = MagicMock()73 recipe = MagicMock()
76 recipe.getTrunkRevno = lambda: 1074 recipe.getTrunkRevno = lambda: 10
@@ -81,8 +79,6 @@ class TestDputRunner(TestDputBase):
81 calls = self._build_calls(recipe, False)79 calls = self._build_calls(recipe, False)
82 self.dput_runner.doDput.assert_has_calls(calls)80 self.dput_runner.doDput.assert_has_calls(calls)
8381
84 @unittest.skipIf(StrictVersion(mock.__version__) < StrictVersion('0.8'),
85 "assert_has_calls not suppored by mock < 0.8")
86 def test_dput_release_only(self):82 def test_dput_release_only(self):
87 recipe = MagicMock()83 recipe = MagicMock()
88 recipe.getTrunkRevno = lambda: 1084 recipe.getTrunkRevno = lambda: 10
@@ -154,8 +150,6 @@ class TestDput(TestDputBase):
154 cwd='/build'))150 cwd='/build'))
155 return calls151 return calls
156152
157 @unittest.skipIf(StrictVersion(mock.__version__) < StrictVersion('0.8'),
158 "assert_has_calls not suppored by mock < 0.8")
159 def test_doDput(self):153 def test_doDput(self):
160 recipe = self._build_recipe()154 recipe = self._build_recipe()
161 check_call = MagicMock()155 check_call = MagicMock()
@@ -173,8 +167,6 @@ class TestDput(TestDputBase):
173 release_only=False)167 release_only=False)
174 check_call.assert_has_calls(calls)168 check_call.assert_has_calls(calls)
175169
176 @unittest.skipIf(StrictVersion(mock.__version__) < StrictVersion('0.8'),
177 "assert_has_calls not suppored by mock < 0.8")
178 def test_doDput_with_epoch(self):170 def test_doDput_with_epoch(self):
179 recipe = self._build_recipe()171 recipe = self._build_recipe()
180 check_call = MagicMock()172 check_call = MagicMock()
@@ -193,8 +185,6 @@ class TestDput(TestDputBase):
193 release_only=False)185 release_only=False)
194 check_call.assert_has_calls(calls)186 check_call.assert_has_calls(calls)
195187
196 @unittest.skipIf(StrictVersion(mock.__version__) < StrictVersion('0.8'),
197 "assert_has_calls not suppored by mock < 0.8")
198 def test_doReleaseOnlyDput(self):188 def test_doReleaseOnlyDput(self):
199 recipe = self._build_recipe()189 recipe = self._build_recipe()
200 check_call = MagicMock()190 check_call = MagicMock()
@@ -287,7 +277,7 @@ class DPutVersionTests(TestWithScenarios, TestDput):
287277
288 ('unknown tag',278 ('unknown tag',
289 {279 {
290 'formatString': '{PACKAGE_VERSION}-{UNKOWN_TAG}',280 'formatString': '{PACKAGE_VERSION}-{UNKNOWN_TAG}',
291 'variables': {281 'variables': {
292 'PACKAGE_VERSION': 13,282 'PACKAGE_VERSION': 13,
293 'BZR_REVISION': 43,283 'BZR_REVISION': 43,
@@ -303,4 +293,4 @@ class DPutVersionTests(TestWithScenarios, TestDput):
303 self.make_dput_runner(versionFormat=self.formatString)293 self.make_dput_runner(versionFormat=self.formatString)
304294
305 result_format = self.dput_runner.formatVersionString(**self.variables)295 result_format = self.dput_runner.formatVersionString(**self.variables)
306 self.assertEquals(self.expectedResult, result_format)296 self.assertEqual(self.expectedResult, result_format)
diff --git a/tests/test_getMergeProposals.py b/tests/test_getMergeProposals.py
index 4c1cc4f..399350b 100644
--- a/tests/test_getMergeProposals.py
+++ b/tests/test_getMergeProposals.py
@@ -1,5 +1,5 @@
1import unittest1import unittest
2from mock import patch, MagicMock2from unittest.mock import patch, MagicMock
3import tests.util as util3import tests.util as util
4from jlp.commands.getMergeProposals import getMergeProposals4from jlp.commands.getMergeProposals import getMergeProposals
55
@@ -32,12 +32,12 @@ class TestGetMergeProposal(unittest.TestCase):
32 """No branch specified; exit with error message."""32 """No branch specified; exit with error message."""
3333
34 sys_argv = ['getMergeProposals.py']34 sys_argv = ['getMergeProposals.py']
35 error_message = 'error: too few arguments'35 error_message = 'error: the following arguments are required: branch'
36 with patch('sys.argv', sys_argv), util.captured_stderr() as stderr:36 with patch('sys.argv', sys_argv), util.captured_stderr() as stderr:
37 with self.assertRaises(SystemExit) as e:37 with self.assertRaises(SystemExit) as e:
38 getMergeProposals()38 getMergeProposals()
39 self.assertIn(error_message, stderr.getvalue())39 self.assertIn(error_message, stderr.getvalue())
40 self.assertEquals(2, e.exception.code)40 self.assertEqual(2, e.exception.code)
4141
42 def test_no_mp_found_one_branch(self):42 def test_no_mp_found_one_branch(self):
43 """One branch specified with no MPs found."""43 """One branch specified with no MPs found."""
@@ -49,7 +49,7 @@ class TestGetMergeProposal(unittest.TestCase):
49 as get_merge_proposals:49 as get_merge_proposals:
50 get_merge_proposals.return_value = []50 get_merge_proposals.return_value = []
51 count = getMergeProposals()51 count = getMergeProposals()
52 self.assertEquals(0, count)52 self.assertEqual(0, count)
5353
54 def test_no_mp_found_multiple_branches(self):54 def test_no_mp_found_multiple_branches(self):
55 """Muiltipe branches specified with no MPs found."""55 """Muiltipe branches specified with no MPs found."""
@@ -63,7 +63,7 @@ class TestGetMergeProposal(unittest.TestCase):
63 as get_merge_proposals:63 as get_merge_proposals:
64 get_merge_proposals.return_value = []64 get_merge_proposals.return_value = []
65 count = getMergeProposals()65 count = getMergeProposals()
66 self.assertEquals(0, count)66 self.assertEqual(0, count)
6767
68 def test_mp_found_one_branch(self):68 def test_mp_found_one_branch(self):
69 """One branch specified with one MP found."""69 """One branch specified with one MP found."""
@@ -75,7 +75,7 @@ class TestGetMergeProposal(unittest.TestCase):
75 as get_merge_proposals:75 as get_merge_proposals:
76 get_merge_proposals.return_value = ['Launchpad_mp']76 get_merge_proposals.return_value = ['Launchpad_mp']
77 count = getMergeProposals()77 count = getMergeProposals()
78 self.assertEquals(1, count)78 self.assertEqual(1, count)
7979
80 def test_mp_found_multiple_branches(self):80 def test_mp_found_multiple_branches(self):
81 """One branch specified with multiple MPs found."""81 """One branch specified with multiple MPs found."""
@@ -89,4 +89,4 @@ class TestGetMergeProposal(unittest.TestCase):
89 'Launchpad_mp2',89 'Launchpad_mp2',
90 'Launchpad_mp3']90 'Launchpad_mp3']
91 count = getMergeProposals()91 count = getMergeProposals()
92 self.assertEquals(3, count)92 self.assertEqual(3, count)
diff --git a/tests/test_jenkinsutils.py b/tests/test_jenkinsutils.py
index d0a6d9b..8c7bd85 100644
--- a/tests/test_jenkinsutils.py
+++ b/tests/test_jenkinsutils.py
@@ -1,4 +1,4 @@
1from mock import MagicMock, patch1from unittest.mock import MagicMock, patch
2from jlp import jenkinsutils, launchpadutils, _config2from jlp import jenkinsutils, launchpadutils, _config
3import unittest3import unittest
4from tests import JenkinsJSONData4from tests import JenkinsJSONData
@@ -222,7 +222,7 @@ class TestIsJobOrDownstreamBuildingScenarios(TestWithScenarios):
222 jenkins.get_json_data = lambda x, append_api=True: self.jenkins_data222 jenkins.get_json_data = lambda x, append_api=True: self.jenkins_data
223 with patch('jlp.jenkinsutils.get_json_jenkins',223 with patch('jlp.jenkinsutils.get_json_jenkins',
224 new=MagicMock(return_value=jenkins)):224 new=MagicMock(return_value=jenkins)):
225 self.assertEquals(225 self.assertEqual(
226 jenkinsutils.is_job_or_downstream_building(226 jenkinsutils.is_job_or_downstream_building(
227 'job', self.job_params),227 'job', self.job_params),
228 self.expected)228 self.expected)
@@ -330,7 +330,7 @@ class TestGetRunningBuilds(TestWithScenarios):
330 jenkins.get_json_data = lambda x, append_api=True: self.jenkins_data330 jenkins.get_json_data = lambda x, append_api=True: self.jenkins_data
331 with patch('jlp.jenkinsutils.get_json_jenkins',331 with patch('jlp.jenkinsutils.get_json_jenkins',
332 new=MagicMock(return_value=jenkins)):332 new=MagicMock(return_value=jenkins)):
333 self.assertEquals(333 self.assertEqual(
334 jenkinsutils.get_running_builds('job', self.job_params),334 jenkinsutils.get_running_builds('job', self.job_params),
335 self.expected)335 self.expected)
336336
@@ -494,7 +494,7 @@ class TestIsJobQueued(TestWithScenarios):
494 upstream_params = self.upstream_params494 upstream_params = self.upstream_params
495 else:495 else:
496 upstream_params = {}496 upstream_params = {}
497 self.assertEquals(497 self.assertEqual(
498 jenkinsutils.is_job_queued(498 jenkinsutils.is_job_queued(
499 'job', queue=self.queue, job_params=self.job_params,499 'job', queue=self.queue, job_params=self.job_params,
500 upstream_job=self.upstream_job,500 upstream_job=self.upstream_job,
@@ -508,7 +508,7 @@ class TestGetBuildActions(unittest.TestCase):
508 json_jenkins = MagicMock()508 json_jenkins = MagicMock()
509 json_jenkins.get_json_data.return_value = {}509 json_jenkins.get_json_data.return_value = {}
510 get_json_jenkins.return_value = json_jenkins510 get_json_jenkins.return_value = json_jenkins
511 self.assertEquals(jenkinsutils._get_build_actions('job', 23),511 self.assertEqual(jenkinsutils._get_build_actions('job', 23),
512 [])512 [])
513513
514 @patch('jlp.jenkinsutils.get_json_jenkins')514 @patch('jlp.jenkinsutils.get_json_jenkins')
@@ -554,7 +554,7 @@ class JenkinsUtilsGetDownstreamBuilds(unittest.TestCase):
554 'http://ip:8080/job/',554 'http://ip:8080/job/',
555 'my-job',555 'my-job',
556 3, 11)556 3, 11)
557 self.assertEquals(ret, [])557 self.assertEqual(ret, [])
558558
559 def test_filter_intermediate_job(self):559 def test_filter_intermediate_job(self):
560 blacklist = lambda name: ['job-freestyle']560 blacklist = lambda name: ['job-freestyle']
@@ -675,11 +675,11 @@ class JenkinsUtilsGetExecutedBuilds(unittest.TestCase):
675 def test_get_executed_builds(self):675 def test_get_executed_builds(self):
676 ret = jenkinsutils.get_executed_builds(self.jenkins, self.build_url)676 ret = jenkinsutils.get_executed_builds(self.jenkins, self.build_url)
677 expected = [677 expected = [
678 {'output': 'http://10.0.0.1:8080/job/job-multiconfig/.' +678 {'output': 'http://10.0.0.1:8080/job/job-multiconfig/' +
679 '/distribution=raring,flavor=amd64/3/console',679 'distribution=raring,flavor=amd64/3/console',
680 'result': 'FAILURE', },680 'result': 'FAILURE', },
681 {'output': 'http://10.0.0.1:8080/job/job-multiconfig/.' +681 {'output': 'http://10.0.0.1:8080/job/job-multiconfig/' +
682 '/distribution=raring,flavor=i386/3/console',682 'distribution=raring,flavor=i386/3/console',
683 'result': 'FAILURE', },683 'result': 'FAILURE', },
684 {'output': 'http://10.0.0.1:8080/job/job-freestyle/7/console',684 {'output': 'http://10.0.0.1:8080/job/job-freestyle/7/console',
685 'result': u'SUCCESS', },685 'result': u'SUCCESS', },
@@ -702,10 +702,10 @@ class JenkinsUtilsGetExecutedTestRuns(unittest.TestCase):
702 self.jenkins,702 self.jenkins,
703 'http://10.0.0.1:8080/job/job-multiconfig/' +703 'http://10.0.0.1:8080/job/job-multiconfig/' +
704 './distribution=raring,flavor=amd64/3/')704 './distribution=raring,flavor=amd64/3/')
705 expected = ['http://10.0.0.1:8080/job/job-multiconfig/./' +705 expected = ['http://10.0.0.1:8080/job/job-multiconfig/' +
706 'distribution=raring,flavor=amd64/3/artifact/' +706 'distribution=raring,flavor=amd64/3/artifact/' +
707 'results/coverity/CID_10895.html',707 'results/coverity/CID_10895.html',
708 'http://10.0.0.1:8080/job/job-multiconfig/./' +708 'http://10.0.0.1:8080/job/job-multiconfig/' +
709 'distribution=raring,flavor=amd64/3/artifact/results' +709 'distribution=raring,flavor=amd64/3/artifact/results' +
710 '/coverity/CID_10896.html']710 '/coverity/CID_10896.html']
711 self.assertEqual(ret, expected)711 self.assertEqual(ret, expected)
@@ -1258,10 +1258,7 @@ class TestTriggerAl(unittest.TestCase):
1258 [MagicMock(), MagicMock(), MagicMock()],1258 [MagicMock(), MagicMock(), MagicMock()],
1259 'job', 'url', None)1259 'job', 'url', None)
1260 self.assertEqual(start_jenkins_job.call_count, 0)1260 self.assertEqual(start_jenkins_job.call_count, 0)
1261 # the new vote is the 5th argument in change_mp_status (and we count1261 self.assertEqual(report_to_launchpad.call_args[1]['vote'],
1262 # from 0)
1263 new_vote_position = 4
1264 self.assertEqual(report_to_launchpad.call_args[0][new_vote_position],
1265 launchpadutils.LaunchpadVote.NEEDS_FIXING)1262 launchpadutils.LaunchpadVote.NEEDS_FIXING)
12661263
1267 @patch('jlp.launchpadutils.is_commit_message_set',1264 @patch('jlp.launchpadutils.is_commit_message_set',
diff --git a/tests/test_jlp.py b/tests/test_jlp.py
index f46eb7c..651d1bc 100644
--- a/tests/test_jlp.py
+++ b/tests/test_jlp.py
@@ -2,7 +2,7 @@ from unittest import TestCase
2import jlp2import jlp
3from jlp import (get_json_jenkins, load_config, get_config_option,3from jlp import (get_json_jenkins, load_config, get_config_option,
4 set_log_level)4 set_log_level)
5from mock import patch, MagicMock5from unittest.mock import patch, MagicMock
6import logging6import logging
77
88
@@ -24,7 +24,7 @@ class TestGetJsonJenkins(TestCase):
24 """Existing JSONJenkins class must be returned when calling24 """Existing JSONJenkins class must be returned when calling
25 get_json_jenkins 2+ time"""25 get_json_jenkins 2+ time"""
26 ret = get_json_jenkins()26 ret = get_json_jenkins()
27 self.assertEquals(ret, self.json_jenkins)27 self.assertEqual(ret, self.json_jenkins)
2828
29 @patch('jlp.load_config')29 @patch('jlp.load_config')
30 def test_get_json_replace_no_url(self, load_config):30 def test_get_json_replace_no_url(self, load_config):
@@ -37,7 +37,7 @@ class TestGetJsonJenkins(TestCase):
37 }37 }
38 json_jenkins = get_json_jenkins()38 json_jenkins = get_json_jenkins()
39 url = json_jenkins.patch_url('https://proxy/job/my-job')39 url = json_jenkins.patch_url('https://proxy/job/my-job')
40 self.assertEquals(url, 'https://proxy/job/my-job')40 self.assertEqual(url, 'https://proxy/job/my-job')
4141
42 @patch('jlp.load_config')42 @patch('jlp.load_config')
43 def test_get_json_replace_no_proxy_url(self, load_config):43 def test_get_json_replace_no_proxy_url(self, load_config):
@@ -50,7 +50,7 @@ class TestGetJsonJenkins(TestCase):
50 }50 }
51 json_jenkins = get_json_jenkins()51 json_jenkins = get_json_jenkins()
52 url = json_jenkins.patch_url('https://proxy/subdir/job/my-job')52 url = json_jenkins.patch_url('https://proxy/subdir/job/my-job')
53 self.assertEquals(url, 'https://proxy/subdir/job/my-job')53 self.assertEqual(url, 'https://proxy/subdir/job/my-job')
5454
55 @patch('jlp.load_config')55 @patch('jlp.load_config')
56 def test_get_json_replace_proxy_url(self, load_config):56 def test_get_json_replace_proxy_url(self, load_config):
@@ -64,7 +64,7 @@ class TestGetJsonJenkins(TestCase):
64 }64 }
65 json_jenkins = get_json_jenkins()65 json_jenkins = get_json_jenkins()
66 url = json_jenkins.patch_url('https://proxy/subdir/job/my-job')66 url = json_jenkins.patch_url('https://proxy/subdir/job/my-job')
67 self.assertEquals(url, 'http://backend:8080/subdir/job/my-job')67 self.assertEqual(url, 'http://backend:8080/subdir/job/my-job')
6868
69 @patch('jlp._json_jenkins', new=None)69 @patch('jlp._json_jenkins', new=None)
70 @patch('jlp.JSONJenkins')70 @patch('jlp.JSONJenkins')
@@ -72,34 +72,34 @@ class TestGetJsonJenkins(TestCase):
72 """Test that json_jenkins is returned when get_json_jenkins is called72 """Test that json_jenkins is returned when get_json_jenkins is called
73 for the first time"""73 for the first time"""
74 ret = get_json_jenkins()74 ret = get_json_jenkins()
75 self.assertEquals(json_jenkins.call_count, 1)75 self.assertEqual(json_jenkins.call_count, 1)
76 self.assertIsNotNone(ret)76 self.assertIsNotNone(ret)
7777
78 @patch('jlp._config', new=config)78 @patch('jlp._config', new=config)
79 @patch('jlp.yaml.safe_load')79 @patch('jlp.yaml.safe_load')
80 def test_load_config_subsequent_time(self, safe_load):80 def test_load_config_subsequent_time(self, safe_load):
81 ret = load_config()81 ret = load_config()
82 self.assertEquals(safe_load.call_count, 0)82 self.assertEqual(safe_load.call_count, 0)
83 self.assertEquals(ret, self.config)83 self.assertEqual(ret, self.config)
8484
85 @patch('jlp._config', new=None)85 @patch('jlp._config', new=None)
86 @patch('__builtin__.open')86 @patch('builtins.open')
87 @patch('jlp.yaml.safe_load')87 @patch('jlp.yaml.safe_load')
88 def test_load_config_from_home_first_time(self, safe_load, open_mock):88 def test_load_config_from_home_first_time(self, safe_load, open_mock):
89 ret = load_config()89 ret = load_config()
90 self.assertEquals(safe_load.call_count, 1)90 self.assertEqual(safe_load.call_count, 1)
91 self.assertIsNotNone(ret)91 self.assertIsNotNone(ret)
9292
93 @patch('jlp._config', new=None)93 @patch('jlp._config', new=None)
94 @patch('__builtin__.open', new=custom_open)94 @patch('builtins.open', new=custom_open)
95 @patch('jlp.yaml.safe_load')95 @patch('jlp.yaml.safe_load')
96 def test_load_config_from_cwd_first_time(self, safe_load):96 def test_load_config_from_cwd_first_time(self, safe_load):
97 ret = load_config()97 ret = load_config()
98 self.assertIsNotNone(ret)98 self.assertIsNotNone(ret)
99 self.assertEquals(safe_load.call_count, 1)99 self.assertEqual(safe_load.call_count, 1)
100100
101 @patch('jlp._config', new=None)101 @patch('jlp._config', new=None)
102 @patch('__builtin__.open')102 @patch('builtins.open')
103 def test_no_config_found(self, open_mock):103 def test_no_config_found(self, open_mock):
104 """If no config is found jlp should sys.exit with 1"""104 """If no config is found jlp should sys.exit with 1"""
105 open_mock.side_effect = IOError()105 open_mock.side_effect = IOError()
@@ -107,7 +107,7 @@ class TestGetJsonJenkins(TestCase):
107 try:107 try:
108 load_config()108 load_config()
109 except SystemExit as e:109 except SystemExit as e:
110 self.assertEquals(e.code, 1)110 self.assertEqual(e.code, 1)
111 systemExit = True111 systemExit = True
112 self.assertTrue(systemExit)112 self.assertTrue(systemExit)
113113
@@ -116,7 +116,7 @@ class TestGetJsonJenkins(TestCase):
116 """get_config_option must return the right value for a defined116 """get_config_option must return the right value for a defined
117 option"""117 option"""
118 value = get_config_option('my_option')118 value = get_config_option('my_option')
119 self.assertEquals(value, 'my_value')119 self.assertEqual(value, 'my_value')
120120
121 @patch('jlp.load_config', new=lambda: {'my_option': 'my_value'})121 @patch('jlp.load_config', new=lambda: {'my_option': 'my_value'})
122 def test_get_invalid_config_option(self):122 def test_get_invalid_config_option(self):
diff --git a/tests/test_launchpadTrigger.py b/tests/test_launchpadTrigger.py
index 6e01673..78075e1 100644
--- a/tests/test_launchpadTrigger.py
+++ b/tests/test_launchpadTrigger.py
@@ -1,5 +1,5 @@
1import unittest1import unittest
2from mock import patch, MagicMock2from unittest.mock import patch, MagicMock
3import tests.util as util3import tests.util as util
4from jlp.commands.launchpadTrigger import launchpadTrigger, trigger_jenkins4from jlp.commands.launchpadTrigger import launchpadTrigger, trigger_jenkins
5from jlp import get_config_option5from jlp import get_config_option
@@ -57,7 +57,8 @@ class TestLaunchpadTriggerParams(PatchedLaunchpadTriggerTest):
57 "-a",57 "-a",
58 "--job=faux-dbus-test-runner",58 "--job=faux-dbus-test-runner",
59 "--autoland"]59 "--autoland"]
60 error_message = "error: argument -b/--branch is required"60 error_message = ("error: the following arguments are required: "
61 "-b/--branch")
61 with patch('sys.argv', sys_argv), \62 with patch('sys.argv', sys_argv), \
62 util.captured_stderr() as stderr:63 util.captured_stderr() as stderr:
63 try:64 try:
@@ -74,7 +75,7 @@ class TestLaunchpadTriggerParams(PatchedLaunchpadTriggerTest):
74 "-n",75 "-n",
75 "--branch=lp:faux-dbus-test-runner",76 "--branch=lp:faux-dbus-test-runner",
76 "--autoland"]77 "--autoland"]
77 error_message = 'argument -j/--job is required'78 error_message = 'error: the following arguments are required: -j/--job'
78 with patch('sys.argv', sys_argv), \79 with patch('sys.argv', sys_argv), \
79 util.captured_stderr() as stderr:80 util.captured_stderr() as stderr:
80 try:81 try:
@@ -154,7 +155,7 @@ class TestLaunchpadTriggerParams(PatchedLaunchpadTriggerTest):
154 patch('jlp.commands.launchpadTrigger.get_merge_proposals') as \155 patch('jlp.commands.launchpadTrigger.get_merge_proposals') as \
155 get_merge_proposals, \156 get_merge_proposals, \
156 patch('jlp.commands.launchpadTrigger.jenkinsutils.' +157 patch('jlp.commands.launchpadTrigger.jenkinsutils.' +
157 'trigger_ci_build') as trigger_ci_build:158 'trigger_ci_build'):
158 get_merge_proposals.return_value = [self.merge_proposal]159 get_merge_proposals.return_value = [self.merge_proposal]
159 launchpadTrigger()160 launchpadTrigger()
160 get_merge_proposals.assert_called_with(self.launchpad,161 get_merge_proposals.assert_called_with(self.launchpad,
diff --git a/tests/test_launchpadutils.py b/tests/test_launchpadutils.py
index 19febf2..cdb5b10 100644
--- a/tests/test_launchpadutils.py
+++ b/tests/test_launchpadutils.py
@@ -1,8 +1,7 @@
1import unittest1import unittest
2from jlp import launchpadutils, get_config_option2from jlp import launchpadutils, get_config_option
3from mock import MagicMock, patch3from unittest.mock import MagicMock, patch
4from testscenarios import TestWithScenarios4from testscenarios import TestWithScenarios
5from textwrap import dedent
65
76
8class LaunchpadUtilsTests(unittest.TestCase):7class LaunchpadUtilsTests(unittest.TestCase):
@@ -104,7 +103,7 @@ class LaunchpadUtilsTests(unittest.TestCase):
104 vote.comment.vote = 'Approve'103 vote.comment.vote = 'Approve'
105 reviews = launchpadutils.get_reviews(mp)104 reviews = launchpadutils.get_reviews(mp)
106 for review in reviews:105 for review in reviews:
107 self.assertEquals(review, 'jenkins;Approve')106 self.assertEqual(review, 'jenkins;Approve')
108107
109 def test_unapproved_prerequisite_no_prerequisite(self):108 def test_unapproved_prerequisite_no_prerequisite(self):
110 mp = MagicMock()109 mp = MagicMock()
@@ -651,13 +650,13 @@ class TestGetGitMergeProposals(unittest.TestCase):
651 def test_get_git_merge_proposals_with_wrong_launchpad_version(self):650 def test_get_git_merge_proposals_with_wrong_launchpad_version(self):
652 launchpad = self._get_launchpad_without_git()651 launchpad = self._get_launchpad_without_git()
653 with self.assertRaises(RuntimeError):652 with self.assertRaises(RuntimeError):
654 ret = launchpadutils.get_merge_proposals(launchpad, '', '',653 launchpadutils.get_merge_proposals(launchpad, '', '',
655 repo_type='git')654 repo_type='git')
656655
657 def test_invalid_repo_type(self):656 def test_invalid_repo_type(self):
658 launchpad = self._get_launchpad(None)657 launchpad = self._get_launchpad(None)
659 with self.assertRaises(RuntimeError):658 with self.assertRaises(RuntimeError):
660 ret = launchpadutils.get_merge_proposals(launchpad, '', '',659 launchpadutils.get_merge_proposals(launchpad, '', '',
661 repo_type='test')660 repo_type='test')
662661
663class TestGetMpHandleFromURL(unittest.TestCase):662class TestGetMpHandleFromURL(unittest.TestCase):
@@ -666,7 +665,7 @@ class TestGetMpHandleFromURL(unittest.TestCase):
666 """If there is no way how to get branch link from the merge proposal665 """If there is no way how to get branch link from the merge proposal
667 url then get_mp_handle_from_url must return None"""666 url then get_mp_handle_from_url must return None"""
668 ret = launchpadutils.get_mp_handle_from_url(MagicMock(), 'http://')667 ret = launchpadutils.get_mp_handle_from_url(MagicMock(), 'http://')
669 self.assertEquals(ret, None)668 self.assertEqual(ret, None)
670669
671 @patch("jlp.launchpadutils.get_branch_from_mp", new=lambda x: 'http://')670 @patch("jlp.launchpadutils.get_branch_from_mp", new=lambda x: 'http://')
672 def test_unable_to_get_branch_handle(self):671 def test_unable_to_get_branch_handle(self):
@@ -675,7 +674,7 @@ class TestGetMpHandleFromURL(unittest.TestCase):
675 launchpad = MagicMock()674 launchpad = MagicMock()
676 launchpad.branches.getByUrl = lambda url: None675 launchpad.branches.getByUrl = lambda url: None
677 ret = launchpadutils.get_mp_handle_from_url(launchpad, 'http://')676 ret = launchpadutils.get_mp_handle_from_url(launchpad, 'http://')
678 self.assertEquals(ret, None)677 self.assertEqual(ret, None)
679678
680 @patch("jlp.launchpadutils.get_branch_from_mp", new=lambda x: 'http://')679 @patch("jlp.launchpadutils.get_branch_from_mp", new=lambda x: 'http://')
681 def test_get_mp_handle_from_url(self):680 def test_get_mp_handle_from_url(self):
@@ -691,7 +690,7 @@ class TestGetMpHandleFromURL(unittest.TestCase):
691 branch.landing_targets = [mp]690 branch.landing_targets = [mp]
692 launchpad.branches.getByUrl = lambda url: branch691 launchpad.branches.getByUrl = lambda url: branch
693 ret = launchpadutils.get_mp_handle_from_url(launchpad, mp_url)692 ret = launchpadutils.get_mp_handle_from_url(launchpad, mp_url)
694 self.assertEquals(ret, mp)693 self.assertEqual(ret, mp)
695694
696 def test_call_git_api_for_git_url(self):695 def test_call_git_api_for_git_url(self):
697 """If there is a merge proposal for the given merge proposal URL then696 """If there is a merge proposal for the given merge proposal URL then
@@ -706,7 +705,7 @@ class TestGetMpHandleFromURL(unittest.TestCase):
706 git_repo.landing_targets = [mp]705 git_repo.landing_targets = [mp]
707 launchpad.git_repositories.getByPath = lambda path: git_repo706 launchpad.git_repositories.getByPath = lambda path: git_repo
708 ret = launchpadutils.get_mp_handle_from_url(launchpad, mp_url)707 ret = launchpadutils.get_mp_handle_from_url(launchpad, mp_url)
709 self.assertEquals(ret, mp)708 self.assertEqual(ret, mp)
710709
711class TestGetBranchHandle(unittest.TestCase):710class TestGetBranchHandle(unittest.TestCase):
712 def setUp(self):711 def setUp(self):
@@ -807,7 +806,7 @@ class TestGetBranchHandle(unittest.TestCase):
807 name = 'lp:dummy'806 name = 'lp:dummy'
808 # Create multiple matches to be returned for the url807 # Create multiple matches to be returned for the url
809 branch = self.create_fake_bazaar_branch()808 branch = self.create_fake_bazaar_branch()
810 repo = self.create_fake_git_repo()809 self.create_fake_git_repo()
811 result = launchpadutils.get_branch_handle_for(self.launchpad, name,810 result = launchpadutils.get_branch_handle_for(self.launchpad, name,
812 'bazaar');811 'bazaar');
813 self.assertEqual(result, ('bazaar', branch))812 self.assertEqual(result, ('bazaar', branch))
@@ -818,7 +817,7 @@ class TestGetBranchHandle(unittest.TestCase):
818 '''817 '''
819 name = 'lp:dummy'818 name = 'lp:dummy'
820 # Create multiple matches to be returned for the url819 # Create multiple matches to be returned for the url
821 branch = self.create_fake_bazaar_branch()820 self.create_fake_bazaar_branch()
822 repo = self.create_fake_git_repo()821 repo = self.create_fake_git_repo()
823 result = launchpadutils.get_branch_handle_for(self.launchpad, name,822 result = launchpadutils.get_branch_handle_for(self.launchpad, name,
824 'git');823 'git');
diff --git a/tests/test_voteOnMergeProposal.py b/tests/test_voteOnMergeProposal.py
index 4f9523c..0378006 100644
--- a/tests/test_voteOnMergeProposal.py
+++ b/tests/test_voteOnMergeProposal.py
@@ -1,5 +1,5 @@
1import unittest1import unittest
2from mock import patch, MagicMock2from unittest.mock import patch, MagicMock
3import tests.util as util3import tests.util as util
4from jlp.commands.voteOnMergeProposal import voteOnMergeProposal4from jlp.commands.voteOnMergeProposal import voteOnMergeProposal
55
@@ -41,13 +41,14 @@ class TestVoteOnMergeProposal(unittest.TestCase):
41 '--branch="lp:~mrazik/faux-dbus-test-runner/yar8"',41 '--branch="lp:~mrazik/faux-dbus-test-runner/yar8"',
42 '--merge-proposal="https://code.launchpad.net/~mrazik/' +42 '--merge-proposal="https://code.launchpad.net/~mrazik/' +
43 'faux-dbus-test-runner/yar8/+merge/106113"']43 'faux-dbus-test-runner/yar8/+merge/106113"']
44 error_message = 'error: argument -u/--build-url is required'44 error_message = ('error: the following arguments are required: '
45 '-u/--build-url')
45 with patch('sys.argv', sys_argv), \46 with patch('sys.argv', sys_argv), \
46 util.captured_stderr() as stderr:47 util.captured_stderr() as stderr:
47 with self.assertRaises(SystemExit) as e:48 with self.assertRaises(SystemExit) as e:
48 voteOnMergeProposal()49 voteOnMergeProposal()
49 self.assertTrue(error_message in stderr.getvalue())50 self.assertTrue(error_message in stderr.getvalue())
50 self.assertEquals(2, e.exception.code)51 self.assertEqual(2, e.exception.code)
5152
52 def test_no_revision_specified(self):53 def test_no_revision_specified(self):
53 """No revision specified; exit with message."""54 """No revision specified; exit with message."""
@@ -59,13 +60,14 @@ class TestVoteOnMergeProposal(unittest.TestCase):
59 '--branch="lp:~mrazik/faux-dbus-test-runner/yar8"',60 '--branch="lp:~mrazik/faux-dbus-test-runner/yar8"',
60 '--merge-proposal="https://code.launchpad.net/~mrazik/' +61 '--merge-proposal="https://code.launchpad.net/~mrazik/' +
61 'faux-dbus-test-runner/yar8/+merge/106113"']62 'faux-dbus-test-runner/yar8/+merge/106113"']
62 error_message = 'error: argument -r/--revision is required'63 error_message = ('error: the following arguments are required: '
64 '-r/--revision')
63 with patch('sys.argv', sys_argv), \65 with patch('sys.argv', sys_argv), \
64 util.captured_stderr() as stderr:66 util.captured_stderr() as stderr:
65 with self.assertRaises(SystemExit) as e:67 with self.assertRaises(SystemExit) as e:
66 voteOnMergeProposal()68 voteOnMergeProposal()
67 self.assertTrue(error_message in stderr.getvalue())69 self.assertTrue(error_message in stderr.getvalue())
68 self.assertEquals(2, e.exception.code)70 self.assertEqual(2, e.exception.code)
6971
70 def test_no_merge_proposal_specified(self):72 def test_no_merge_proposal_specified(self):
71 """No merge_proposal specified; exit with message."""73 """No merge_proposal specified; exit with message."""
@@ -76,13 +78,14 @@ class TestVoteOnMergeProposal(unittest.TestCase):
76 'faux-dbus-test-runner-ci/configure"',78 'faux-dbus-test-runner-ci/configure"',
77 '--revision=66',79 '--revision=66',
78 '--branch="lp:~mrazik/faux-dbus-test-runner/yar8"']80 '--branch="lp:~mrazik/faux-dbus-test-runner/yar8"']
79 error_message = 'error: argument -p/--merge-proposal is required'81 error_message = ('error: the following arguments are required: '
82 '-p/--merge-proposal')
80 with patch('sys.argv', sys_argv), \83 with patch('sys.argv', sys_argv), \
81 util.captured_stderr() as stderr:84 util.captured_stderr() as stderr:
82 with self.assertRaises(SystemExit) as e:85 with self.assertRaises(SystemExit) as e:
83 voteOnMergeProposal()86 voteOnMergeProposal()
84 self.assertTrue(error_message in stderr.getvalue())87 self.assertTrue(error_message in stderr.getvalue())
85 self.assertEquals(2, e.exception.code)88 self.assertEqual(2, e.exception.code)
8689
87 def test_unknown_merge_proposal(self):90 def test_unknown_merge_proposal(self):
88 """The given merge proposal wasn't found; error out with message."""91 """The given merge proposal wasn't found; error out with message."""
@@ -108,12 +111,11 @@ class TestVoteOnMergeProposal(unittest.TestCase):
108 pass111 pass
109 self.assertTrue(error_message in stderr.getvalue())112 self.assertTrue(error_message in stderr.getvalue())
110113
111 @patch('sys.argv')
112 @patch('jlp.commands.voteOnMergeProposal.launchpadutils.get_mp_handle_from_url')114 @patch('jlp.commands.voteOnMergeProposal.launchpadutils.get_mp_handle_from_url')
113 @patch('jlp.launchpadutils.report_to_launchpad')115 @patch('jlp.launchpadutils.report_to_launchpad')
114 @patch('jlp.commands.voteOnMergeProposal.launchpadutils.get_template_args')116 @patch('jlp.commands.voteOnMergeProposal.launchpadutils.get_template_args')
115 @patch('jlp.commands.voteOnMergeProposal.get_jinja_environment')117 @patch('jlp.commands.voteOnMergeProposal.get_jinja_environment')
116 def test_passed_vote(self, gje, gta, rtl, gmphandle, sys_argv):118 def test_passed_vote(self, gje, gta, rtl, gmphandle):
117 """Vote on a proposal which passed."""119 """Vote on a proposal which passed."""
118120
119 sys_argv = ['voteOnMergeProposal.py',121 sys_argv = ['voteOnMergeProposal.py',
@@ -130,21 +132,20 @@ class TestVoteOnMergeProposal(unittest.TestCase):
130 'result': 'PASSED',132 'result': 'PASSED',
131 'revision': '66'133 'revision': '66'
132 }134 }
133 ret = voteOnMergeProposal()135 with patch('sys.argv', sys_argv):
136 ret = voteOnMergeProposal()
134 self.assertEqual(ret, 0)137 self.assertEqual(ret, 0)
135 rtl.assert_called_once()138 rtl.assert_called_once()
136 gje.get_template.assert_called_with('ci_test.j2')139 gje.return_value.get_template.assert_called_with('ci_test.j2')
137140
138141
139 @patch('sys.argv')
140 @patch('jlp.commands.voteOnMergeProposal.launchpadutils.' +\142 @patch('jlp.commands.voteOnMergeProposal.launchpadutils.' +\
141 'get_mp_handle_from_url')143 'get_mp_handle_from_url')
142 @patch('jlp.launchpadutils.report_to_launchpad')144 @patch('jlp.launchpadutils.report_to_launchpad')
143 @patch('jlp.launchpadutils.is_commit_message_set')145 @patch('jlp.launchpadutils.is_commit_message_set')
144 @patch('jlp.commands.voteOnMergeProposal.launchpadutils.get_template_args')146 @patch('jlp.commands.voteOnMergeProposal.launchpadutils.get_template_args')
145 @patch('jlp.commands.voteOnMergeProposal.get_jinja_environment')147 @patch('jlp.commands.voteOnMergeProposal.get_jinja_environment')
146 def test_no_commit_message_set(self, gje, gta, icms,148 def test_no_commit_message_set(self, gje, gta, icms, rtl, gmphandle):
147 rtl, gmphandle, sys_argv):
148 """Vote on a proposal where tests passed but no commit message149 """Vote on a proposal where tests passed but no commit message
149 was set."""150 was set."""
150151
@@ -167,6 +168,7 @@ class TestVoteOnMergeProposal(unittest.TestCase):
167 }168 }
168 icms.return_value = False169 icms.return_value = False
169 170
170 ret = voteOnMergeProposal()171 with patch('sys.argv', sys_argv):
172 ret = voteOnMergeProposal()
171 self.assertEqual(ret, 0)173 self.assertEqual(ret, 0)
172 gje.get_template.assert_called_with('no_commit.j2')174 gje.return_value.get_template.assert_called_with('no_commit.j2')
diff --git a/tests/util.py b/tests/util.py
index 4ba80fb..b9bd5c9 100644
--- a/tests/util.py
+++ b/tests/util.py
@@ -1,5 +1,5 @@
1import sys1import sys
2from StringIO import StringIO2from io import StringIO
3import contextlib3import contextlib
44
55
diff --git a/voteOnMergeProposal.py b/voteOnMergeProposal.py
6deleted file mode 1200006deleted file mode 120000
index ebf0657..0000000
--- a/voteOnMergeProposal.py
+++ /dev/null
@@ -1 +0,0 @@
1scripts/voteOnMergeProposal
2\ No newline at end of file0\ No newline at end of file

Subscribers

People subscribed via source and target branches