Mercurial > p > roundup > code
comparison test/test_indexer.py @ 848:2a928d404af8
ehem, forgot to add
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 10 Jul 2002 06:40:01 +0000 |
| parents | |
| children | 9b910e8d987d |
comparison
equal
deleted
inserted
replaced
| 847:0f0f6049c9a7 | 848:2a928d404af8 |
|---|---|
| 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 |
