~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_plugins.py

  • Committer: Aaron Bentley
  • Date: 2007-05-14 17:21:02 UTC
  • mfrom: (2485 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2528.
  • Revision ID: aaron.bentley@utoronto.ca-20070514172102-byyl4ldjxhfxvryy
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 Canonical Ltd
 
1
# Copyright (C) 2005, 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
250
250
        index = plugin.PluginsHelpIndex()
251
251
        self.assertEqual([], index.get_topics(None))
252
252
 
253
 
    def test_get_topics_launchpad(self):
254
 
        """Searching for 'launchpad' returns the launchpad plugin docstring."""
 
253
    def test_get_topics_for_plugin(self):
 
254
        """Searching for plugin name gets its docstring."""
255
255
        index = plugin.PluginsHelpIndex()
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
 
256
        # make a new plugin here for this test, even if we're run with
 
257
        # --no-plugins
 
258
        self.assertFalse(sys.modules.has_key('bzrlib.plugins.demo_module'))
 
259
        demo_module = FakeModule('', 'bzrlib.plugins.demo_module')
 
260
        sys.modules['bzrlib.plugins.demo_module'] = demo_module
259
261
        try:
260
 
            topics = index.get_topics('get_topics')
 
262
            topics = index.get_topics('demo_module')
261
263
            self.assertEqual(1, len(topics))
262
264
            self.assertIsInstance(topics[0], plugin.ModuleHelpTopic)
263
265
            self.assertEqual(demo_module, topics[0].module)
264
266
        finally:
265
 
            del sys.modules['bzrlib.plugins.get_topics']
 
267
            del sys.modules['bzrlib.plugins.demo_module']
266
268
 
267
269
    def test_get_topics_no_topic(self):
268
270
        """Searching for something that is not a plugin returns []."""
276
278
        index = plugin.PluginsHelpIndex()
277
279
        self.assertEqual('plugins/', index.prefix)
278
280
 
279
 
    def test_get_topic_with_prefix(self):
280
 
        """Searching for plugins/launchpad returns launchpad module help."""
 
281
    def test_get_plugin_topic_with_prefix(self):
 
282
        """Searching for plugins/demo_module returns help."""
281
283
        index = plugin.PluginsHelpIndex()
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
 
284
        self.assertFalse(sys.modules.has_key('bzrlib.plugins.demo_module'))
 
285
        demo_module = FakeModule('', 'bzrlib.plugins.demo_module')
 
286
        sys.modules['bzrlib.plugins.demo_module'] = demo_module
285
287
        try:
286
 
            topics = index.get_topics('plugins/get_topics')
 
288
            topics = index.get_topics('plugins/demo_module')
287
289
            self.assertEqual(1, len(topics))
288
290
            self.assertIsInstance(topics[0], plugin.ModuleHelpTopic)
289
291
            self.assertEqual(demo_module, topics[0].module)
290
292
        finally:
291
 
            del sys.modules['bzrlib.plugins.get_topics']
 
293
            del sys.modules['bzrlib.plugins.demo_module']
292
294
 
293
295
 
294
296
class FakeModule(object):