201
202
wt.branch.tags.set_tag('3tag', 'null:')
202
203
self.complete(['bzr', 'log', '-r', 'tag', ':', 't'],
203
204
expect=['tag1', 'tag2'])
207
class TestBashCodeGen(TestCase):
209
def test_command_names(self):
210
data = CompletionData()
211
bar = CommandData('bar')
212
bar.aliases.append('baz')
213
data.commands.append(bar)
214
data.commands.append(CommandData('foo'))
215
cg = BashCodeGen(data)
216
self.assertEqual('bar baz foo', cg.command_names())
218
def test_debug_output(self):
219
data = CompletionData()
220
self.assertEqual('', BashCodeGen(data, debug=False).debug_output())
221
self.assertTrue(BashCodeGen(data, debug=True).debug_output())
223
def test_bzr_version(self):
224
data = CompletionData()
225
cg = BashCodeGen(data)
226
self.assertEqual('%s.' % bzrlib.version_string, cg.bzr_version())
227
data.plugins['foo'] = PluginData('foo', '1.0')
228
data.plugins['bar'] = PluginData('bar', '2.0')
229
cg = BashCodeGen(data)
230
self.assertEqual('''\
231
%s and the following plugins:
233
# foo 1.0''' % bzrlib.version_string, cg.bzr_version())
235
def test_global_options(self):
236
data = CompletionData()
237
data.global_options.add('--foo')
238
data.global_options.add('--bar')
239
cg = BashCodeGen(data)
240
self.assertEqual('--bar --foo', cg.global_options())
242
def test_command_cases(self):
243
data = CompletionData()
244
bar = CommandData('bar')
245
bar.aliases.append('baz')
246
bar.options.append(OptionData('--opt'))
247
data.commands.append(bar)
248
data.commands.append(CommandData('foo'))
249
cg = BashCodeGen(data)
250
self.assertEqualDiff('''\
257
''', cg.command_cases())
259
def test_command_case(self):
260
cmd = CommandData('cmd')
261
cmd.plugin = PluginData('plugger', '1.0')
262
bar = OptionData('--bar')
263
bar.registry_keys = ['that', 'this']
264
bar.error_messages.append('Some error message')
265
cmd.options.append(bar)
266
cmd.options.append(OptionData('--foo'))
267
data = CompletionData()
268
data.commands.append(cmd)
269
cg = BashCodeGen(data)
270
self.assertEqualDiff('''\
272
\t\t# plugin "plugger 1.0"
273
\t\t# Some error message
274
\t\tcmdOpts='--bar=that --bar=this --foo'
276
\t\t\t--bar) optEnums='that this' ;;
279
''', cg.command_case(cmd))
282
class TestDataCollector(TestCase):
285
super(TestDataCollector, self).setUp()
286
commands.install_bzr_command_hooks()
288
def test_global_options(self):
291
self.assertSubset(['--no-plugins', '--builtin'],
292
dc.data.global_options)
294
def test_commands(self):
297
self.assertSubset(['init', 'init-repo', 'init-repository'],
298
dc.data.all_command_aliases())
300
def test_commit_dashm(self):
302
cmd = dc.command('commit')
303
self.assertSubset(['-m'],
304
[str(o) for o in cmd.options])
306
def test_status_negated(self):
308
cmd = dc.command('status')
309
self.assertSubset(['--no-versioned', '--no-verbose'],
310
[str(o) for o in cmd.options])
312
def test_init_format(self):
314
cmd = dc.command('init')
315
for opt in cmd.options:
316
if opt.name == '--format':
317
self.assertSubset(['2a'], opt.registry_keys)
319
raise AssertionError('Option --format not found')