Mercurial > p > roundup > code
annotate test/test_indexer.py @ 2077:3e0961d6d44d
Added the "actor" property.
Metakit backend not done (still not confident I know how it's supposed
to work ;)
Currently it will come up as NULL in the RDBMS backends for older items.
The *dbm backends will look up the journal. I hope to remedy the former
before 0.7's release.
Fixed a bunch of migration issues in the rdbms backends while I was at it
(index changes for key prop changes) and simplified the class table update
code for RDBMSes that have "alter table" in their command set (ie. not
sqlite) ... migration from "version 1" to "version 2" still hasn't
actually been tested yet though.
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Mon, 15 Mar 2004 05:50:20 +0000 |
| parents | f63aa57386b0 |
| children | 93f03c6714d8 |
| rev | line source |
|---|---|
|
848
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
1 # Copyright (c) 2002 ekit.com Inc (http://www.ekit-inc.com/) |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
2 # |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
3 # Permission is hereby granted, free of charge, to any person obtaining a copy |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
4 # of this software and associated documentation files (the "Software"), to deal |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
5 # in the Software without restriction, including without limitation the rights |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
7 # copies of the Software, and to permit persons to whom the Software is |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
8 # furnished to do so, subject to the following conditions: |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
9 # |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
10 # The above copyright notice and this permission notice shall be included in |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
11 # all copies or substantial portions of the Software. |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
12 # |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
19 # SOFTWARE. |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
20 |
|
1873
f63aa57386b0
Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
1090
diff
changeset
|
21 # $Id: test_indexer.py,v 1.3 2003-10-25 22:53:26 richard Exp $ |
|
848
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
22 |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
23 import os, unittest, shutil |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
24 |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
25 from roundup.indexer import Indexer |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
26 |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
27 class IndexerTest(unittest.TestCase): |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
28 def setUp(self): |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
29 if os.path.exists('test-index'): |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
30 shutil.rmtree('test-index') |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
31 os.mkdir('test-index') |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
32 os.mkdir('test-index/files') |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
33 self.dex = Indexer('test-index') |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
34 self.dex.load_index() |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
35 |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
36 def test_basics(self): |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
37 self.dex.add_text('testing1', 'a the hello world') |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
38 self.assertEqual(self.dex.words, {'HELLO': {1: 1}, 'THE': {1: 1}, |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
39 'WORLD': {1: 1}}) |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
40 self.dex.add_text('testing2', 'blah blah the world') |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
41 self.assertEqual(self.dex.words, {'BLAH': {2: 2}, 'HELLO': {1: 1}, |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
42 'THE': {2: 1, 1: 1}, 'WORLD': {2: 1, 1: 1}}) |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
43 self.assertEqual(self.dex.find(['world']), {2: 'testing2', |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
44 1: 'testing1'}) |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
45 self.assertEqual(self.dex.find(['blah']), {2: 'testing2'}) |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
46 self.assertEqual(self.dex.find(['blah', 'hello']), {}) |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
47 self.dex.save_index() |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
48 |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
49 def tearDown(self): |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
50 shutil.rmtree('test-index') |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
51 |
|
1873
f63aa57386b0
Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
1090
diff
changeset
|
52 def test_suite(): |
|
f63aa57386b0
Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
1090
diff
changeset
|
53 suite = unittest.TestSuite() |
|
f63aa57386b0
Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
1090
diff
changeset
|
54 suite.addTest(unittest.makeSuite(IndexerTest)) |
|
f63aa57386b0
Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
1090
diff
changeset
|
55 return suite |
|
848
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
56 |
|
1873
f63aa57386b0
Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
1090
diff
changeset
|
57 if __name__ == '__main__': |
|
f63aa57386b0
Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
1090
diff
changeset
|
58 runner = unittest.TextTestRunner() |
|
f63aa57386b0
Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
1090
diff
changeset
|
59 unittest.main(testRunner=runner) |
|
848
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
60 |
|
2a928d404af8
ehem, forgot to add
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
61 # vim: set filetype=python ts=4 sw=4 et si |
