bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.191.1
by Robert Collins
Created plugin, basic functionality of looking for NEWS and including the |
1 |
# Copyright (C) 2010 Canonical Ltd
|
2 |
#
|
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
16 |
||
17 |
"""Tests for the commit template creation."""
|
|
18 |
||
|
6690.6.1
by Jelmer Vernooij
Bundle the commitfromnews plugin. |
19 |
from ... import commitfromnews |
|
6739
by Jelmer Vernooij
Merge lp:~jelmer/brz/bundle-commitfromnews. |
20 |
from .... import ( |
21 |
config, |
|
22 |
msgeditor, |
|
23 |
)
|
|
|
6690.6.1
by Jelmer Vernooij
Bundle the commitfromnews plugin. |
24 |
from ....tests import TestCaseWithTransport |
|
0.191.1
by Robert Collins
Created plugin, basic functionality of looking for NEWS and including the |
25 |
|
|
7027.8.1
by Jelmer Vernooij
Fix commitfromnews tests on python3. |
26 |
INITIAL_NEWS_CONTENT = b"""---------------------------- |
|
0.192.1
by Jelmer Vernooij
tests: Put initial content in a variable. |
27 |
commitfromnews release notes
|
28 |
----------------------------
|
|
29 |
||
30 |
NEXT (In development)
|
|
31 |
---------------------
|
|
32 |
||
33 |
IMPROVEMENTS
|
|
34 |
~~~~~~~~~~~~
|
|
35 |
||
36 |
* Created plugin, basic functionality of looking for NEWS and including the
|
|
37 |
NEWS diff.
|
|
38 |
"""
|
|
39 |
||
40 |
||
|
0.191.1
by Robert Collins
Created plugin, basic functionality of looking for NEWS and including the |
41 |
class TestCommitTemplate(TestCaseWithTransport): |
42 |
||
43 |
def capture_template(self, commit, message): |
|
|
0.192.2
by Jelmer Vernooij
Initial work on extract bug numbers from NEWS. |
44 |
self.commits.append(commit) |
|
0.191.1
by Robert Collins
Created plugin, basic functionality of looking for NEWS and including the |
45 |
self.messages.append(message) |
46 |
if message is None: |
|
|
7027.8.1
by Jelmer Vernooij
Fix commitfromnews tests on python3. |
47 |
message = u'let this commit succeed I command thee.' |
|
0.191.1
by Robert Collins
Created plugin, basic functionality of looking for NEWS and including the |
48 |
return message |
49 |
||
|
6739
by Jelmer Vernooij
Merge lp:~jelmer/brz/bundle-commitfromnews. |
50 |
def enable_commitfromnews(self): |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
51 |
stack = config.GlobalStack() |
|
6739
by Jelmer Vernooij
Merge lp:~jelmer/brz/bundle-commitfromnews. |
52 |
stack.set("commit.template_from_files", ["NEWS"]) |
53 |
||
|
0.191.1
by Robert Collins
Created plugin, basic functionality of looking for NEWS and including the |
54 |
def setup_capture(self): |
55 |
commitfromnews.register() |
|
56 |
msgeditor.hooks.install_named_hook('commit_message_template', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
57 |
self.capture_template, 'commitfromnews test template') |
|
0.191.1
by Robert Collins
Created plugin, basic functionality of looking for NEWS and including the |
58 |
self.messages = [] |
|
0.192.2
by Jelmer Vernooij
Initial work on extract bug numbers from NEWS. |
59 |
self.commits = [] |
|
0.191.1
by Robert Collins
Created plugin, basic functionality of looking for NEWS and including the |
60 |
|
61 |
def test_initial(self): |
|
62 |
self.setup_capture() |
|
|
6739
by Jelmer Vernooij
Merge lp:~jelmer/brz/bundle-commitfromnews. |
63 |
self.enable_commitfromnews() |
|
0.191.1
by Robert Collins
Created plugin, basic functionality of looking for NEWS and including the |
64 |
builder = self.make_branch_builder('test') |
65 |
builder.start_series() |
|
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
66 |
builder.build_snapshot(None, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
67 |
[('add', ('', None, 'directory', None)), |
68 |
('add', ('foo', b'foo-id', 'file', b'a\nb\nc\nd\ne\n')), |
|
69 |
],
|
|
70 |
message_callback=msgeditor.generate_commit_message_template, |
|
71 |
revision_id=b'BASE-id') |
|
|
0.191.1
by Robert Collins
Created plugin, basic functionality of looking for NEWS and including the |
72 |
builder.finish_series() |
73 |
self.assertEqual([None], self.messages) |
|
74 |
||
75 |
def test_added_NEWS(self): |
|
76 |
self.setup_capture() |
|
|
6739
by Jelmer Vernooij
Merge lp:~jelmer/brz/bundle-commitfromnews. |
77 |
self.enable_commitfromnews() |
|
0.191.1
by Robert Collins
Created plugin, basic functionality of looking for NEWS and including the |
78 |
builder = self.make_branch_builder('test') |
79 |
builder.start_series() |
|
|
0.192.1
by Jelmer Vernooij
tests: Put initial content in a variable. |
80 |
content = INITIAL_NEWS_CONTENT |
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
81 |
builder.build_snapshot(None, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
82 |
[('add', ('', None, 'directory', None)), |
83 |
('add', ('NEWS', b'foo-id', 'file', content)), |
|
84 |
],
|
|
85 |
message_callback=msgeditor.generate_commit_message_template, |
|
86 |
revision_id=b'BASE-id') |
|
|
0.191.1
by Robert Collins
Created plugin, basic functionality of looking for NEWS and including the |
87 |
builder.finish_series() |
|
7027.8.1
by Jelmer Vernooij
Fix commitfromnews tests on python3. |
88 |
self.assertEqual([content.decode('utf-8')], self.messages) |
|
0.191.1
by Robert Collins
Created plugin, basic functionality of looking for NEWS and including the |
89 |
|
90 |
def test_changed_NEWS(self): |
|
91 |
self.setup_capture() |
|
|
6739
by Jelmer Vernooij
Merge lp:~jelmer/brz/bundle-commitfromnews. |
92 |
self.enable_commitfromnews() |
|
0.191.1
by Robert Collins
Created plugin, basic functionality of looking for NEWS and including the |
93 |
builder = self.make_branch_builder('test') |
94 |
builder.start_series() |
|
|
0.192.1
by Jelmer Vernooij
tests: Put initial content in a variable. |
95 |
orig_content = INITIAL_NEWS_CONTENT |
|
6883.22.11
by Jelmer Vernooij
merge trunk |
96 |
mod_content = b"""---------------------------- |
|
0.191.1
by Robert Collins
Created plugin, basic functionality of looking for NEWS and including the |
97 |
commitfromnews release notes
|
98 |
----------------------------
|
|
99 |
||
100 |
NEXT (In development)
|
|
101 |
---------------------
|
|
102 |
||
103 |
IMPROVEMENTS
|
|
104 |
~~~~~~~~~~~~
|
|
105 |
||
106 |
* Added a new change to the system.
|
|
107 |
||
108 |
* Created plugin, basic functionality of looking for NEWS and including the
|
|
109 |
NEWS diff.
|
|
110 |
"""
|
|
111 |
change_content = """* Added a new change to the system. |
|
112 |
||
113 |
"""
|
|
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
114 |
builder.build_snapshot(None, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
115 |
[('add', ('', None, 'directory', None)), |
116 |
('add', ('NEWS', b'foo-id', 'file', orig_content)), |
|
117 |
], revision_id=b'BASE-id') |
|
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
118 |
builder.build_snapshot(None, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
119 |
[('modify', ('NEWS', mod_content)), |
120 |
],
|
|
121 |
message_callback=msgeditor.generate_commit_message_template) |
|
|
0.191.1
by Robert Collins
Created plugin, basic functionality of looking for NEWS and including the |
122 |
builder.finish_series() |
123 |
self.assertEqual([change_content], self.messages) |
|
124 |
||
|
0.192.2
by Jelmer Vernooij
Initial work on extract bug numbers from NEWS. |
125 |
def test_fix_bug(self): |
126 |
self.setup_capture() |
|
|
6739
by Jelmer Vernooij
Merge lp:~jelmer/brz/bundle-commitfromnews. |
127 |
self.enable_commitfromnews() |
|
0.192.2
by Jelmer Vernooij
Initial work on extract bug numbers from NEWS. |
128 |
builder = self.make_branch_builder('test') |
129 |
builder.start_series() |
|
130 |
orig_content = INITIAL_NEWS_CONTENT |
|
|
6883.22.11
by Jelmer Vernooij
merge trunk |
131 |
mod_content = b"""---------------------------- |
|
0.192.2
by Jelmer Vernooij
Initial work on extract bug numbers from NEWS. |
132 |
commitfromnews release notes
|
133 |
----------------------------
|
|
134 |
||
135 |
NEXT (In development)
|
|
136 |
---------------------
|
|
137 |
||
138 |
IMPROVEMENTS
|
|
139 |
~~~~~~~~~~~~
|
|
140 |
||
141 |
* Created plugin, basic functionality of looking for NEWS and including the
|
|
142 |
NEWS diff.
|
|
143 |
||
|
0.192.3
by Jelmer Vernooij
Match on lp:BUGNO rather than #BUGNO |
144 |
* Fixed a horrible bug. (lp:523423)
|
|
0.192.2
by Jelmer Vernooij
Initial work on extract bug numbers from NEWS. |
145 |
|
146 |
"""
|
|
147 |
change_content = """ |
|
|
0.192.3
by Jelmer Vernooij
Match on lp:BUGNO rather than #BUGNO |
148 |
* Fixed a horrible bug. (lp:523423)
|
|
0.192.2
by Jelmer Vernooij
Initial work on extract bug numbers from NEWS. |
149 |
|
150 |
"""
|
|
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
151 |
builder.build_snapshot(None, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
152 |
[('add', ('', None, 'directory', None)), |
153 |
('add', ('NEWS', b'foo-id', 'file', orig_content)), |
|
154 |
], revision_id=b'BASE-id') |
|
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
155 |
builder.build_snapshot(None, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
156 |
[('modify', ('NEWS', mod_content)), |
157 |
],
|
|
158 |
message_callback=msgeditor.generate_commit_message_template) |
|
|
0.192.2
by Jelmer Vernooij
Initial work on extract bug numbers from NEWS. |
159 |
builder.finish_series() |
160 |
self.assertEqual([change_content], self.messages) |
|
161 |
self.assertEqual(1, len(self.commits)) |
|
162 |
self.assertEquals('https://launchpad.net/bugs/523423 fixed', |
|
163 |
self.commits[0].revprops['bugs']) |
|
164 |
||
|
0.191.1
by Robert Collins
Created plugin, basic functionality of looking for NEWS and including the |
165 |
def _todo_test_passes_messages_through(self): |
166 |
pass
|