253
253
def test_get_topics_launchpad(self):
254
254
"""Searching for 'launchpad' returns the launchpad plugin docstring."""
255
255
index = plugin.PluginsHelpIndex()
256
# if bzr was run with '--no-plugins' we need to manually load the
257
# reference plugin. Its shipped with bzr, and loading at this point
258
# won't add additional tests to run.
259
import bzrlib.plugins.launchpad
260
topics = index.get_topics('launchpad')
261
self.assertEqual(1, len(topics))
262
self.assertIsInstance(topics[0], plugin.ModuleHelpTopic)
263
self.assertEqual(bzrlib.plugins.launchpad, topics[0].module)
256
self.assertFalse(sys.modules.has_key('bzrlib.plugins.get_topics'))
257
demo_module = FakeModule('', 'bzrlib.plugins.get_topics')
258
sys.modules['bzrlib.plugins.get_topics'] = demo_module
260
topics = index.get_topics('get_topics')
261
self.assertEqual(1, len(topics))
262
self.assertIsInstance(topics[0], plugin.ModuleHelpTopic)
263
self.assertEqual(demo_module, topics[0].module)
265
del sys.modules['bzrlib.plugins.get_topics']
265
267
def test_get_topics_no_topic(self):
266
268
"""Searching for something that is not a plugin returns []."""
277
279
def test_get_topic_with_prefix(self):
278
280
"""Searching for plugins/launchpad returns launchpad module help."""
279
281
index = plugin.PluginsHelpIndex()
280
# if bzr was run with '--no-plugins' we need to manually load the
281
# reference plugin. Its shipped with bzr, and loading at this point
282
# won't add additional tests to run.
283
import bzrlib.plugins.launchpad
284
topics = index.get_topics('plugins/launchpad')
285
self.assertEqual(1, len(topics))
286
self.assertIsInstance(topics[0], plugin.ModuleHelpTopic)
287
self.assertEqual(bzrlib.plugins.launchpad, topics[0].module)
282
self.assertFalse(sys.modules.has_key('bzrlib.plugins.get_topics'))
283
demo_module = FakeModule('', 'bzrlib.plugins.get_topics')
284
sys.modules['bzrlib.plugins.get_topics'] = demo_module
286
topics = index.get_topics('plugins/get_topics')
287
self.assertEqual(1, len(topics))
288
self.assertIsInstance(topics[0], plugin.ModuleHelpTopic)
289
self.assertEqual(demo_module, topics[0].module)
291
del sys.modules['bzrlib.plugins.get_topics']
290
294
class FakeModule(object):