122
122
self.assertEqual([], index.get_topics('nothing by this name'))
125
class TestHelpIndexs(tests.TestCase):
126
"""Tests for the HelpIndexs class."""
125
class TestHelpIndices(tests.TestCase):
126
"""Tests for the HelpIndices class."""
128
128
def test_default_search_path(self):
129
129
"""The default search path should include internal indexs."""
130
indexs = help.HelpIndexs()
131
self.assertEqual(2, len(indexs.search_path))
130
indices = help.HelpIndices()
131
self.assertEqual(2, len(indices.search_path))
132
132
# help topics should be searched in first.
133
self.assertIsInstance(indexs.search_path[0],
133
self.assertIsInstance(indices.search_path[0],
134
134
help_topics.HelpTopicIndex)
135
135
# with commands being search second.
136
self.assertIsInstance(indexs.search_path[1],
136
self.assertIsInstance(indices.search_path[1],
137
137
commands.HelpCommandIndex)
139
139
def test_search_for_unknown_topic_raises(self):
140
140
"""Searching for an unknown topic should raise NoHelpTopic."""
141
indexs = help.HelpIndexs()
142
indexs.search_path = []
143
error = self.assertRaises(errors.NoHelpTopic, indexs.search, 'foo')
141
indices = help.HelpIndices()
142
indices.search_path = []
143
error = self.assertRaises(errors.NoHelpTopic, indices.search, 'foo')
144
144
self.assertEqual('foo', error.topic)
146
146
def test_search_calls_get_topic(self):
152
152
def get_topics(self, topic):
153
153
calls.append(('get_topics', self.name, topic))
154
154
return ['something']
155
index = help.HelpIndexs()
155
index = help.HelpIndices()
156
156
index.search_path = [RecordingIndex('1'), RecordingIndex('2')]
158
158
index.search(None)
177
177
self.result = search_result
178
178
def get_topics(self, topic):
179
179
return self.result
180
index = help.HelpIndexs()
180
index = help.HelpIndices()
181
181
index.search_path = [CannedIndex(['a']), CannedIndex(['b', 'c'])]
182
182
self.assertEqual(['a', 'b', 'c'], index.search(None))