OLD | NEW |
1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, |
2 # Copyright (C) 2006-present eyeo GmbH | 2 # Copyright (C) 2006-present eyeo GmbH |
3 # | 3 # |
4 # Adblock Plus is free software: you can redistribute it and/or modify | 4 # Adblock Plus is free software: you can redistribute it and/or modify |
5 # it under the terms of the GNU General Public License version 3 as | 5 # it under the terms of the GNU General Public License version 3 as |
6 # published by the Free Software Foundation. | 6 # published by the Free Software Foundation. |
7 # | 7 # |
8 # Adblock Plus is distributed in the hope that it will be useful, | 8 # Adblock Plus is distributed in the hope that it will be useful, |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 # GNU General Public License for more details. | 11 # GNU General Public License for more details. |
12 # | 12 # |
13 # You should have received a copy of the GNU General Public License | 13 # You should have received a copy of the GNU General Public License |
14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
15 | 15 |
16 import ConfigParser | 16 import ConfigParser |
17 import mock | 17 import mock |
18 import unittest | 18 import unittest |
19 | 19 |
20 import sitescripts.hg.bin.update_issues as update_issues | 20 import sitescripts.hg.bin.update_issues as update_issues |
21 | 21 |
22 | 22 |
23 def _issue(component, milestone='', can_resolve=False): | 23 def _issue(component, milestone='', can_resolve=False): |
24 issue = { | 24 issue = { |
25 'attrs': {'_ts': 1, 'milestone': milestone, 'component': component}, | 25 'attrs': {'_ts': 1, 'milestone': milestone, 'component': component}, |
26 'actions': [['leave', '', '', []]] | 26 'actions': [['leave', '', '', []]], |
27 } | 27 } |
28 if can_resolve: | 28 if can_resolve: |
29 issue['actions'].append(['resolve', '', '', []]) | 29 issue['actions'].append(['resolve', '', '', []]) |
30 return issue | 30 return issue |
31 | 31 |
32 | 32 |
33 ISSUES = { | 33 ISSUES = { |
34 1337: _issue(component='one', can_resolve=True), | 34 1337: _issue(component='one', can_resolve=True), |
35 2448: _issue(component='two'), | 35 2448: _issue(component='two'), |
36 3559: _issue(component='one', milestone='other'), | 36 3559: _issue(component='one', milestone='other'), |
37 4670: _issue(component='three', can_resolve=True), | 37 4670: _issue(component='three', can_resolve=True), |
38 5781: _issue(component='four', can_resolve=True) | 38 5781: _issue(component='four', can_resolve=True), |
39 } | 39 } |
40 | 40 |
41 MILESTONES = { | 41 MILESTONES = { |
42 'completed': {'completed': True, 'name': 'completed'}, | 42 'completed': {'completed': True, 'name': 'completed'}, |
43 'current': {'completed': None, 'name': 'current'}, | 43 'current': {'completed': None, 'name': 'current'}, |
44 'other': {'completed': None, 'name': 'other'} | 44 'other': {'completed': None, 'name': 'other'}, |
45 } | 45 } |
46 | 46 |
47 | 47 |
48 class _TestBase(unittest.TestCase): | 48 class _TestBase(unittest.TestCase): |
49 """Base class for hook tests that prepares the environment.""" | 49 """Base class for hook tests that prepares the environment.""" |
50 | 50 |
51 def _patchWith(self, target, return_value): | 51 def _patchWith(self, target, return_value): |
52 patcher = mock.patch(target, return_value=return_value) | 52 patcher = mock.patch(target, return_value=return_value) |
53 patcher.start() | 53 patcher.start() |
54 self.addCleanup(patcher.stop) | 54 self.addCleanup(patcher.stop) |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 return updates | 122 return updates |
123 | 123 |
124 def test_commits_with_invalid_message_format_ignored(self): | 124 def test_commits_with_invalid_message_format_ignored(self): |
125 self._run_hook([ | 125 self._run_hook([ |
126 '', | 126 '', |
127 'Issue #1337 - Extraneous characters in issue number', | 127 'Issue #1337 - Extraneous characters in issue number', |
128 'Issue 1337', # No dash, no message. | 128 'Issue 1337', # No dash, no message. |
129 'Issue 1337: Colon instead of dash', | 129 'Issue 1337: Colon instead of dash', |
130 'Noissue no dash', | 130 'Noissue no dash', |
131 'Issue 1337-No space around dash', | 131 'Issue 1337-No space around dash', |
132 'Fixes 1337 no dash' | 132 'Fixes 1337 no dash', |
133 ], warning_count=7) | 133 ], warning_count=7) |
134 | 134 |
135 def test_noissue_commits_ignored(self): | 135 def test_noissue_commits_ignored(self): |
136 self._run_hook(['Noissue - Foo', 'noissue - Bar']) # No updates. | 136 self._run_hook(['Noissue - Foo', 'noissue - Bar']) # No updates. |
137 | 137 |
138 def test_single_issue_referenced(self): | 138 def test_single_issue_referenced(self): |
139 updates = self._run_hook(['Issue 1337 - Foo'], update_count=1) | 139 updates = self._run_hook(['Issue 1337 - Foo'], update_count=1) |
140 self.assertEqual(updates[0][0][0], 1337) | 140 self.assertEqual(updates[0][0][0], 1337) |
141 | 141 |
142 def test_multiline_commit_message(self): | 142 def test_multiline_commit_message(self): |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 233 |
234 def test_fix_nonexistent(self): | 234 def test_fix_nonexistent(self): |
235 self._run_hook(['Fixes 7331 - Foo'], warning_count=1) | 235 self._run_hook(['Fixes 7331 - Foo'], warning_count=1) |
236 | 236 |
237 def test_fix_closed_with_assigned_milestone(self): | 237 def test_fix_closed_with_assigned_milestone(self): |
238 self._run_hook(['fixes 3559 - Foo']) # No updates. | 238 self._run_hook(['fixes 3559 - Foo']) # No updates. |
239 | 239 |
240 | 240 |
241 if __name__ == '__main__': | 241 if __name__ == '__main__': |
242 unittest.main() | 242 unittest.main() |
OLD | NEW |