Rev 2438: HelpContexts.search now invokes get_topics on each context. in file:///home/robertc/source/baz/help-contexts/
Robert Collins
robertc at robertcollins.net
Fri Apr 20 01:30:42 BST 2007
At file:///home/robertc/source/baz/help-contexts/
------------------------------------------------------------
revno: 2438
revision-id: robertc at robertcollins.net-20070420003040-6410f4x7k68hsx87
parent: robertc at robertcollins.net-20070420001830-lrxkvu3fkd1d7bnn
committer: Robert Collins <robertc at robertcollins.net>
branch nick: help-contexts
timestamp: Fri 2007-04-20 10:30:40 +1000
message:
HelpContexts.search now invokes get_topics on each context.
modified:
bzrlib/help.py help.py-20050505025907-4dd7a6d63912f894
bzrlib/tests/test_help.py test_help.py-20070419045354-6q6rq15j9e2n5fna-1
=== modified file 'bzrlib/help.py'
--- a/bzrlib/help.py 2007-04-20 00:18:30 +0000
+++ b/bzrlib/help.py 2007-04-20 00:30:40 +0000
@@ -197,4 +197,8 @@
:param topic: A string naming the help topic to search for.
:raises: NoHelpTopic if none of the contexts in search_path have topic.
"""
- raise errors.NoHelpTopic(topic)
+ result = []
+ for context in self.search_path:
+ result.extend(context.get_topics(topic))
+ if not result:
+ raise errors.NoHelpTopic(topic)
=== modified file 'bzrlib/tests/test_help.py'
--- a/bzrlib/tests/test_help.py 2007-04-20 00:18:30 +0000
+++ b/bzrlib/tests/test_help.py 2007-04-20 00:30:40 +0000
@@ -78,3 +78,30 @@
contexts.search_path = []
error = self.assertRaises(errors.NoHelpTopic, contexts.search, 'foo')
self.assertEqual('foo', error.topic)
+
+ def test_search_calls_get_topic(self):
+ """Searching should call get_topics in all indexes in order."""
+ calls = []
+ class RecordingContext(object):
+ def __init__(self, name):
+ self.name = name
+ def get_topics(self, topic):
+ calls.append(('get_topics', self.name, topic))
+ return ['something']
+ contexts = help.HelpContexts()
+ contexts.search_path = [RecordingContext('1'), RecordingContext('2')]
+ # try with None
+ contexts.search(None)
+ self.assertEqual([
+ ('get_topics', '1', None),
+ ('get_topics', '2', None),
+ ],
+ calls)
+ # and with a string
+ del calls[:]
+ contexts.search('bar')
+ self.assertEqual([
+ ('get_topics', '1', 'bar'),
+ ('get_topics', '2', 'bar'),
+ ],
+ calls)
More information about the bazaar-commits
mailing list