Skip to content

Commit 3fa8a2b

Browse files
author
Richard Jones
committed
ehem, forgot to add
1 parent 2284ebd commit 3fa8a2b

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

test/test_indexer.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Copyright (c) 2002 ekit.com Inc (http://www.ekit-inc.com/)
2+
#
3+
# Permission is hereby granted, free of charge, to any person obtaining a copy
4+
# of this software and associated documentation files (the "Software"), to deal
5+
# in the Software without restriction, including without limitation the rights
6+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
# copies of the Software, and to permit persons to whom the Software is
8+
# furnished to do so, subject to the following conditions:
9+
#
10+
# The above copyright notice and this permission notice shall be included in
11+
# all copies or substantial portions of the Software.
12+
#
13+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
# SOFTWARE.
20+
21+
# $Id: test_indexer.py,v 1.1 2002-07-10 06:40:01 richard Exp $
22+
23+
import os, unittest, shutil
24+
25+
from roundup.indexer import Indexer
26+
27+
class IndexerTest(unittest.TestCase):
28+
def setUp(self):
29+
if os.path.exists('test-index'):
30+
shutil.rmtree('test-index')
31+
os.mkdir('test-index')
32+
os.mkdir('test-index/files')
33+
self.dex = Indexer('test-index')
34+
self.dex.load_index()
35+
36+
def test_basics(self):
37+
self.dex.add_text('testing1', 'a the hello world')
38+
self.assertEqual(self.dex.words, {'HELLO': {1: 1}, 'THE': {1: 1},
39+
'WORLD': {1: 1}})
40+
self.dex.add_text('testing2', 'blah blah the world')
41+
self.assertEqual(self.dex.words, {'BLAH': {2: 2}, 'HELLO': {1: 1},
42+
'THE': {2: 1, 1: 1}, 'WORLD': {2: 1, 1: 1}})
43+
self.assertEqual(self.dex.find(['world']), {2: 'testing2',
44+
1: 'testing1'})
45+
self.assertEqual(self.dex.find(['blah']), {2: 'testing2'})
46+
self.assertEqual(self.dex.find(['blah', 'hello']), {})
47+
self.dex.save_index()
48+
49+
def tearDown(self):
50+
shutil.rmtree('test-index')
51+
52+
def suite():
53+
return unittest.makeSuite(IndexerTest)
54+
55+
56+
#
57+
# $Log: not supported by cvs2svn $
58+
#
59+
#
60+
# vim: set filetype=python ts=4 sw=4 et si

0 commit comments

Comments
 (0)