Merge ~paride/jenkins-launchpad-plugin:py3 into jenkins-launchpad-plugin:master
- Git
- lp:~paride/jenkins-launchpad-plugin
- py3
- Merge into master
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) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Joshua Powers (community) | Approve | ||
Review via email:
|
Commit message
Convert package to Python 3
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Paride Legovini (paride) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Joshua Powers (powersj) wrote : | # |
Can you show an example of this working using some test LP project please? Otherwise 2 in-line questions?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Paride Legovini (paride) wrote : | # |
Lines removed; all tests still passing.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Paride Legovini (paride) wrote : | # |
Tested against the lp:paride-test-project project. This is the MP I used for testing:
https:/
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:/
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.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Paride Legovini (paride) wrote : | # |
The root of the problem seems to be:
[ 267.086787] cloud-init[1461]: Processing triggers for linux-image-
[ 267.410038] cloud-init[1461]: /etc/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.
[ 267.563889] cloud-init[1461]: Can't find /boot/vmlinuz-
[ 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:/
Possible workaround: restrict the "run update-initramfs once" logic to arm64 until we find what goes wrong on arm64 and s390x.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Paride Legovini (paride) wrote : | # |
Wrong brower tab :)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Joshua Powers (powersj) : | # |
Preview Diff
1 | diff --git a/.gitignore b/.gitignore | |||
2 | index bf01a23..9379187 100644 | |||
3 | --- a/.gitignore | |||
4 | +++ b/.gitignore | |||
5 | @@ -1,8 +1,11 @@ | |||
6 | 1 | docs/_build/* | 1 | docs/_build/* |
14 | 2 | ./bin | 2 | /bin |
15 | 3 | ./share | 3 | /share |
16 | 4 | ./local | 4 | /local |
17 | 5 | ./lib | 5 | /lib |
18 | 6 | ./include | 6 | /include |
19 | 7 | ./jenkins_launchpad_plugin.egg-info | 7 | /jenkins_launchpad_plugin.egg-info |
20 | 8 | ./man | 8 | /man |
21 | 9 | __pycache__ | ||
22 | 10 | *.pyc | ||
23 | 11 | build | ||
24 | diff --git a/HACKING b/HACKING | |||
25 | 9 | deleted file mode 100644 | 12 | deleted file mode 100644 |
26 | index b0555b8..0000000 | |||
27 | --- a/HACKING | |||
28 | +++ /dev/null | |||
29 | @@ -1,23 +0,0 @@ | |||
30 | 1 | If you are not running Ubuntu raring or later you will need run the | ||
31 | 2 | following in order to install pyruntest: | ||
32 | 3 | * sudo add-apt-repository ppa:autopilot/ppa | ||
33 | 4 | |||
34 | 5 | |||
35 | 6 | You need the following if you want to make changes/run this project: | ||
36 | 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 | ||
37 | 8 | * install tarmac: | ||
38 | 9 | bzr branch lp:tarmac | ||
39 | 10 | cd tarmac | ||
40 | 11 | sudo python setup.py install | ||
41 | 12 | |||
42 | 13 | To run the tests: | ||
43 | 14 | * pyruntest tests | ||
44 | 15 | |||
45 | 16 | Virtualenv instructions: | ||
46 | 17 | $ sudo apt-get install python-virtualenv | ||
47 | 18 | $ virtualenv . --system-site-packages | ||
48 | 19 | $ bin/python setup.py develop | ||
49 | 20 | $ bzr branch lp:tarmac ../tarmac | ||
50 | 21 | $ jlp=$(pwd) | ||
51 | 22 | $ cd ../tarmac | ||
52 | 23 | $ $jlp/bin/python setup.py install | ||
53 | diff --git a/autoland.py b/autoland.py | |||
54 | 24 | deleted file mode 120000 | 0 | deleted file mode 120000 |
55 | index f8abc68..0000000 | |||
56 | --- a/autoland.py | |||
57 | +++ /dev/null | |||
58 | @@ -1 +0,0 @@ | |||
59 | 1 | scripts/autoland | ||
60 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
61 | diff --git a/dput b/dput | |||
62 | 3 | deleted file mode 120000 | 1 | deleted file mode 120000 |
63 | index f63205d..0000000 | |||
64 | --- a/dput | |||
65 | +++ /dev/null | |||
66 | @@ -1 +0,0 @@ | |||
67 | 1 | scripts/dput | ||
68 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
69 | diff --git a/getMergeProposals.py b/getMergeProposals.py | |||
70 | 3 | deleted file mode 120000 | 1 | deleted file mode 120000 |
71 | index 80e275c..0000000 | |||
72 | --- a/getMergeProposals.py | |||
73 | +++ /dev/null | |||
74 | @@ -1 +0,0 @@ | |||
75 | 1 | scripts/getMergeProposals | ||
76 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
77 | diff --git a/jlp/__init__.py b/jlp/__init__.py | |||
78 | index 00d6adc..9802aea 100644 | |||
79 | --- a/jlp/__init__.py | |||
80 | +++ b/jlp/__init__.py | |||
81 | @@ -8,7 +8,7 @@ jlp | |||
82 | 8 | """ | 8 | """ |
83 | 9 | 9 | ||
84 | 10 | __name__ = 'jlp' | 10 | __name__ = 'jlp' |
86 | 11 | __version__ = '0.1' | 11 | __version__ = '3.1' |
87 | 12 | __author__ = 'Martin Mrazik' | 12 | __author__ = 'Martin Mrazik' |
88 | 13 | 13 | ||
89 | 14 | import jinja2 | 14 | import jinja2 |
90 | diff --git a/jlp/branch.py b/jlp/branch.py | |||
91 | index 5334d6f..9462f88 100644 | |||
92 | --- a/jlp/branch.py | |||
93 | +++ b/jlp/branch.py | |||
94 | @@ -1,7 +1,7 @@ | |||
95 | 1 | import logging | 1 | import logging |
97 | 2 | from bzrlib.plugin import load_plugins | 2 | from breezy.plugin import load_plugins |
98 | 3 | load_plugins() | 3 | load_plugins() |
100 | 4 | from bzrlib import branch as bzr_branch | 4 | from breezy import branch as bzr_branch |
101 | 5 | from tarmac.branch import Branch as TarmacBranch | 5 | from tarmac.branch import Branch as TarmacBranch |
102 | 6 | from tarmac.branch import BranchConfig | 6 | from tarmac.branch import BranchConfig |
103 | 7 | from jlp import get_config_option | 7 | from jlp import get_config_option |
104 | diff --git a/jlp/commands/__init__.py b/jlp/commands/__init__.py | |||
105 | 8 | deleted file mode 100644 | 8 | deleted file mode 100644 |
106 | index e69de29..0000000 | |||
107 | --- a/jlp/commands/__init__.py | |||
108 | +++ /dev/null | |||
109 | diff --git a/jlp/commands/autoland.py b/jlp/commands/autoland.py | |||
110 | index ba95372..a4552f0 100644 | |||
111 | --- a/jlp/commands/autoland.py | |||
112 | +++ b/jlp/commands/autoland.py | |||
113 | @@ -7,10 +7,10 @@ from jlp.launchpadutils import (LaunchpadVote, get_vote_subject, | |||
114 | 7 | get_target_branch, get_source_branch, | 7 | get_target_branch, get_source_branch, |
115 | 8 | is_git_project) | 8 | is_git_project) |
116 | 9 | from jlp import (launchpadutils, Branch, | 9 | from jlp import (launchpadutils, Branch, |
118 | 10 | DputRunner, jenkinsutils, get_launchpad, | 10 | DputRunner, get_launchpad, |
119 | 11 | get_config_option, logger, get_jinja_environment) | 11 | get_config_option, logger, get_jinja_environment) |
120 | 12 | from tarmac.exceptions import TarmacMergeError, BranchHasConflicts | 12 | from tarmac.exceptions import TarmacMergeError, BranchHasConflicts |
122 | 13 | from bzrlib.errors import LockFailed | 13 | from breezy.errors import LockFailed |
123 | 14 | import os | 14 | import os |
124 | 15 | from shutil import rmtree | 15 | from shutil import rmtree |
125 | 16 | import tempfile | 16 | import tempfile |
126 | diff --git a/jlp/commands/voteOnMergeProposal.py b/jlp/commands/voteOnMergeProposal.py | |||
127 | index dab10ef..bf9f008 100644 | |||
128 | --- a/jlp/commands/voteOnMergeProposal.py | |||
129 | +++ b/jlp/commands/voteOnMergeProposal.py | |||
130 | @@ -1,7 +1,6 @@ | |||
131 | 1 | from argparse import ArgumentParser | 1 | from argparse import ArgumentParser |
132 | 2 | import atexit | 2 | import atexit |
135 | 3 | import jinja2 | 3 | from jlp import launchpadutils, get_launchpad, logger, get_jinja_environment |
134 | 4 | from jlp import launchpadutils, get_launchpad, logger, get_config_option, get_jinja_environment | ||
136 | 5 | import re | 4 | import re |
137 | 6 | import os | 5 | import os |
138 | 7 | from shutil import rmtree | 6 | from shutil import rmtree |
139 | diff --git a/jlp/dputrunner.py b/jlp/dputrunner.py | |||
140 | index cfce696..d096d77 100644 | |||
141 | --- a/jlp/dputrunner.py | |||
142 | +++ b/jlp/dputrunner.py | |||
143 | @@ -37,7 +37,7 @@ class DputRunner: | |||
144 | 37 | return self.versionFormat.format(**kwargs) | 37 | return self.versionFormat.format(**kwargs) |
145 | 38 | except KeyError as error: | 38 | except KeyError as error: |
146 | 39 | logger.error('Unkown variable used in format string: ' + | 39 | logger.error('Unkown variable used in format string: ' + |
148 | 40 | error.message) | 40 | str(error)) |
149 | 41 | return None | 41 | return None |
150 | 42 | 42 | ||
151 | 43 | def _run_hooks(self, hooks, cwd): | 43 | def _run_hooks(self, hooks, cwd): |
152 | diff --git a/jlp/jenkinsutils.py b/jlp/jenkinsutils.py | |||
153 | index 2083d45..8b94b1b 100644 | |||
154 | --- a/jlp/jenkinsutils.py | |||
155 | +++ b/jlp/jenkinsutils.py | |||
156 | @@ -2,18 +2,16 @@ import re | |||
157 | 2 | import os | 2 | import os |
158 | 3 | from xml.dom.minidom import parseString | 3 | from xml.dom.minidom import parseString |
159 | 4 | import jenkins | 4 | import jenkins |
164 | 5 | import urlparse | 5 | import urllib |
165 | 6 | import urllib2 | 6 | from . import launchpadutils |
162 | 7 | import launchpadutils | ||
163 | 8 | from textwrap import dedent | ||
166 | 9 | from . import get_json_jenkins | 7 | from . import get_json_jenkins |
167 | 10 | from lazr.restfulclient.errors import Unauthorized | 8 | from lazr.restfulclient.errors import Unauthorized |
168 | 11 | from jlp import logger, get_config_option, get_jinja_environment | 9 | from jlp import logger, get_config_option, get_jinja_environment |
169 | 12 | 10 | ||
170 | 13 | 11 | ||
171 | 14 | def normalize_url(url): | 12 | def normalize_url(url): |
174 | 15 | return urlparse.urljoin(url, | 13 | return urllib.parse.urljoin(url, |
175 | 16 | urlparse.urlparse(url).path.replace('//', '/')) | 14 | urllib.parse.urlparse(url).path.replace('//', '/')) |
176 | 17 | 15 | ||
177 | 18 | 16 | ||
178 | 19 | def _actions_has_param(actions, param, value): | 17 | def _actions_has_param(actions, param, value): |
179 | @@ -427,7 +425,7 @@ def is_pipeline_job(jenkins, job_url): | |||
180 | 427 | try: | 425 | try: |
181 | 428 | data = jenkins.get_json_data(job_url + 'wfapi', | 426 | data = jenkins.get_json_data(job_url + 'wfapi', |
182 | 429 | append_api=False) | 427 | append_api=False) |
184 | 430 | except urllib2.HTTPError: | 428 | except urllib.error.HTTPError: |
185 | 431 | data = None | 429 | data = None |
186 | 432 | 430 | ||
187 | 433 | if data: | 431 | if data: |
188 | @@ -755,7 +753,7 @@ def start_jenkins_job(lp_handle, launchpaduser, jenkins_url, jenkins_job, mp, | |||
189 | 755 | try: | 753 | try: |
190 | 756 | is_merge_only = launchpadutils.is_merge_only(mp) | 754 | is_merge_only = launchpadutils.is_merge_only(mp) |
191 | 757 | except LookupError as error: | 755 | except LookupError as error: |
193 | 758 | logger.error(error.message) | 756 | logger.error(str(error)) |
194 | 759 | logger.debug('Skipping this merge proposal') | 757 | logger.debug('Skipping this merge proposal') |
195 | 760 | return False | 758 | return False |
196 | 761 | 759 | ||
197 | diff --git a/jlp/jsonjenkins.py b/jlp/jsonjenkins.py | |||
198 | index 98ab1e4..353043f 100644 | |||
199 | --- a/jlp/jsonjenkins.py | |||
200 | +++ b/jlp/jsonjenkins.py | |||
201 | @@ -1,5 +1,5 @@ | |||
202 | 1 | import json | 1 | import json |
204 | 2 | import urllib2 | 2 | import urllib |
205 | 3 | 3 | ||
206 | 4 | 4 | ||
207 | 5 | class JSONJenkins(): | 5 | class JSONJenkins(): |
208 | @@ -9,11 +9,11 @@ class JSONJenkins(): | |||
209 | 9 | self.jenkins_url = jenkins_url | 9 | self.jenkins_url = jenkins_url |
210 | 10 | self.jenkins_proxy_url = jenkins_proxy_url | 10 | self.jenkins_proxy_url = jenkins_proxy_url |
211 | 11 | 11 | ||
213 | 12 | passman = urllib2.HTTPPasswordMgrWithDefaultRealm() | 12 | passman = urllib.request.HTTPPasswordMgrWithDefaultRealm() |
214 | 13 | passman.add_password(None, jenkins_url, username, password) | 13 | passman.add_password(None, jenkins_url, username, password) |
218 | 14 | authhandler = urllib2.HTTPBasicAuthHandler(passman) | 14 | authhandler = urllib.request.HTTPBasicAuthHandler(passman) |
219 | 15 | self.urllib_opener = urllib2.build_opener(authhandler) | 15 | self.urllib_opener = urllib.request.build_opener(authhandler) |
220 | 16 | urllib2.install_opener(self.urllib_opener) | 16 | urllib.request.install_opener(self.urllib_opener) |
221 | 17 | 17 | ||
222 | 18 | def patch_url(self, url): | 18 | def patch_url(self, url): |
223 | 19 | # Test for presence of a url that needs to be patched. | 19 | # Test for presence of a url that needs to be patched. |
224 | @@ -30,5 +30,5 @@ class JSONJenkins(): | |||
225 | 30 | url = self.patch_url(url) | 30 | url = self.patch_url(url) |
226 | 31 | if append_api: | 31 | if append_api: |
227 | 32 | url = url + '/api/json' | 32 | url = url + '/api/json' |
229 | 33 | data = urllib2.urlopen(url) | 33 | data = urllib.request.urlopen(url) |
230 | 34 | return json.load(data) | 34 | return json.load(data) |
231 | diff --git a/jlp/launchpadagent.py b/jlp/launchpadagent.py | |||
232 | index 65e0621..fd29d81 100644 | |||
233 | --- a/jlp/launchpadagent.py | |||
234 | +++ b/jlp/launchpadagent.py | |||
235 | @@ -31,7 +31,7 @@ class AuthorizeRequestTokenWithConsole(RequestTokenAuthorizationEngine): | |||
236 | 31 | 31 | ||
237 | 32 | """ | 32 | """ |
238 | 33 | authorization_url = self.authorization_url(request_token) | 33 | authorization_url = self.authorization_url(request_token) |
240 | 34 | print WAITING_FOR_USER.format(authorization_url) | 34 | print(WAITING_FOR_USER.format(authorization_url)) |
241 | 35 | # if we don't flush we may not see the message | 35 | # if we don't flush we may not see the message |
242 | 36 | sys.stdout.flush() | 36 | sys.stdout.flush() |
243 | 37 | while credentials.access_token is None: | 37 | while credentials.access_token is None: |
244 | @@ -40,7 +40,7 @@ class AuthorizeRequestTokenWithConsole(RequestTokenAuthorizationEngine): | |||
245 | 40 | credentials.exchange_request_token_for_access_token( | 40 | credentials.exchange_request_token_for_access_token( |
246 | 41 | self.web_root) | 41 | self.web_root) |
247 | 42 | break | 42 | break |
249 | 43 | except HTTPError, e: | 43 | except HTTPError as e: |
250 | 44 | if e.response.status == 403: | 44 | if e.response.status == 403: |
251 | 45 | # The user decided not to authorize this | 45 | # The user decided not to authorize this |
252 | 46 | # application. | 46 | # application. |
253 | diff --git a/jlp/launchpadutils.py b/jlp/launchpadutils.py | |||
254 | index 7197180..4c50bba 100644 | |||
255 | --- a/jlp/launchpadutils.py | |||
256 | +++ b/jlp/launchpadutils.py | |||
257 | @@ -1,6 +1,6 @@ | |||
259 | 1 | import os, re | 1 | import re |
260 | 2 | from jlp import logger, get_config_option | 2 | from jlp import logger, get_config_option |
262 | 3 | import jenkinsutils | 3 | from jlp import jenkinsutils |
263 | 4 | from . import get_json_jenkins | 4 | from . import get_json_jenkins |
264 | 5 | 5 | ||
265 | 6 | RE_LP_BUG_IDS = r'LP:(,? #\d+)+\s*$' | 6 | RE_LP_BUG_IDS = r'LP:(,? #\d+)+\s*$' |
266 | @@ -283,7 +283,7 @@ def users_allowed_to_trigger_jobs(lp_users): | |||
267 | 283 | try: | 283 | try: |
268 | 284 | allowed_person = lp.people[allowed] | 284 | allowed_person = lp.people[allowed] |
269 | 285 | except KeyError: | 285 | except KeyError: |
271 | 286 | logger.warn('User {} from the allowed_users list is not in ' | 286 | logger.warning('User {} from the allowed_users list is not in ' |
272 | 287 | 'launchpad!'.format(allowed)) | 287 | 'launchpad!'.format(allowed)) |
273 | 288 | continue | 288 | continue |
274 | 289 | if not allowed_person.is_team: | 289 | if not allowed_person.is_team: |
275 | diff --git a/launchpadTrigger.py b/launchpadTrigger.py | |||
276 | 290 | deleted file mode 120000 | 290 | deleted file mode 120000 |
277 | index 128f211..0000000 | |||
278 | --- a/launchpadTrigger.py | |||
279 | +++ /dev/null | |||
280 | @@ -1 +0,0 @@ | |||
281 | 1 | scripts/launchpadTrigger | ||
282 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
283 | diff --git a/scripts/autoland b/scripts/autoland | |||
284 | index 7ffac75..6279088 100755 | |||
285 | --- a/scripts/autoland | |||
286 | +++ b/scripts/autoland | |||
287 | @@ -1,4 +1,4 @@ | |||
289 | 1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python3 |
290 | 2 | import sys | 2 | import sys |
291 | 3 | # this is to keep backwards compatibility with deployments directly from | 3 | # this is to keep backwards compatibility with deployments directly from |
292 | 4 | # bzr branch | 4 | # bzr branch |
293 | diff --git a/scripts/dput b/scripts/dput | |||
294 | index 5d4e952..7bef560 100755 | |||
295 | --- a/scripts/dput | |||
296 | +++ b/scripts/dput | |||
297 | @@ -1,4 +1,4 @@ | |||
299 | 1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python3 |
300 | 2 | import sys | 2 | import sys |
301 | 3 | # this is to keep backwards compatibility with deployments directly from | 3 | # this is to keep backwards compatibility with deployments directly from |
302 | 4 | # bzr branch | 4 | # bzr branch |
303 | diff --git a/scripts/getMergeProposals b/scripts/getMergeProposals | |||
304 | index f21ffaf..c2b072b 100755 | |||
305 | --- a/scripts/getMergeProposals | |||
306 | +++ b/scripts/getMergeProposals | |||
307 | @@ -1,4 +1,4 @@ | |||
309 | 1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python3 |
310 | 2 | import sys | 2 | import sys |
311 | 3 | # this is to keep backwards compatibility with deployments directly from | 3 | # this is to keep backwards compatibility with deployments directly from |
312 | 4 | # bzr branch | 4 | # bzr branch |
313 | diff --git a/scripts/launchpadTrigger b/scripts/launchpadTrigger | |||
314 | index e62d7fc..28aa2e3 100755 | |||
315 | --- a/scripts/launchpadTrigger | |||
316 | +++ b/scripts/launchpadTrigger | |||
317 | @@ -1,4 +1,4 @@ | |||
319 | 1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python3 |
320 | 2 | import sys | 2 | import sys |
321 | 3 | # this is to keep backwards compatibility with deployments directly from | 3 | # this is to keep backwards compatibility with deployments directly from |
322 | 4 | # bzr branch | 4 | # bzr branch |
323 | diff --git a/scripts/voteOnMergeProposal b/scripts/voteOnMergeProposal | |||
324 | index c9274a6..61f099c 100755 | |||
325 | --- a/scripts/voteOnMergeProposal | |||
326 | +++ b/scripts/voteOnMergeProposal | |||
327 | @@ -1,4 +1,4 @@ | |||
329 | 1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python3 |
330 | 2 | import sys | 2 | import sys |
331 | 3 | # this is to keep backwards compatibility with deployments directly from | 3 | # this is to keep backwards compatibility with deployments directly from |
332 | 4 | # bzr branch | 4 | # bzr branch |
333 | diff --git a/setup.py b/setup.py | |||
334 | index db40a0b..346810d 100644 | |||
335 | --- a/setup.py | |||
336 | +++ b/setup.py | |||
337 | @@ -1,9 +1,10 @@ | |||
338 | 1 | from distutils.core import setup | 1 | from distutils.core import setup |
339 | 2 | from setuptools import find_packages | 2 | from setuptools import find_packages |
340 | 3 | from jlp import __version__ | ||
341 | 3 | import glob | 4 | import glob |
342 | 4 | setup( | 5 | setup( |
343 | 5 | name='jenkins-launchpad-plugin', | 6 | name='jenkins-launchpad-plugin', |
345 | 6 | version='0.1', | 7 | version=__version__, |
346 | 7 | url='https://launchpad.net/jenkins-launchpad-plugin', | 8 | url='https://launchpad.net/jenkins-launchpad-plugin', |
347 | 8 | packages=find_packages(), | 9 | packages=find_packages(), |
348 | 9 | include_package_data=True, | 10 | include_package_data=True, |
349 | diff --git a/tests/__init__.py b/tests/__init__.py | |||
350 | index 2cce6c0..2843c1f 100644 | |||
351 | --- a/tests/__init__.py | |||
352 | +++ b/tests/__init__.py | |||
353 | @@ -160,7 +160,7 @@ class JenkinsJSONData(): | |||
354 | 160 | 160 | ||
355 | 161 | def get_json_data(self, url, append_api=True): | 161 | def get_json_data(self, url, append_api=True): |
356 | 162 | url = url.rstrip('/') | 162 | url = url.rstrip('/') |
358 | 163 | print url | 163 | print(url) |
359 | 164 | if url == 'http://10.0.0.1:8080/job/my-job': | 164 | if url == 'http://10.0.0.1:8080/job/my-job': |
360 | 165 | return self.job_data | 165 | return self.job_data |
361 | 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': |
362 | diff --git a/tests/test_autoland.py b/tests/test_autoland.py | |||
363 | index e6d1aef..e82de4f 100644 | |||
364 | --- a/tests/test_autoland.py | |||
365 | +++ b/tests/test_autoland.py | |||
366 | @@ -1,10 +1,10 @@ | |||
367 | 1 | import unittest | 1 | import unittest |
370 | 2 | from mock import patch | 2 | from unittest.mock import patch |
371 | 3 | from mock import MagicMock | 3 | from unittest.mock import MagicMock |
372 | 4 | import tests.util as util | 4 | import tests.util as util |
373 | 5 | from jlp import get_config_option | 5 | from jlp import get_config_option |
374 | 6 | from tarmac.exceptions import TarmacMergeError, BranchHasConflicts | 6 | from tarmac.exceptions import TarmacMergeError, BranchHasConflicts |
376 | 7 | from bzrlib.errors import LockFailed | 7 | from breezy.errors import LockFailed |
377 | 8 | from jlp.launchpadutils import LaunchpadVote | 8 | from jlp.launchpadutils import LaunchpadVote |
378 | 9 | import jlp.commands.autoland as autoland | 9 | import jlp.commands.autoland as autoland |
379 | 10 | 10 | ||
380 | @@ -18,7 +18,7 @@ class TestGetFixesCommitMessage(unittest.TestCase): | |||
381 | 18 | b.web_link = 'http://' + str(i) | 18 | b.web_link = 'http://' + str(i) |
382 | 19 | mp.source_branch.linked_bugs_collection.append(b) | 19 | mp.source_branch.linked_bugs_collection.append(b) |
383 | 20 | ret = autoland.get_fixes_commit_message(mp) | 20 | ret = autoland.get_fixes_commit_message(mp) |
385 | 21 | expected = ' Fixes: http://0, http://1, http://2, http://3.' | 21 | expected = ' Fixes: http://0, http://1, http://2, http://3' |
386 | 22 | self.assertEqual(ret, expected) | 22 | self.assertEqual(ret, expected) |
387 | 23 | 23 | ||
388 | 24 | def test_no_bugs(self): | 24 | def test_no_bugs(self): |
389 | @@ -198,7 +198,7 @@ class TestAutolandVoting(TestAutolandForMergeAndCommit): | |||
390 | 198 | def test_last_vote_was_needs_fixing(self): | 198 | def test_last_vote_was_needs_fixing(self): |
391 | 199 | sys_argv = ['autoland.py', '-r', 'PASSED', | 199 | sys_argv = ['autoland.py', '-r', 'PASSED', |
392 | 200 | '-v', '123', '-m', 'url'] | 200 | '-v', '123', '-m', 'url'] |
394 | 201 | merge_and_commit = lambda x, y: 0 | 201 | merge_and_commit = lambda x, y, z: 0 |
395 | 202 | get_last_mp_vote = lambda x: LaunchpadVote.NEEDS_FIXING | 202 | get_last_mp_vote = lambda x: LaunchpadVote.NEEDS_FIXING |
396 | 203 | with patch('sys.argv', sys_argv), \ | 203 | with patch('sys.argv', sys_argv), \ |
397 | 204 | patch( | 204 | patch( |
398 | @@ -215,7 +215,7 @@ class TestAutolandVoting(TestAutolandForMergeAndCommit): | |||
399 | 215 | def test_last_vote_was_approved(self): | 215 | def test_last_vote_was_approved(self): |
400 | 216 | sys_argv = ['autoland.py', '-r', 'PASSED', | 216 | sys_argv = ['autoland.py', '-r', 'PASSED', |
401 | 217 | '-v', '123', '-m', 'url'] | 217 | '-v', '123', '-m', 'url'] |
403 | 218 | merge_and_commit = lambda y, z: 0 | 218 | merge_and_commit = lambda x, y, z: 0 |
404 | 219 | get_last_mp_vote = lambda x: LaunchpadVote.APPROVE | 219 | get_last_mp_vote = lambda x: LaunchpadVote.APPROVE |
405 | 220 | with patch('sys.argv', sys_argv), \ | 220 | with patch('sys.argv', sys_argv), \ |
406 | 221 | patch('jlp.commands.autoland.get_last_mp_vote', | 221 | patch('jlp.commands.autoland.get_last_mp_vote', |
407 | @@ -223,7 +223,7 @@ class TestAutolandVoting(TestAutolandForMergeAndCommit): | |||
408 | 223 | patch('jlp.commands.autoland.merge_and_commit', | 223 | patch('jlp.commands.autoland.merge_and_commit', |
409 | 224 | merge_and_commit): | 224 | merge_and_commit): |
410 | 225 | autoland.autoland() | 225 | autoland.autoland() |
412 | 226 | self.assertEquals(self.mp.createComment.call_count, 0) | 226 | self.assertEqual(self.mp.createComment.call_count, 0) |
413 | 227 | 227 | ||
414 | 228 | 228 | ||
415 | 229 | class TestAutolandMergeAndCommitWithDescription(TestAutolandForMergeAndCommit): | 229 | class TestAutolandMergeAndCommitWithDescription(TestAutolandForMergeAndCommit): |
416 | @@ -250,12 +250,13 @@ class TestAutolandWithMultipleDputs(TestAutolandForMergeAndCommit): | |||
417 | 250 | '-d', 'quantal,precise'] | 250 | '-d', 'quantal,precise'] |
418 | 251 | dputRunner = MagicMock() | 251 | dputRunner = MagicMock() |
419 | 252 | with patch('sys.argv', sys_argv), \ | 252 | with patch('sys.argv', sys_argv), \ |
421 | 253 | patch('jlp.commands.autoland.DputRunner', new=dputRunner): | 253 | patch('jlp.commands.autoland.DputRunner', new=dputRunner), \ |
422 | 254 | patch('jlp.commands.autoland.get_config_option'): | ||
423 | 254 | self.assertTrue(autoland.autoland() == 0) | 255 | self.assertTrue(autoland.autoland() == 0) |
424 | 255 | ppas_expected = ['ppa:myppa', 'ppa:myppa2'] | 256 | ppas_expected = ['ppa:myppa', 'ppa:myppa2'] |
425 | 256 | distributions_expected = ['quantal', 'precise'] | 257 | distributions_expected = ['quantal', 'precise'] |
428 | 257 | self.assertEquals(ppas_expected, dputRunner.call_args[1]['ppas']) | 258 | self.assertEqual(ppas_expected, dputRunner.call_args[1]['ppas']) |
429 | 258 | self.assertEquals(distributions_expected, | 259 | self.assertEqual(distributions_expected, |
430 | 259 | dputRunner.call_args[1]['distributions']) | 260 | dputRunner.call_args[1]['distributions']) |
431 | 260 | 261 | ||
432 | 261 | 262 | ||
433 | @@ -266,7 +267,8 @@ class TestAutolandWithReleaseOnly(TestAutolandForMergeAndCommit): | |||
434 | 266 | '-d', 'quantal', '--release-only'] | 267 | '-d', 'quantal', '--release-only'] |
435 | 267 | dputRunner = MagicMock() | 268 | dputRunner = MagicMock() |
436 | 268 | with patch('sys.argv', sys_argv), \ | 269 | with patch('sys.argv', sys_argv), \ |
438 | 269 | patch('jlp.commands.autoland.DputRunner', new=dputRunner): | 270 | patch('jlp.commands.autoland.DputRunner', new=dputRunner), \ |
439 | 271 | patch('jlp.commands.autoland.get_config_option'): | ||
440 | 270 | autoland.autoland() | 272 | autoland.autoland() |
441 | 271 | self.assertTrue(dputRunner.call_args[1]['release_only']) | 273 | self.assertTrue(dputRunner.call_args[1]['release_only']) |
442 | 272 | 274 | ||
443 | @@ -278,10 +280,11 @@ class TestAutolandWithVersionFormatString(TestAutolandForMergeAndCommit): | |||
444 | 278 | '-d', 'quantal', '-f', '{PACKAGE_VERSION}0'] | 280 | '-d', 'quantal', '-f', '{PACKAGE_VERSION}0'] |
445 | 279 | dputRunner = MagicMock() | 281 | dputRunner = MagicMock() |
446 | 280 | with patch('sys.argv', sys_argv), \ | 282 | with patch('sys.argv', sys_argv), \ |
448 | 281 | patch('jlp.commands.autoland.DputRunner', new=dputRunner): | 283 | patch('jlp.commands.autoland.DputRunner', new=dputRunner), \ |
449 | 284 | patch('jlp.commands.autoland.get_config_option'): | ||
450 | 282 | self.assertTrue(autoland.autoland() == 0) | 285 | self.assertTrue(autoland.autoland() == 0) |
451 | 283 | version_format_expected = '{PACKAGE_VERSION}0' | 286 | version_format_expected = '{PACKAGE_VERSION}0' |
453 | 284 | self.assertEquals(version_format_expected, | 287 | self.assertEqual(version_format_expected, |
454 | 285 | dputRunner.call_args[1]['versionFormat']) | 288 | dputRunner.call_args[1]['versionFormat']) |
455 | 286 | 289 | ||
456 | 287 | def test_quoted_string(self): | 290 | def test_quoted_string(self): |
457 | @@ -290,10 +293,11 @@ class TestAutolandWithVersionFormatString(TestAutolandForMergeAndCommit): | |||
458 | 290 | '-d', 'quantal', '-f', '"{PACKAGE_VERSION}"'] | 293 | '-d', 'quantal', '-f', '"{PACKAGE_VERSION}"'] |
459 | 291 | dputRunner = MagicMock() | 294 | dputRunner = MagicMock() |
460 | 292 | with patch('sys.argv', sys_argv), \ | 295 | with patch('sys.argv', sys_argv), \ |
462 | 293 | patch('jlp.commands.autoland.DputRunner', new=dputRunner): | 296 | patch('jlp.commands.autoland.DputRunner', new=dputRunner), \ |
463 | 297 | patch('jlp.commands.autoland.get_config_option'): | ||
464 | 294 | self.assertTrue(autoland.autoland() == 0) | 298 | self.assertTrue(autoland.autoland() == 0) |
465 | 295 | version_format_expected = '{PACKAGE_VERSION}' | 299 | version_format_expected = '{PACKAGE_VERSION}' |
467 | 296 | self.assertEquals(version_format_expected, | 300 | self.assertEqual(version_format_expected, |
468 | 297 | dputRunner.call_args[1]['versionFormat']) | 301 | dputRunner.call_args[1]['versionFormat']) |
469 | 298 | 302 | ||
470 | 299 | 303 | ||
471 | @@ -317,7 +321,8 @@ class TestAutolandMergeCommitAndDput(TestAutolandForMergeAndCommit): | |||
472 | 317 | '-a', 'packaging_branch', '-b', | 321 | '-a', 'packaging_branch', '-b', |
473 | 318 | 'http://10.0.0.1:8080/job/unity-daily/17/', '-d', | 322 | 'http://10.0.0.1:8080/job/unity-daily/17/', '-d', |
474 | 319 | 'precise'] | 323 | 'precise'] |
476 | 320 | with patch('sys.argv', sys_argv): | 324 | with patch('sys.argv', sys_argv), \ |
477 | 325 | patch('jlp.commands.autoland.get_config_option'): | ||
478 | 321 | self.assertTrue(autoland.autoland() == 0) | 326 | self.assertTrue(autoland.autoland() == 0) |
479 | 322 | self.assertTrue(self.target.merge.call_count == 1) | 327 | self.assertTrue(self.target.merge.call_count == 1) |
480 | 323 | self.assertTrue(self.target.commit.call_count == 1) | 328 | self.assertTrue(self.target.commit.call_count == 1) |
481 | diff --git a/tests/test_bzrrecipe.py b/tests/test_bzrrecipe.py | |||
482 | index be211ea..b31c564 100644 | |||
483 | --- a/tests/test_bzrrecipe.py | |||
484 | +++ b/tests/test_bzrrecipe.py | |||
485 | @@ -1,6 +1,6 @@ | |||
486 | 1 | import unittest | 1 | import unittest |
489 | 2 | from mock import patch | 2 | from unittest.mock import patch |
490 | 3 | from mock import MagicMock | 3 | from unittest.mock import MagicMock |
491 | 4 | from jlp import BzrRecipe | 4 | from jlp import BzrRecipe |
492 | 5 | from textwrap import dedent | 5 | from textwrap import dedent |
493 | 6 | 6 | ||
494 | @@ -15,8 +15,8 @@ class TestBzrRecipeInstantiation(unittest.TestCase): | |||
495 | 15 | nest-part ubuntu lp:dummy/packaging debian | 15 | nest-part ubuntu lp:dummy/packaging debian |
496 | 16 | ''') | 16 | ''') |
497 | 17 | recipe.generateRecipe() | 17 | recipe.generateRecipe() |
500 | 18 | self.assertEquals(recipe.recipe, expected) | 18 | self.assertEqual(recipe.recipe, expected) |
501 | 19 | self.assertEquals(recipe.getTrunkRevno(), 14) | 19 | self.assertEqual(recipe.getTrunkRevno(), 14) |
502 | 20 | 20 | ||
503 | 21 | def test_check_recipe_without_explicit_revision(self): | 21 | def test_check_recipe_without_explicit_revision(self): |
504 | 22 | bzr = MagicMock() | 22 | bzr = MagicMock() |
505 | @@ -29,8 +29,8 @@ class TestBzrRecipeInstantiation(unittest.TestCase): | |||
506 | 29 | nest-part ubuntu lp:dummy/packaging debian | 29 | nest-part ubuntu lp:dummy/packaging debian |
507 | 30 | ''') | 30 | ''') |
508 | 31 | recipe.generateRecipe() | 31 | recipe.generateRecipe() |
511 | 32 | self.assertEquals(recipe.recipe, expected) | 32 | self.assertEqual(recipe.recipe, expected) |
512 | 33 | self.assertEquals(recipe.getTrunkRevno(), 10) | 33 | self.assertEqual(recipe.getTrunkRevno(), 10) |
513 | 34 | 34 | ||
514 | 35 | def test_check_recipe_without_packaging_branch(self): | 35 | def test_check_recipe_without_packaging_branch(self): |
515 | 36 | bzr = MagicMock() | 36 | bzr = MagicMock() |
516 | @@ -43,8 +43,8 @@ class TestBzrRecipeInstantiation(unittest.TestCase): | |||
517 | 43 | # No packaging branch | 43 | # No packaging branch |
518 | 44 | ''') | 44 | ''') |
519 | 45 | recipe.generateRecipe() | 45 | recipe.generateRecipe() |
522 | 46 | self.assertEquals(recipe.recipe, expected) | 46 | self.assertEqual(recipe.recipe, expected) |
523 | 47 | self.assertEquals(recipe.getTrunkRevno(), 10) | 47 | self.assertEqual(recipe.getTrunkRevno(), 10) |
524 | 48 | 48 | ||
525 | 49 | def test_check_recipe_with_inline_packaging(self): | 49 | def test_check_recipe_with_inline_packaging(self): |
526 | 50 | bzr = MagicMock() | 50 | bzr = MagicMock() |
527 | @@ -57,15 +57,15 @@ class TestBzrRecipeInstantiation(unittest.TestCase): | |||
528 | 57 | # No packaging branch | 57 | # No packaging branch |
529 | 58 | ''') | 58 | ''') |
530 | 59 | recipe.generateRecipe() | 59 | recipe.generateRecipe() |
533 | 60 | self.assertEquals(recipe.recipe, expected) | 60 | self.assertEqual(recipe.recipe, expected) |
534 | 61 | self.assertEquals(recipe.getTrunkRevno(), 10) | 61 | self.assertEqual(recipe.getTrunkRevno(), 10) |
535 | 62 | 62 | ||
536 | 63 | def test_get_packaging_branch_revno(self): | 63 | def test_get_packaging_branch_revno(self): |
537 | 64 | bzr = MagicMock() | 64 | bzr = MagicMock() |
538 | 65 | bzr.revno = lambda self: 10 | 65 | bzr.revno = lambda self: 10 |
539 | 66 | with patch('jlp.bzrrecipe.Bazaar', new=MagicMock(return_value=bzr)): | 66 | with patch('jlp.bzrrecipe.Bazaar', new=MagicMock(return_value=bzr)): |
540 | 67 | recipe = BzrRecipe('lp:dummy', 'lp:dummy/packaging', 14) | 67 | recipe = BzrRecipe('lp:dummy', 'lp:dummy/packaging', 14) |
542 | 68 | self.assertEquals(recipe.getPackagingBranchRevno(), 10) | 68 | self.assertEqual(recipe.getPackagingBranchRevno(), 10) |
543 | 69 | 69 | ||
544 | 70 | def test_getDir_before_tree_building(self): | 70 | def test_getDir_before_tree_building(self): |
545 | 71 | with patch('jlp.bzrrecipe.Bazaar'): | 71 | with patch('jlp.bzrrecipe.Bazaar'): |
546 | @@ -219,10 +219,10 @@ class TestBzrRecipe(unittest.TestCase): | |||
547 | 219 | class TestBzrRecipeBuildTree(TestBzrRecipe): | 219 | class TestBzrRecipeBuildTree(TestBzrRecipe): |
548 | 220 | def test_buildTree(self): | 220 | def test_buildTree(self): |
549 | 221 | self.recipe.buildTree() | 221 | self.recipe.buildTree() |
551 | 222 | self.assertEquals( | 222 | self.assertEqual( |
552 | 223 | self.open_file.__enter__.return_value.write.call_count, 1) | 223 | self.open_file.__enter__.return_value.write.call_count, 1) |
555 | 224 | self.assertEquals(self.recipe.getBuildDir(), self.temp_dir) | 224 | self.assertEqual(self.recipe.getBuildDir(), self.temp_dir) |
556 | 225 | self.assertEquals(self.recipe.getTrunkDir(), | 225 | self.assertEqual(self.recipe.getTrunkDir(), |
557 | 226 | self.temp_dir + '/trunk') | 226 | self.temp_dir + '/trunk') |
558 | 227 | 227 | ||
559 | 228 | 228 | ||
560 | @@ -230,10 +230,10 @@ class TestBzrRecipeBuildTreeTwice(TestBzrRecipe): | |||
561 | 230 | def test_buildTree_twice(self): | 230 | def test_buildTree_twice(self): |
562 | 231 | self.recipe.buildTree() | 231 | self.recipe.buildTree() |
563 | 232 | self.recipe.buildTree() | 232 | self.recipe.buildTree() |
565 | 233 | self.assertEquals( | 233 | self.assertEqual( |
566 | 234 | self.open_file.__enter__.return_value.write.call_count, 1) | 234 | self.open_file.__enter__.return_value.write.call_count, 1) |
569 | 235 | self.assertEquals(self.recipe.getBuildDir(), self.temp_dir) | 235 | self.assertEqual(self.recipe.getBuildDir(), self.temp_dir) |
570 | 236 | self.assertEquals(self.recipe.getTrunkDir(), | 236 | self.assertEqual(self.recipe.getTrunkDir(), |
571 | 237 | self.temp_dir + '/trunk') | 237 | self.temp_dir + '/trunk') |
572 | 238 | 238 | ||
573 | 239 | 239 | ||
574 | diff --git a/tests/test_dput.py b/tests/test_dput.py | |||
575 | index b9267d9..3977d70 100644 | |||
576 | --- a/tests/test_dput.py | |||
577 | +++ b/tests/test_dput.py | |||
578 | @@ -1,6 +1,6 @@ | |||
579 | 1 | import jlp.commands.dput as dput | 1 | import jlp.commands.dput as dput |
580 | 2 | import unittest | 2 | import unittest |
582 | 3 | from mock import patch, MagicMock | 3 | from unittest.mock import patch, MagicMock |
583 | 4 | 4 | ||
584 | 5 | 5 | ||
585 | 6 | class TestDput(unittest.TestCase): | 6 | class TestDput(unittest.TestCase): |
586 | diff --git a/tests/test_dputrunner.py b/tests/test_dputrunner.py | |||
587 | index 80c35bd..8c51f38 100644 | |||
588 | --- a/tests/test_dputrunner.py | |||
589 | +++ b/tests/test_dputrunner.py | |||
590 | @@ -1,8 +1,8 @@ | |||
591 | 1 | import unittest | 1 | import unittest |
594 | 2 | from mock import patch, MagicMock | 2 | from unittest.mock import patch, MagicMock |
595 | 3 | import mock | 3 | from unittest import mock |
596 | 4 | try: | 4 | try: |
598 | 5 | from mock import call | 5 | from unittest.mock import call |
599 | 6 | except ImportError: | 6 | except ImportError: |
600 | 7 | pass | 7 | pass |
601 | 8 | from jlp import DputRunner | 8 | from jlp import DputRunner |
602 | @@ -69,8 +69,6 @@ class TestDputRunner(TestDputBase): | |||
603 | 69 | release_only=release_only)) | 69 | release_only=release_only)) |
604 | 70 | return calls | 70 | return calls |
605 | 71 | 71 | ||
606 | 72 | @unittest.skipIf(StrictVersion(mock.__version__) < StrictVersion('0.8'), | ||
607 | 73 | "assert_has_calls not suppored by mock < 0.8") | ||
608 | 74 | def test_dput(self): | 72 | def test_dput(self): |
609 | 75 | recipe = MagicMock() | 73 | recipe = MagicMock() |
610 | 76 | recipe.getTrunkRevno = lambda: 10 | 74 | recipe.getTrunkRevno = lambda: 10 |
611 | @@ -81,8 +79,6 @@ class TestDputRunner(TestDputBase): | |||
612 | 81 | calls = self._build_calls(recipe, False) | 79 | calls = self._build_calls(recipe, False) |
613 | 82 | self.dput_runner.doDput.assert_has_calls(calls) | 80 | self.dput_runner.doDput.assert_has_calls(calls) |
614 | 83 | 81 | ||
615 | 84 | @unittest.skipIf(StrictVersion(mock.__version__) < StrictVersion('0.8'), | ||
616 | 85 | "assert_has_calls not suppored by mock < 0.8") | ||
617 | 86 | def test_dput_release_only(self): | 82 | def test_dput_release_only(self): |
618 | 87 | recipe = MagicMock() | 83 | recipe = MagicMock() |
619 | 88 | recipe.getTrunkRevno = lambda: 10 | 84 | recipe.getTrunkRevno = lambda: 10 |
620 | @@ -154,8 +150,6 @@ class TestDput(TestDputBase): | |||
621 | 154 | cwd='/build')) | 150 | cwd='/build')) |
622 | 155 | return calls | 151 | return calls |
623 | 156 | 152 | ||
624 | 157 | @unittest.skipIf(StrictVersion(mock.__version__) < StrictVersion('0.8'), | ||
625 | 158 | "assert_has_calls not suppored by mock < 0.8") | ||
626 | 159 | def test_doDput(self): | 153 | def test_doDput(self): |
627 | 160 | recipe = self._build_recipe() | 154 | recipe = self._build_recipe() |
628 | 161 | check_call = MagicMock() | 155 | check_call = MagicMock() |
629 | @@ -173,8 +167,6 @@ class TestDput(TestDputBase): | |||
630 | 173 | release_only=False) | 167 | release_only=False) |
631 | 174 | check_call.assert_has_calls(calls) | 168 | check_call.assert_has_calls(calls) |
632 | 175 | 169 | ||
633 | 176 | @unittest.skipIf(StrictVersion(mock.__version__) < StrictVersion('0.8'), | ||
634 | 177 | "assert_has_calls not suppored by mock < 0.8") | ||
635 | 178 | def test_doDput_with_epoch(self): | 170 | def test_doDput_with_epoch(self): |
636 | 179 | recipe = self._build_recipe() | 171 | recipe = self._build_recipe() |
637 | 180 | check_call = MagicMock() | 172 | check_call = MagicMock() |
638 | @@ -193,8 +185,6 @@ class TestDput(TestDputBase): | |||
639 | 193 | release_only=False) | 185 | release_only=False) |
640 | 194 | check_call.assert_has_calls(calls) | 186 | check_call.assert_has_calls(calls) |
641 | 195 | 187 | ||
642 | 196 | @unittest.skipIf(StrictVersion(mock.__version__) < StrictVersion('0.8'), | ||
643 | 197 | "assert_has_calls not suppored by mock < 0.8") | ||
644 | 198 | def test_doReleaseOnlyDput(self): | 188 | def test_doReleaseOnlyDput(self): |
645 | 199 | recipe = self._build_recipe() | 189 | recipe = self._build_recipe() |
646 | 200 | check_call = MagicMock() | 190 | check_call = MagicMock() |
647 | @@ -287,7 +277,7 @@ class DPutVersionTests(TestWithScenarios, TestDput): | |||
648 | 287 | 277 | ||
649 | 288 | ('unknown tag', | 278 | ('unknown tag', |
650 | 289 | { | 279 | { |
652 | 290 | 'formatString': '{PACKAGE_VERSION}-{UNKOWN_TAG}', | 280 | 'formatString': '{PACKAGE_VERSION}-{UNKNOWN_TAG}', |
653 | 291 | 'variables': { | 281 | 'variables': { |
654 | 292 | 'PACKAGE_VERSION': 13, | 282 | 'PACKAGE_VERSION': 13, |
655 | 293 | 'BZR_REVISION': 43, | 283 | 'BZR_REVISION': 43, |
656 | @@ -303,4 +293,4 @@ class DPutVersionTests(TestWithScenarios, TestDput): | |||
657 | 303 | self.make_dput_runner(versionFormat=self.formatString) | 293 | self.make_dput_runner(versionFormat=self.formatString) |
658 | 304 | 294 | ||
659 | 305 | result_format = self.dput_runner.formatVersionString(**self.variables) | 295 | result_format = self.dput_runner.formatVersionString(**self.variables) |
661 | 306 | self.assertEquals(self.expectedResult, result_format) | 296 | self.assertEqual(self.expectedResult, result_format) |
662 | diff --git a/tests/test_getMergeProposals.py b/tests/test_getMergeProposals.py | |||
663 | index 4c1cc4f..399350b 100644 | |||
664 | --- a/tests/test_getMergeProposals.py | |||
665 | +++ b/tests/test_getMergeProposals.py | |||
666 | @@ -1,5 +1,5 @@ | |||
667 | 1 | import unittest | 1 | import unittest |
669 | 2 | from mock import patch, MagicMock | 2 | from unittest.mock import patch, MagicMock |
670 | 3 | import tests.util as util | 3 | import tests.util as util |
671 | 4 | from jlp.commands.getMergeProposals import getMergeProposals | 4 | from jlp.commands.getMergeProposals import getMergeProposals |
672 | 5 | 5 | ||
673 | @@ -32,12 +32,12 @@ class TestGetMergeProposal(unittest.TestCase): | |||
674 | 32 | """No branch specified; exit with error message.""" | 32 | """No branch specified; exit with error message.""" |
675 | 33 | 33 | ||
676 | 34 | sys_argv = ['getMergeProposals.py'] | 34 | sys_argv = ['getMergeProposals.py'] |
678 | 35 | error_message = 'error: too few arguments' | 35 | error_message = 'error: the following arguments are required: branch' |
679 | 36 | with patch('sys.argv', sys_argv), util.captured_stderr() as stderr: | 36 | with patch('sys.argv', sys_argv), util.captured_stderr() as stderr: |
680 | 37 | with self.assertRaises(SystemExit) as e: | 37 | with self.assertRaises(SystemExit) as e: |
681 | 38 | getMergeProposals() | 38 | getMergeProposals() |
682 | 39 | self.assertIn(error_message, stderr.getvalue()) | 39 | self.assertIn(error_message, stderr.getvalue()) |
684 | 40 | self.assertEquals(2, e.exception.code) | 40 | self.assertEqual(2, e.exception.code) |
685 | 41 | 41 | ||
686 | 42 | def test_no_mp_found_one_branch(self): | 42 | def test_no_mp_found_one_branch(self): |
687 | 43 | """One branch specified with no MPs found.""" | 43 | """One branch specified with no MPs found.""" |
688 | @@ -49,7 +49,7 @@ class TestGetMergeProposal(unittest.TestCase): | |||
689 | 49 | as get_merge_proposals: | 49 | as get_merge_proposals: |
690 | 50 | get_merge_proposals.return_value = [] | 50 | get_merge_proposals.return_value = [] |
691 | 51 | count = getMergeProposals() | 51 | count = getMergeProposals() |
693 | 52 | self.assertEquals(0, count) | 52 | self.assertEqual(0, count) |
694 | 53 | 53 | ||
695 | 54 | def test_no_mp_found_multiple_branches(self): | 54 | def test_no_mp_found_multiple_branches(self): |
696 | 55 | """Muiltipe branches specified with no MPs found.""" | 55 | """Muiltipe branches specified with no MPs found.""" |
697 | @@ -63,7 +63,7 @@ class TestGetMergeProposal(unittest.TestCase): | |||
698 | 63 | as get_merge_proposals: | 63 | as get_merge_proposals: |
699 | 64 | get_merge_proposals.return_value = [] | 64 | get_merge_proposals.return_value = [] |
700 | 65 | count = getMergeProposals() | 65 | count = getMergeProposals() |
702 | 66 | self.assertEquals(0, count) | 66 | self.assertEqual(0, count) |
703 | 67 | 67 | ||
704 | 68 | def test_mp_found_one_branch(self): | 68 | def test_mp_found_one_branch(self): |
705 | 69 | """One branch specified with one MP found.""" | 69 | """One branch specified with one MP found.""" |
706 | @@ -75,7 +75,7 @@ class TestGetMergeProposal(unittest.TestCase): | |||
707 | 75 | as get_merge_proposals: | 75 | as get_merge_proposals: |
708 | 76 | get_merge_proposals.return_value = ['Launchpad_mp'] | 76 | get_merge_proposals.return_value = ['Launchpad_mp'] |
709 | 77 | count = getMergeProposals() | 77 | count = getMergeProposals() |
711 | 78 | self.assertEquals(1, count) | 78 | self.assertEqual(1, count) |
712 | 79 | 79 | ||
713 | 80 | def test_mp_found_multiple_branches(self): | 80 | def test_mp_found_multiple_branches(self): |
714 | 81 | """One branch specified with multiple MPs found.""" | 81 | """One branch specified with multiple MPs found.""" |
715 | @@ -89,4 +89,4 @@ class TestGetMergeProposal(unittest.TestCase): | |||
716 | 89 | 'Launchpad_mp2', | 89 | 'Launchpad_mp2', |
717 | 90 | 'Launchpad_mp3'] | 90 | 'Launchpad_mp3'] |
718 | 91 | count = getMergeProposals() | 91 | count = getMergeProposals() |
720 | 92 | self.assertEquals(3, count) | 92 | self.assertEqual(3, count) |
721 | diff --git a/tests/test_jenkinsutils.py b/tests/test_jenkinsutils.py | |||
722 | index d0a6d9b..8c7bd85 100644 | |||
723 | --- a/tests/test_jenkinsutils.py | |||
724 | +++ b/tests/test_jenkinsutils.py | |||
725 | @@ -1,4 +1,4 @@ | |||
727 | 1 | from mock import MagicMock, patch | 1 | from unittest.mock import MagicMock, patch |
728 | 2 | from jlp import jenkinsutils, launchpadutils, _config | 2 | from jlp import jenkinsutils, launchpadutils, _config |
729 | 3 | import unittest | 3 | import unittest |
730 | 4 | from tests import JenkinsJSONData | 4 | from tests import JenkinsJSONData |
731 | @@ -222,7 +222,7 @@ class TestIsJobOrDownstreamBuildingScenarios(TestWithScenarios): | |||
732 | 222 | jenkins.get_json_data = lambda x, append_api=True: self.jenkins_data | 222 | jenkins.get_json_data = lambda x, append_api=True: self.jenkins_data |
733 | 223 | with patch('jlp.jenkinsutils.get_json_jenkins', | 223 | with patch('jlp.jenkinsutils.get_json_jenkins', |
734 | 224 | new=MagicMock(return_value=jenkins)): | 224 | new=MagicMock(return_value=jenkins)): |
736 | 225 | self.assertEquals( | 225 | self.assertEqual( |
737 | 226 | jenkinsutils.is_job_or_downstream_building( | 226 | jenkinsutils.is_job_or_downstream_building( |
738 | 227 | 'job', self.job_params), | 227 | 'job', self.job_params), |
739 | 228 | self.expected) | 228 | self.expected) |
740 | @@ -330,7 +330,7 @@ class TestGetRunningBuilds(TestWithScenarios): | |||
741 | 330 | jenkins.get_json_data = lambda x, append_api=True: self.jenkins_data | 330 | jenkins.get_json_data = lambda x, append_api=True: self.jenkins_data |
742 | 331 | with patch('jlp.jenkinsutils.get_json_jenkins', | 331 | with patch('jlp.jenkinsutils.get_json_jenkins', |
743 | 332 | new=MagicMock(return_value=jenkins)): | 332 | new=MagicMock(return_value=jenkins)): |
745 | 333 | self.assertEquals( | 333 | self.assertEqual( |
746 | 334 | jenkinsutils.get_running_builds('job', self.job_params), | 334 | jenkinsutils.get_running_builds('job', self.job_params), |
747 | 335 | self.expected) | 335 | self.expected) |
748 | 336 | 336 | ||
749 | @@ -494,7 +494,7 @@ class TestIsJobQueued(TestWithScenarios): | |||
750 | 494 | upstream_params = self.upstream_params | 494 | upstream_params = self.upstream_params |
751 | 495 | else: | 495 | else: |
752 | 496 | upstream_params = {} | 496 | upstream_params = {} |
754 | 497 | self.assertEquals( | 497 | self.assertEqual( |
755 | 498 | jenkinsutils.is_job_queued( | 498 | jenkinsutils.is_job_queued( |
756 | 499 | 'job', queue=self.queue, job_params=self.job_params, | 499 | 'job', queue=self.queue, job_params=self.job_params, |
757 | 500 | upstream_job=self.upstream_job, | 500 | upstream_job=self.upstream_job, |
758 | @@ -508,7 +508,7 @@ class TestGetBuildActions(unittest.TestCase): | |||
759 | 508 | json_jenkins = MagicMock() | 508 | json_jenkins = MagicMock() |
760 | 509 | json_jenkins.get_json_data.return_value = {} | 509 | json_jenkins.get_json_data.return_value = {} |
761 | 510 | get_json_jenkins.return_value = json_jenkins | 510 | get_json_jenkins.return_value = json_jenkins |
763 | 511 | self.assertEquals(jenkinsutils._get_build_actions('job', 23), | 511 | self.assertEqual(jenkinsutils._get_build_actions('job', 23), |
764 | 512 | []) | 512 | []) |
765 | 513 | 513 | ||
766 | 514 | @patch('jlp.jenkinsutils.get_json_jenkins') | 514 | @patch('jlp.jenkinsutils.get_json_jenkins') |
767 | @@ -554,7 +554,7 @@ class JenkinsUtilsGetDownstreamBuilds(unittest.TestCase): | |||
768 | 554 | 'http://ip:8080/job/', | 554 | 'http://ip:8080/job/', |
769 | 555 | 'my-job', | 555 | 'my-job', |
770 | 556 | 3, 11) | 556 | 3, 11) |
772 | 557 | self.assertEquals(ret, []) | 557 | self.assertEqual(ret, []) |
773 | 558 | 558 | ||
774 | 559 | def test_filter_intermediate_job(self): | 559 | def test_filter_intermediate_job(self): |
775 | 560 | blacklist = lambda name: ['job-freestyle'] | 560 | blacklist = lambda name: ['job-freestyle'] |
776 | @@ -675,11 +675,11 @@ class JenkinsUtilsGetExecutedBuilds(unittest.TestCase): | |||
777 | 675 | def test_get_executed_builds(self): | 675 | def test_get_executed_builds(self): |
778 | 676 | ret = jenkinsutils.get_executed_builds(self.jenkins, self.build_url) | 676 | ret = jenkinsutils.get_executed_builds(self.jenkins, self.build_url) |
779 | 677 | expected = [ | 677 | expected = [ |
782 | 678 | {'output': 'http://10.0.0.1:8080/job/job-multiconfig/.' + | 678 | {'output': 'http://10.0.0.1:8080/job/job-multiconfig/' + |
783 | 679 | '/distribution=raring,flavor=amd64/3/console', | 679 | 'distribution=raring,flavor=amd64/3/console', |
784 | 680 | 'result': 'FAILURE', }, | 680 | 'result': 'FAILURE', }, |
787 | 681 | {'output': 'http://10.0.0.1:8080/job/job-multiconfig/.' + | 681 | {'output': 'http://10.0.0.1:8080/job/job-multiconfig/' + |
788 | 682 | '/distribution=raring,flavor=i386/3/console', | 682 | 'distribution=raring,flavor=i386/3/console', |
789 | 683 | 'result': 'FAILURE', }, | 683 | 'result': 'FAILURE', }, |
790 | 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', |
791 | 685 | 'result': u'SUCCESS', }, | 685 | 'result': u'SUCCESS', }, |
792 | @@ -702,10 +702,10 @@ class JenkinsUtilsGetExecutedTestRuns(unittest.TestCase): | |||
793 | 702 | self.jenkins, | 702 | self.jenkins, |
794 | 703 | 'http://10.0.0.1:8080/job/job-multiconfig/' + | 703 | 'http://10.0.0.1:8080/job/job-multiconfig/' + |
795 | 704 | './distribution=raring,flavor=amd64/3/') | 704 | './distribution=raring,flavor=amd64/3/') |
797 | 705 | expected = ['http://10.0.0.1:8080/job/job-multiconfig/./' + | 705 | expected = ['http://10.0.0.1:8080/job/job-multiconfig/' + |
798 | 706 | 'distribution=raring,flavor=amd64/3/artifact/' + | 706 | 'distribution=raring,flavor=amd64/3/artifact/' + |
799 | 707 | 'results/coverity/CID_10895.html', | 707 | 'results/coverity/CID_10895.html', |
801 | 708 | 'http://10.0.0.1:8080/job/job-multiconfig/./' + | 708 | 'http://10.0.0.1:8080/job/job-multiconfig/' + |
802 | 709 | 'distribution=raring,flavor=amd64/3/artifact/results' + | 709 | 'distribution=raring,flavor=amd64/3/artifact/results' + |
803 | 710 | '/coverity/CID_10896.html'] | 710 | '/coverity/CID_10896.html'] |
804 | 711 | self.assertEqual(ret, expected) | 711 | self.assertEqual(ret, expected) |
805 | @@ -1258,10 +1258,7 @@ class TestTriggerAl(unittest.TestCase): | |||
806 | 1258 | [MagicMock(), MagicMock(), MagicMock()], | 1258 | [MagicMock(), MagicMock(), MagicMock()], |
807 | 1259 | 'job', 'url', None) | 1259 | 'job', 'url', None) |
808 | 1260 | self.assertEqual(start_jenkins_job.call_count, 0) | 1260 | self.assertEqual(start_jenkins_job.call_count, 0) |
813 | 1261 | # the new vote is the 5th argument in change_mp_status (and we count | 1261 | self.assertEqual(report_to_launchpad.call_args[1]['vote'], |
810 | 1262 | # from 0) | ||
811 | 1263 | new_vote_position = 4 | ||
812 | 1264 | self.assertEqual(report_to_launchpad.call_args[0][new_vote_position], | ||
814 | 1265 | launchpadutils.LaunchpadVote.NEEDS_FIXING) | 1262 | launchpadutils.LaunchpadVote.NEEDS_FIXING) |
815 | 1266 | 1263 | ||
816 | 1267 | @patch('jlp.launchpadutils.is_commit_message_set', | 1264 | @patch('jlp.launchpadutils.is_commit_message_set', |
817 | diff --git a/tests/test_jlp.py b/tests/test_jlp.py | |||
818 | index f46eb7c..651d1bc 100644 | |||
819 | --- a/tests/test_jlp.py | |||
820 | +++ b/tests/test_jlp.py | |||
821 | @@ -2,7 +2,7 @@ from unittest import TestCase | |||
822 | 2 | import jlp | 2 | import jlp |
823 | 3 | from jlp import (get_json_jenkins, load_config, get_config_option, | 3 | from jlp import (get_json_jenkins, load_config, get_config_option, |
824 | 4 | set_log_level) | 4 | set_log_level) |
826 | 5 | from mock import patch, MagicMock | 5 | from unittest.mock import patch, MagicMock |
827 | 6 | import logging | 6 | import logging |
828 | 7 | 7 | ||
829 | 8 | 8 | ||
830 | @@ -24,7 +24,7 @@ class TestGetJsonJenkins(TestCase): | |||
831 | 24 | """Existing JSONJenkins class must be returned when calling | 24 | """Existing JSONJenkins class must be returned when calling |
832 | 25 | get_json_jenkins 2+ time""" | 25 | get_json_jenkins 2+ time""" |
833 | 26 | ret = get_json_jenkins() | 26 | ret = get_json_jenkins() |
835 | 27 | self.assertEquals(ret, self.json_jenkins) | 27 | self.assertEqual(ret, self.json_jenkins) |
836 | 28 | 28 | ||
837 | 29 | @patch('jlp.load_config') | 29 | @patch('jlp.load_config') |
838 | 30 | def test_get_json_replace_no_url(self, load_config): | 30 | def test_get_json_replace_no_url(self, load_config): |
839 | @@ -37,7 +37,7 @@ class TestGetJsonJenkins(TestCase): | |||
840 | 37 | } | 37 | } |
841 | 38 | json_jenkins = get_json_jenkins() | 38 | json_jenkins = get_json_jenkins() |
842 | 39 | url = json_jenkins.patch_url('https://proxy/job/my-job') | 39 | url = json_jenkins.patch_url('https://proxy/job/my-job') |
844 | 40 | self.assertEquals(url, 'https://proxy/job/my-job') | 40 | self.assertEqual(url, 'https://proxy/job/my-job') |
845 | 41 | 41 | ||
846 | 42 | @patch('jlp.load_config') | 42 | @patch('jlp.load_config') |
847 | 43 | def test_get_json_replace_no_proxy_url(self, load_config): | 43 | def test_get_json_replace_no_proxy_url(self, load_config): |
848 | @@ -50,7 +50,7 @@ class TestGetJsonJenkins(TestCase): | |||
849 | 50 | } | 50 | } |
850 | 51 | json_jenkins = get_json_jenkins() | 51 | json_jenkins = get_json_jenkins() |
851 | 52 | url = json_jenkins.patch_url('https://proxy/subdir/job/my-job') | 52 | url = json_jenkins.patch_url('https://proxy/subdir/job/my-job') |
853 | 53 | self.assertEquals(url, 'https://proxy/subdir/job/my-job') | 53 | self.assertEqual(url, 'https://proxy/subdir/job/my-job') |
854 | 54 | 54 | ||
855 | 55 | @patch('jlp.load_config') | 55 | @patch('jlp.load_config') |
856 | 56 | def test_get_json_replace_proxy_url(self, load_config): | 56 | def test_get_json_replace_proxy_url(self, load_config): |
857 | @@ -64,7 +64,7 @@ class TestGetJsonJenkins(TestCase): | |||
858 | 64 | } | 64 | } |
859 | 65 | json_jenkins = get_json_jenkins() | 65 | json_jenkins = get_json_jenkins() |
860 | 66 | url = json_jenkins.patch_url('https://proxy/subdir/job/my-job') | 66 | url = json_jenkins.patch_url('https://proxy/subdir/job/my-job') |
862 | 67 | self.assertEquals(url, 'http://backend:8080/subdir/job/my-job') | 67 | self.assertEqual(url, 'http://backend:8080/subdir/job/my-job') |
863 | 68 | 68 | ||
864 | 69 | @patch('jlp._json_jenkins', new=None) | 69 | @patch('jlp._json_jenkins', new=None) |
865 | 70 | @patch('jlp.JSONJenkins') | 70 | @patch('jlp.JSONJenkins') |
866 | @@ -72,34 +72,34 @@ class TestGetJsonJenkins(TestCase): | |||
867 | 72 | """Test that json_jenkins is returned when get_json_jenkins is called | 72 | """Test that json_jenkins is returned when get_json_jenkins is called |
868 | 73 | for the first time""" | 73 | for the first time""" |
869 | 74 | ret = get_json_jenkins() | 74 | ret = get_json_jenkins() |
871 | 75 | self.assertEquals(json_jenkins.call_count, 1) | 75 | self.assertEqual(json_jenkins.call_count, 1) |
872 | 76 | self.assertIsNotNone(ret) | 76 | self.assertIsNotNone(ret) |
873 | 77 | 77 | ||
874 | 78 | @patch('jlp._config', new=config) | 78 | @patch('jlp._config', new=config) |
875 | 79 | @patch('jlp.yaml.safe_load') | 79 | @patch('jlp.yaml.safe_load') |
876 | 80 | def test_load_config_subsequent_time(self, safe_load): | 80 | def test_load_config_subsequent_time(self, safe_load): |
877 | 81 | ret = load_config() | 81 | ret = load_config() |
880 | 82 | self.assertEquals(safe_load.call_count, 0) | 82 | self.assertEqual(safe_load.call_count, 0) |
881 | 83 | self.assertEquals(ret, self.config) | 83 | self.assertEqual(ret, self.config) |
882 | 84 | 84 | ||
883 | 85 | @patch('jlp._config', new=None) | 85 | @patch('jlp._config', new=None) |
885 | 86 | @patch('__builtin__.open') | 86 | @patch('builtins.open') |
886 | 87 | @patch('jlp.yaml.safe_load') | 87 | @patch('jlp.yaml.safe_load') |
887 | 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): |
888 | 89 | ret = load_config() | 89 | ret = load_config() |
890 | 90 | self.assertEquals(safe_load.call_count, 1) | 90 | self.assertEqual(safe_load.call_count, 1) |
891 | 91 | self.assertIsNotNone(ret) | 91 | self.assertIsNotNone(ret) |
892 | 92 | 92 | ||
893 | 93 | @patch('jlp._config', new=None) | 93 | @patch('jlp._config', new=None) |
895 | 94 | @patch('__builtin__.open', new=custom_open) | 94 | @patch('builtins.open', new=custom_open) |
896 | 95 | @patch('jlp.yaml.safe_load') | 95 | @patch('jlp.yaml.safe_load') |
897 | 96 | def test_load_config_from_cwd_first_time(self, safe_load): | 96 | def test_load_config_from_cwd_first_time(self, safe_load): |
898 | 97 | ret = load_config() | 97 | ret = load_config() |
899 | 98 | self.assertIsNotNone(ret) | 98 | self.assertIsNotNone(ret) |
901 | 99 | self.assertEquals(safe_load.call_count, 1) | 99 | self.assertEqual(safe_load.call_count, 1) |
902 | 100 | 100 | ||
903 | 101 | @patch('jlp._config', new=None) | 101 | @patch('jlp._config', new=None) |
905 | 102 | @patch('__builtin__.open') | 102 | @patch('builtins.open') |
906 | 103 | def test_no_config_found(self, open_mock): | 103 | def test_no_config_found(self, open_mock): |
907 | 104 | """If no config is found jlp should sys.exit with 1""" | 104 | """If no config is found jlp should sys.exit with 1""" |
908 | 105 | open_mock.side_effect = IOError() | 105 | open_mock.side_effect = IOError() |
909 | @@ -107,7 +107,7 @@ class TestGetJsonJenkins(TestCase): | |||
910 | 107 | try: | 107 | try: |
911 | 108 | load_config() | 108 | load_config() |
912 | 109 | except SystemExit as e: | 109 | except SystemExit as e: |
914 | 110 | self.assertEquals(e.code, 1) | 110 | self.assertEqual(e.code, 1) |
915 | 111 | systemExit = True | 111 | systemExit = True |
916 | 112 | self.assertTrue(systemExit) | 112 | self.assertTrue(systemExit) |
917 | 113 | 113 | ||
918 | @@ -116,7 +116,7 @@ class TestGetJsonJenkins(TestCase): | |||
919 | 116 | """get_config_option must return the right value for a defined | 116 | """get_config_option must return the right value for a defined |
920 | 117 | option""" | 117 | option""" |
921 | 118 | value = get_config_option('my_option') | 118 | value = get_config_option('my_option') |
923 | 119 | self.assertEquals(value, 'my_value') | 119 | self.assertEqual(value, 'my_value') |
924 | 120 | 120 | ||
925 | 121 | @patch('jlp.load_config', new=lambda: {'my_option': 'my_value'}) | 121 | @patch('jlp.load_config', new=lambda: {'my_option': 'my_value'}) |
926 | 122 | def test_get_invalid_config_option(self): | 122 | def test_get_invalid_config_option(self): |
927 | diff --git a/tests/test_launchpadTrigger.py b/tests/test_launchpadTrigger.py | |||
928 | index 6e01673..78075e1 100644 | |||
929 | --- a/tests/test_launchpadTrigger.py | |||
930 | +++ b/tests/test_launchpadTrigger.py | |||
931 | @@ -1,5 +1,5 @@ | |||
932 | 1 | import unittest | 1 | import unittest |
934 | 2 | from mock import patch, MagicMock | 2 | from unittest.mock import patch, MagicMock |
935 | 3 | import tests.util as util | 3 | import tests.util as util |
936 | 4 | from jlp.commands.launchpadTrigger import launchpadTrigger, trigger_jenkins | 4 | from jlp.commands.launchpadTrigger import launchpadTrigger, trigger_jenkins |
937 | 5 | from jlp import get_config_option | 5 | from jlp import get_config_option |
938 | @@ -57,7 +57,8 @@ class TestLaunchpadTriggerParams(PatchedLaunchpadTriggerTest): | |||
939 | 57 | "-a", | 57 | "-a", |
940 | 58 | "--job=faux-dbus-test-runner", | 58 | "--job=faux-dbus-test-runner", |
941 | 59 | "--autoland"] | 59 | "--autoland"] |
943 | 60 | error_message = "error: argument -b/--branch is required" | 60 | error_message = ("error: the following arguments are required: " |
944 | 61 | "-b/--branch") | ||
945 | 61 | with patch('sys.argv', sys_argv), \ | 62 | with patch('sys.argv', sys_argv), \ |
946 | 62 | util.captured_stderr() as stderr: | 63 | util.captured_stderr() as stderr: |
947 | 63 | try: | 64 | try: |
948 | @@ -74,7 +75,7 @@ class TestLaunchpadTriggerParams(PatchedLaunchpadTriggerTest): | |||
949 | 74 | "-n", | 75 | "-n", |
950 | 75 | "--branch=lp:faux-dbus-test-runner", | 76 | "--branch=lp:faux-dbus-test-runner", |
951 | 76 | "--autoland"] | 77 | "--autoland"] |
953 | 77 | error_message = 'argument -j/--job is required' | 78 | error_message = 'error: the following arguments are required: -j/--job' |
954 | 78 | with patch('sys.argv', sys_argv), \ | 79 | with patch('sys.argv', sys_argv), \ |
955 | 79 | util.captured_stderr() as stderr: | 80 | util.captured_stderr() as stderr: |
956 | 80 | try: | 81 | try: |
957 | @@ -154,7 +155,7 @@ class TestLaunchpadTriggerParams(PatchedLaunchpadTriggerTest): | |||
958 | 154 | patch('jlp.commands.launchpadTrigger.get_merge_proposals') as \ | 155 | patch('jlp.commands.launchpadTrigger.get_merge_proposals') as \ |
959 | 155 | get_merge_proposals, \ | 156 | get_merge_proposals, \ |
960 | 156 | patch('jlp.commands.launchpadTrigger.jenkinsutils.' + | 157 | patch('jlp.commands.launchpadTrigger.jenkinsutils.' + |
962 | 157 | 'trigger_ci_build') as trigger_ci_build: | 158 | 'trigger_ci_build'): |
963 | 158 | get_merge_proposals.return_value = [self.merge_proposal] | 159 | get_merge_proposals.return_value = [self.merge_proposal] |
964 | 159 | launchpadTrigger() | 160 | launchpadTrigger() |
965 | 160 | get_merge_proposals.assert_called_with(self.launchpad, | 161 | get_merge_proposals.assert_called_with(self.launchpad, |
966 | diff --git a/tests/test_launchpadutils.py b/tests/test_launchpadutils.py | |||
967 | index 19febf2..cdb5b10 100644 | |||
968 | --- a/tests/test_launchpadutils.py | |||
969 | +++ b/tests/test_launchpadutils.py | |||
970 | @@ -1,8 +1,7 @@ | |||
971 | 1 | import unittest | 1 | import unittest |
972 | 2 | from jlp import launchpadutils, get_config_option | 2 | from jlp import launchpadutils, get_config_option |
974 | 3 | from mock import MagicMock, patch | 3 | from unittest.mock import MagicMock, patch |
975 | 4 | from testscenarios import TestWithScenarios | 4 | from testscenarios import TestWithScenarios |
976 | 5 | from textwrap import dedent | ||
977 | 6 | 5 | ||
978 | 7 | 6 | ||
979 | 8 | class LaunchpadUtilsTests(unittest.TestCase): | 7 | class LaunchpadUtilsTests(unittest.TestCase): |
980 | @@ -104,7 +103,7 @@ class LaunchpadUtilsTests(unittest.TestCase): | |||
981 | 104 | vote.comment.vote = 'Approve' | 103 | vote.comment.vote = 'Approve' |
982 | 105 | reviews = launchpadutils.get_reviews(mp) | 104 | reviews = launchpadutils.get_reviews(mp) |
983 | 106 | for review in reviews: | 105 | for review in reviews: |
985 | 107 | self.assertEquals(review, 'jenkins;Approve') | 106 | self.assertEqual(review, 'jenkins;Approve') |
986 | 108 | 107 | ||
987 | 109 | def test_unapproved_prerequisite_no_prerequisite(self): | 108 | def test_unapproved_prerequisite_no_prerequisite(self): |
988 | 110 | mp = MagicMock() | 109 | mp = MagicMock() |
989 | @@ -651,13 +650,13 @@ class TestGetGitMergeProposals(unittest.TestCase): | |||
990 | 651 | def test_get_git_merge_proposals_with_wrong_launchpad_version(self): | 650 | def test_get_git_merge_proposals_with_wrong_launchpad_version(self): |
991 | 652 | launchpad = self._get_launchpad_without_git() | 651 | launchpad = self._get_launchpad_without_git() |
992 | 653 | with self.assertRaises(RuntimeError): | 652 | with self.assertRaises(RuntimeError): |
994 | 654 | ret = launchpadutils.get_merge_proposals(launchpad, '', '', | 653 | launchpadutils.get_merge_proposals(launchpad, '', '', |
995 | 655 | repo_type='git') | 654 | repo_type='git') |
996 | 656 | 655 | ||
997 | 657 | def test_invalid_repo_type(self): | 656 | def test_invalid_repo_type(self): |
998 | 658 | launchpad = self._get_launchpad(None) | 657 | launchpad = self._get_launchpad(None) |
999 | 659 | with self.assertRaises(RuntimeError): | 658 | with self.assertRaises(RuntimeError): |
1001 | 660 | ret = launchpadutils.get_merge_proposals(launchpad, '', '', | 659 | launchpadutils.get_merge_proposals(launchpad, '', '', |
1002 | 661 | repo_type='test') | 660 | repo_type='test') |
1003 | 662 | 661 | ||
1004 | 663 | class TestGetMpHandleFromURL(unittest.TestCase): | 662 | class TestGetMpHandleFromURL(unittest.TestCase): |
1005 | @@ -666,7 +665,7 @@ class TestGetMpHandleFromURL(unittest.TestCase): | |||
1006 | 666 | """If there is no way how to get branch link from the merge proposal | 665 | """If there is no way how to get branch link from the merge proposal |
1007 | 667 | url then get_mp_handle_from_url must return None""" | 666 | url then get_mp_handle_from_url must return None""" |
1008 | 668 | ret = launchpadutils.get_mp_handle_from_url(MagicMock(), 'http://') | 667 | ret = launchpadutils.get_mp_handle_from_url(MagicMock(), 'http://') |
1010 | 669 | self.assertEquals(ret, None) | 668 | self.assertEqual(ret, None) |
1011 | 670 | 669 | ||
1012 | 671 | @patch("jlp.launchpadutils.get_branch_from_mp", new=lambda x: 'http://') | 670 | @patch("jlp.launchpadutils.get_branch_from_mp", new=lambda x: 'http://') |
1013 | 672 | def test_unable_to_get_branch_handle(self): | 671 | def test_unable_to_get_branch_handle(self): |
1014 | @@ -675,7 +674,7 @@ class TestGetMpHandleFromURL(unittest.TestCase): | |||
1015 | 675 | launchpad = MagicMock() | 674 | launchpad = MagicMock() |
1016 | 676 | launchpad.branches.getByUrl = lambda url: None | 675 | launchpad.branches.getByUrl = lambda url: None |
1017 | 677 | ret = launchpadutils.get_mp_handle_from_url(launchpad, 'http://') | 676 | ret = launchpadutils.get_mp_handle_from_url(launchpad, 'http://') |
1019 | 678 | self.assertEquals(ret, None) | 677 | self.assertEqual(ret, None) |
1020 | 679 | 678 | ||
1021 | 680 | @patch("jlp.launchpadutils.get_branch_from_mp", new=lambda x: 'http://') | 679 | @patch("jlp.launchpadutils.get_branch_from_mp", new=lambda x: 'http://') |
1022 | 681 | def test_get_mp_handle_from_url(self): | 680 | def test_get_mp_handle_from_url(self): |
1023 | @@ -691,7 +690,7 @@ class TestGetMpHandleFromURL(unittest.TestCase): | |||
1024 | 691 | branch.landing_targets = [mp] | 690 | branch.landing_targets = [mp] |
1025 | 692 | launchpad.branches.getByUrl = lambda url: branch | 691 | launchpad.branches.getByUrl = lambda url: branch |
1026 | 693 | ret = launchpadutils.get_mp_handle_from_url(launchpad, mp_url) | 692 | ret = launchpadutils.get_mp_handle_from_url(launchpad, mp_url) |
1028 | 694 | self.assertEquals(ret, mp) | 693 | self.assertEqual(ret, mp) |
1029 | 695 | 694 | ||
1030 | 696 | def test_call_git_api_for_git_url(self): | 695 | def test_call_git_api_for_git_url(self): |
1031 | 697 | """If there is a merge proposal for the given merge proposal URL then | 696 | """If there is a merge proposal for the given merge proposal URL then |
1032 | @@ -706,7 +705,7 @@ class TestGetMpHandleFromURL(unittest.TestCase): | |||
1033 | 706 | git_repo.landing_targets = [mp] | 705 | git_repo.landing_targets = [mp] |
1034 | 707 | launchpad.git_repositories.getByPath = lambda path: git_repo | 706 | launchpad.git_repositories.getByPath = lambda path: git_repo |
1035 | 708 | ret = launchpadutils.get_mp_handle_from_url(launchpad, mp_url) | 707 | ret = launchpadutils.get_mp_handle_from_url(launchpad, mp_url) |
1037 | 709 | self.assertEquals(ret, mp) | 708 | self.assertEqual(ret, mp) |
1038 | 710 | 709 | ||
1039 | 711 | class TestGetBranchHandle(unittest.TestCase): | 710 | class TestGetBranchHandle(unittest.TestCase): |
1040 | 712 | def setUp(self): | 711 | def setUp(self): |
1041 | @@ -807,7 +806,7 @@ class TestGetBranchHandle(unittest.TestCase): | |||
1042 | 807 | name = 'lp:dummy' | 806 | name = 'lp:dummy' |
1043 | 808 | # Create multiple matches to be returned for the url | 807 | # Create multiple matches to be returned for the url |
1044 | 809 | branch = self.create_fake_bazaar_branch() | 808 | branch = self.create_fake_bazaar_branch() |
1046 | 810 | repo = self.create_fake_git_repo() | 809 | self.create_fake_git_repo() |
1047 | 811 | result = launchpadutils.get_branch_handle_for(self.launchpad, name, | 810 | result = launchpadutils.get_branch_handle_for(self.launchpad, name, |
1048 | 812 | 'bazaar'); | 811 | 'bazaar'); |
1049 | 813 | self.assertEqual(result, ('bazaar', branch)) | 812 | self.assertEqual(result, ('bazaar', branch)) |
1050 | @@ -818,7 +817,7 @@ class TestGetBranchHandle(unittest.TestCase): | |||
1051 | 818 | ''' | 817 | ''' |
1052 | 819 | name = 'lp:dummy' | 818 | name = 'lp:dummy' |
1053 | 820 | # Create multiple matches to be returned for the url | 819 | # Create multiple matches to be returned for the url |
1055 | 821 | branch = self.create_fake_bazaar_branch() | 820 | self.create_fake_bazaar_branch() |
1056 | 822 | repo = self.create_fake_git_repo() | 821 | repo = self.create_fake_git_repo() |
1057 | 823 | result = launchpadutils.get_branch_handle_for(self.launchpad, name, | 822 | result = launchpadutils.get_branch_handle_for(self.launchpad, name, |
1058 | 824 | 'git'); | 823 | 'git'); |
1059 | diff --git a/tests/test_voteOnMergeProposal.py b/tests/test_voteOnMergeProposal.py | |||
1060 | index 4f9523c..0378006 100644 | |||
1061 | --- a/tests/test_voteOnMergeProposal.py | |||
1062 | +++ b/tests/test_voteOnMergeProposal.py | |||
1063 | @@ -1,5 +1,5 @@ | |||
1064 | 1 | import unittest | 1 | import unittest |
1066 | 2 | from mock import patch, MagicMock | 2 | from unittest.mock import patch, MagicMock |
1067 | 3 | import tests.util as util | 3 | import tests.util as util |
1068 | 4 | from jlp.commands.voteOnMergeProposal import voteOnMergeProposal | 4 | from jlp.commands.voteOnMergeProposal import voteOnMergeProposal |
1069 | 5 | 5 | ||
1070 | @@ -41,13 +41,14 @@ class TestVoteOnMergeProposal(unittest.TestCase): | |||
1071 | 41 | '--branch="lp:~mrazik/faux-dbus-test-runner/yar8"', | 41 | '--branch="lp:~mrazik/faux-dbus-test-runner/yar8"', |
1072 | 42 | '--merge-proposal="https://code.launchpad.net/~mrazik/' + | 42 | '--merge-proposal="https://code.launchpad.net/~mrazik/' + |
1073 | 43 | 'faux-dbus-test-runner/yar8/+merge/106113"'] | 43 | 'faux-dbus-test-runner/yar8/+merge/106113"'] |
1075 | 44 | error_message = 'error: argument -u/--build-url is required' | 44 | error_message = ('error: the following arguments are required: ' |
1076 | 45 | '-u/--build-url') | ||
1077 | 45 | with patch('sys.argv', sys_argv), \ | 46 | with patch('sys.argv', sys_argv), \ |
1078 | 46 | util.captured_stderr() as stderr: | 47 | util.captured_stderr() as stderr: |
1079 | 47 | with self.assertRaises(SystemExit) as e: | 48 | with self.assertRaises(SystemExit) as e: |
1080 | 48 | voteOnMergeProposal() | 49 | voteOnMergeProposal() |
1081 | 49 | self.assertTrue(error_message in stderr.getvalue()) | 50 | self.assertTrue(error_message in stderr.getvalue()) |
1083 | 50 | self.assertEquals(2, e.exception.code) | 51 | self.assertEqual(2, e.exception.code) |
1084 | 51 | 52 | ||
1085 | 52 | def test_no_revision_specified(self): | 53 | def test_no_revision_specified(self): |
1086 | 53 | """No revision specified; exit with message.""" | 54 | """No revision specified; exit with message.""" |
1087 | @@ -59,13 +60,14 @@ class TestVoteOnMergeProposal(unittest.TestCase): | |||
1088 | 59 | '--branch="lp:~mrazik/faux-dbus-test-runner/yar8"', | 60 | '--branch="lp:~mrazik/faux-dbus-test-runner/yar8"', |
1089 | 60 | '--merge-proposal="https://code.launchpad.net/~mrazik/' + | 61 | '--merge-proposal="https://code.launchpad.net/~mrazik/' + |
1090 | 61 | 'faux-dbus-test-runner/yar8/+merge/106113"'] | 62 | 'faux-dbus-test-runner/yar8/+merge/106113"'] |
1092 | 62 | error_message = 'error: argument -r/--revision is required' | 63 | error_message = ('error: the following arguments are required: ' |
1093 | 64 | '-r/--revision') | ||
1094 | 63 | with patch('sys.argv', sys_argv), \ | 65 | with patch('sys.argv', sys_argv), \ |
1095 | 64 | util.captured_stderr() as stderr: | 66 | util.captured_stderr() as stderr: |
1096 | 65 | with self.assertRaises(SystemExit) as e: | 67 | with self.assertRaises(SystemExit) as e: |
1097 | 66 | voteOnMergeProposal() | 68 | voteOnMergeProposal() |
1098 | 67 | self.assertTrue(error_message in stderr.getvalue()) | 69 | self.assertTrue(error_message in stderr.getvalue()) |
1100 | 68 | self.assertEquals(2, e.exception.code) | 70 | self.assertEqual(2, e.exception.code) |
1101 | 69 | 71 | ||
1102 | 70 | def test_no_merge_proposal_specified(self): | 72 | def test_no_merge_proposal_specified(self): |
1103 | 71 | """No merge_proposal specified; exit with message.""" | 73 | """No merge_proposal specified; exit with message.""" |
1104 | @@ -76,13 +78,14 @@ class TestVoteOnMergeProposal(unittest.TestCase): | |||
1105 | 76 | 'faux-dbus-test-runner-ci/configure"', | 78 | 'faux-dbus-test-runner-ci/configure"', |
1106 | 77 | '--revision=66', | 79 | '--revision=66', |
1107 | 78 | '--branch="lp:~mrazik/faux-dbus-test-runner/yar8"'] | 80 | '--branch="lp:~mrazik/faux-dbus-test-runner/yar8"'] |
1109 | 79 | error_message = 'error: argument -p/--merge-proposal is required' | 81 | error_message = ('error: the following arguments are required: ' |
1110 | 82 | '-p/--merge-proposal') | ||
1111 | 80 | with patch('sys.argv', sys_argv), \ | 83 | with patch('sys.argv', sys_argv), \ |
1112 | 81 | util.captured_stderr() as stderr: | 84 | util.captured_stderr() as stderr: |
1113 | 82 | with self.assertRaises(SystemExit) as e: | 85 | with self.assertRaises(SystemExit) as e: |
1114 | 83 | voteOnMergeProposal() | 86 | voteOnMergeProposal() |
1115 | 84 | self.assertTrue(error_message in stderr.getvalue()) | 87 | self.assertTrue(error_message in stderr.getvalue()) |
1117 | 85 | self.assertEquals(2, e.exception.code) | 88 | self.assertEqual(2, e.exception.code) |
1118 | 86 | 89 | ||
1119 | 87 | def test_unknown_merge_proposal(self): | 90 | def test_unknown_merge_proposal(self): |
1120 | 88 | """The given merge proposal wasn't found; error out with message.""" | 91 | """The given merge proposal wasn't found; error out with message.""" |
1121 | @@ -108,12 +111,11 @@ class TestVoteOnMergeProposal(unittest.TestCase): | |||
1122 | 108 | pass | 111 | pass |
1123 | 109 | self.assertTrue(error_message in stderr.getvalue()) | 112 | self.assertTrue(error_message in stderr.getvalue()) |
1124 | 110 | 113 | ||
1125 | 111 | @patch('sys.argv') | ||
1126 | 112 | @patch('jlp.commands.voteOnMergeProposal.launchpadutils.get_mp_handle_from_url') | 114 | @patch('jlp.commands.voteOnMergeProposal.launchpadutils.get_mp_handle_from_url') |
1127 | 113 | @patch('jlp.launchpadutils.report_to_launchpad') | 115 | @patch('jlp.launchpadutils.report_to_launchpad') |
1128 | 114 | @patch('jlp.commands.voteOnMergeProposal.launchpadutils.get_template_args') | 116 | @patch('jlp.commands.voteOnMergeProposal.launchpadutils.get_template_args') |
1129 | 115 | @patch('jlp.commands.voteOnMergeProposal.get_jinja_environment') | 117 | @patch('jlp.commands.voteOnMergeProposal.get_jinja_environment') |
1131 | 116 | def test_passed_vote(self, gje, gta, rtl, gmphandle, sys_argv): | 118 | def test_passed_vote(self, gje, gta, rtl, gmphandle): |
1132 | 117 | """Vote on a proposal which passed.""" | 119 | """Vote on a proposal which passed.""" |
1133 | 118 | 120 | ||
1134 | 119 | sys_argv = ['voteOnMergeProposal.py', | 121 | sys_argv = ['voteOnMergeProposal.py', |
1135 | @@ -130,21 +132,20 @@ class TestVoteOnMergeProposal(unittest.TestCase): | |||
1136 | 130 | 'result': 'PASSED', | 132 | 'result': 'PASSED', |
1137 | 131 | 'revision': '66' | 133 | 'revision': '66' |
1138 | 132 | } | 134 | } |
1140 | 133 | ret = voteOnMergeProposal() | 135 | with patch('sys.argv', sys_argv): |
1141 | 136 | ret = voteOnMergeProposal() | ||
1142 | 134 | self.assertEqual(ret, 0) | 137 | self.assertEqual(ret, 0) |
1143 | 135 | rtl.assert_called_once() | 138 | rtl.assert_called_once() |
1145 | 136 | gje.get_template.assert_called_with('ci_test.j2') | 139 | gje.return_value.get_template.assert_called_with('ci_test.j2') |
1146 | 137 | 140 | ||
1147 | 138 | 141 | ||
1148 | 139 | @patch('sys.argv') | ||
1149 | 140 | @patch('jlp.commands.voteOnMergeProposal.launchpadutils.' +\ | 142 | @patch('jlp.commands.voteOnMergeProposal.launchpadutils.' +\ |
1150 | 141 | 'get_mp_handle_from_url') | 143 | 'get_mp_handle_from_url') |
1151 | 142 | @patch('jlp.launchpadutils.report_to_launchpad') | 144 | @patch('jlp.launchpadutils.report_to_launchpad') |
1152 | 143 | @patch('jlp.launchpadutils.is_commit_message_set') | 145 | @patch('jlp.launchpadutils.is_commit_message_set') |
1153 | 144 | @patch('jlp.commands.voteOnMergeProposal.launchpadutils.get_template_args') | 146 | @patch('jlp.commands.voteOnMergeProposal.launchpadutils.get_template_args') |
1154 | 145 | @patch('jlp.commands.voteOnMergeProposal.get_jinja_environment') | 147 | @patch('jlp.commands.voteOnMergeProposal.get_jinja_environment') |
1157 | 146 | def test_no_commit_message_set(self, gje, gta, icms, | 148 | def test_no_commit_message_set(self, gje, gta, icms, rtl, gmphandle): |
1156 | 147 | rtl, gmphandle, sys_argv): | ||
1158 | 148 | """Vote on a proposal where tests passed but no commit message | 149 | """Vote on a proposal where tests passed but no commit message |
1159 | 149 | was set.""" | 150 | was set.""" |
1160 | 150 | 151 | ||
1161 | @@ -167,6 +168,7 @@ class TestVoteOnMergeProposal(unittest.TestCase): | |||
1162 | 167 | } | 168 | } |
1163 | 168 | icms.return_value = False | 169 | icms.return_value = False |
1164 | 169 | 170 | ||
1166 | 170 | ret = voteOnMergeProposal() | 171 | with patch('sys.argv', sys_argv): |
1167 | 172 | ret = voteOnMergeProposal() | ||
1168 | 171 | self.assertEqual(ret, 0) | 173 | self.assertEqual(ret, 0) |
1170 | 172 | gje.get_template.assert_called_with('no_commit.j2') | 174 | gje.return_value.get_template.assert_called_with('no_commit.j2') |
1171 | diff --git a/tests/util.py b/tests/util.py | |||
1172 | index 4ba80fb..b9bd5c9 100644 | |||
1173 | --- a/tests/util.py | |||
1174 | +++ b/tests/util.py | |||
1175 | @@ -1,5 +1,5 @@ | |||
1176 | 1 | import sys | 1 | import sys |
1178 | 2 | from StringIO import StringIO | 2 | from io import StringIO |
1179 | 3 | import contextlib | 3 | import contextlib |
1180 | 4 | 4 | ||
1181 | 5 | 5 | ||
1182 | diff --git a/voteOnMergeProposal.py b/voteOnMergeProposal.py | |||
1183 | 6 | deleted file mode 120000 | 6 | deleted file mode 120000 |
1184 | index ebf0657..0000000 | |||
1185 | --- a/voteOnMergeProposal.py | |||
1186 | +++ /dev/null | |||
1187 | @@ -1 +0,0 @@ | |||
1188 | 1 | scripts/voteOnMergeProposal | ||
1189 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
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.