/[hyperestraier_wrappers]/0.0.13/test/python.py
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /0.0.13/test/python.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 14 - (hide annotations)
Fri Sep 9 15:26:39 2005 UTC (14 years, 5 months ago) by dpavlin
File MIME type: text/x-python
File size: 4991 byte(s)
import of 0.0.13
1 dpavlin 1 #!/usr/bin/env python
2    
3     import unittest
4    
5     import os
6    
7     from HyperEstraier import *
8    
9     class ConditionTest(unittest.TestCase):
10     def setUp(self):
11     self.cond = Condition()
12    
13     def testConstantVariables(self):
14     self.cond.CONDSURE
15     self.cond.CONDUSU
16     self.cond.CONDFAST
17     self.cond.CONDAGIT
18     self.cond.CONDNOIDF
19     self.cond.CONDSIMPLE
20    
21     def testSetPhrase(self):
22     self.cond.set_phrase("foo")
23    
24     def testAddAttr(self):
25     self.cond.add_attr('@uri ISTREW .txt')
26    
27     def testSetOrder(self):
28     self.cond.set_order('@id')
29    
30     def testSetMax(self):
31     self.cond.set_max(30)
32    
33     def testSetOptions(self):
34     self.cond.set_options(Condition.CONDSURE)
35    
36     class DocumentTest(unittest.TestCase):
37     def setUp(self):
38     self.doc = Document()
39    
40     def testAddAttr(self):
41     self.doc.add_attr('@uri', 'http://tokuhirom.dnsalias.org/')
42    
43     def testAddText(self):
44     self.doc.add_text('Hyper Estraier')
45     self.doc.add_text('QDBM')
46    
47     def testAddHiddenText(self):
48     self.doc.add_hidden_text('a full-text search system for communities')
49    
50     def testID(self):
51     self.doc.id()
52    
53     def testAttrNames(self):
54     self.doc.attr_names()
55    
56     def testAttr(self):
57     self.assertEqual(self.doc.attr('@foo'), None)
58     self.doc.add_attr('@foo', 'bar')
59     self.assertEqual(self.doc.attr('@foo'), 'bar')
60    
61     def testTexts(self):
62     self.assertEqual(list(self.doc.texts()), [])
63     self.doc.add_text('foo')
64     self.doc.add_text('bar')
65     self.assertEqual(list(self.doc.texts()), ['foo', 'bar'])
66    
67     """
68     def testCatTexts(self):
69     self.assertEqual(self.doc.cat_texts(), '')
70     self.doc.add_text('foo')
71     self.doc.add_text('bar')
72     self.assertEqual(self.doc.cat_texts(), 'foobar')
73     """
74    
75     def testDumpDraft(self):
76     self.doc.add_text('foo')
77     self.doc.add_text('bar')
78     self.assertEqual(self.doc.dump_draft(), "\nfoo\nbar\n")
79    
80     def testMakeSnippet(self):
81     self.doc.add_text('foo')
82     self.doc.add_text('bar')
83     self.doc.add_text('baz')
84     self.assertEqual(
85     self.doc.make_snippet(['foo', 'baz'], 30, 30, 20),
86     'foo\tfoo\n bar \nbaz\tbaz\n\n')
87    
88     def testScanWords(self):
89     self.doc.add_text('foo')
90     self.assertEqual(self.doc.scan_words('foo'), True)
91     self.assertEqual(self.doc.scan_words('bar'), False)
92    
93     class DatabaseStaticTest(unittest.TestCase):
94     def testConstantVariables(self):
95     Database.ERRNOERR
96     Database.ERRINVAL
97     Database.ERRACCES
98     Database.ERRLOCK
99     Database.ERRDB
100     Database.ERRIO
101     Database.ERRNOITEM
102     Database.ERRMISC
103     Database.DBREADER
104     Database.DBWRITER
105     Database.DBCREAT
106     Database.DBTRUNC
107     Database.DBNOLCK
108     Database.DBLCKNB
109     Database.DBPERFNG
110     Database.PDCLEAN
111     Database.ODCLEAN
112     Database.OPTNOPURGE
113     Database.OPTNODBOPT
114     Database.GDNOATTR
115     Database.GDNOTEXT
116    
117     def testErrMsg(self):
118     Database.err_msg(0)
119    
120     class DatabaseWriterTest(unittest.TestCase):
121     def setUp(self):
122     self.db = Database()
123     self.assertEqual(self.db.open('casket',
124     Database.DBWRITER | Database.DBCREAT),
125     True)
126     self.doc = Document()
127     self.doc.add_attr('@uri', 'http://www.example.com/')
128     self.doc.add_text('foo')
129     self.assertEqual(self.db.put_doc(self.doc, 0), True)
130    
131     def testError(self):
132     self.assertEqual(self.db.error(), Database.ERRNOERR)
133     self.db.close()
134    
135     def testFatal(self):
136     self.assertEqual(self.db.fatal(), False)
137     self.db.close()
138    
139     def testFlush(self):
140     self.assertEqual(self.db.flush(0), True)
141     self.db.close()
142    
143     def testSync(self):
144     self.assertEqual(self.db.sync(), True)
145     self.db.close()
146    
147     def testOptimize(self):
148     self.assertEqual(self.db.optimize(0), True)
149     self.db.close()
150    
151     def testPutDoc(self):
152     doc = Document()
153     doc.add_attr('@uri', 'http://www.example.com/')
154     doc.add_text('foo')
155     self.assertEqual(self.db.put_doc(doc, 0), True)
156     self.db.close()
157    
158     def testOutDoc(self):
159     self.assertEqual(self.db.out_doc(self.doc.id(), 0), True)
160     self.db.close()
161    
162     def testGetDoc(self):
163     self.assertNotEqual(self.db.get_doc(self.doc.id(), 0), None)
164     self.db.close()
165    
166     def testUriToID(self):
167     self.assertEqual(self.db.uri_to_id('http://www.example.com/'), self.doc.id())
168     self.db.close()
169    
170     def testEtchDoc(self):
171     self.assertEqual(self.db.etch_doc(self.doc, 10).keys(), ['foo'])
172     self.db.close()
173    
174     def testIterInit(self):
175     self.assertEqual(self.db.iter_init(), True)
176     self.db.close()
177    
178     def testIterNext(self):
179     self.assertEqual(self.db.iter_init(), True)
180     self.db.iter_next()
181     self.db.close()
182    
183     def testName(self):
184     self.assertEqual(self.db.name(), 'casket')
185     self.db.close()
186    
187     def testDocNum(self):
188     self.assertEqual(self.db.doc_num(), 1)
189     self.db.close()
190    
191     def testWordNum(self):
192     self.assertEqual(self.db.word_num(), 1)
193     self.db.close()
194    
195     def testSize(self):
196     self.assert_(self.db.size()>0)
197     self.db.close()
198    
199     def testSearch(self):
200     cond = Condition()
201     cond.set_phrase('foo')
202     self.assertNotEqual(len(list(self.db.search(cond, 0))), 0)
203     self.db.close()
204    
205     def testSetCacheSize(self):
206     self.db.set_cache_size(100, 100, 100)
207     self.db.close()
208    
209     def testSetSpecialCache(self):
210     self.db.set_special_cache('hoge', 100)
211     self.db.close()
212    
213     if __name__ == '__main__':
214     unittest.main()
215    

  ViewVC Help
Powered by ViewVC 1.1.26