Ticket #108: test.py

File test.py, 959 bytes (added by Richard Boulton, 18 years ago)

Test script simulating failure seen on windows

Line 
1#!/usr/bin/env python
2
3import os
4import xapian
5
6path="foo1"
7base_extn=".baseB"
8
9db = xapian.WritableDatabase(path, xapian.DB_CREATE_OR_OVERWRITE)
10doc = xapian.Document()
11# Database has full set of baseA, no baseB
12
13db.add_document(doc)
14db.flush()
15
16# Database has full set of baseB, old baseA
17
18db.add_document(doc)
19db.flush()
20
21# Database has full set of baseA, old baseB
22dbr = xapian.Database(path);
23print dbr.get_doccount()
24
25# Simulate a transaction starting, some of the baseB getting removed,
26# but then the transaction fails.
27os.unlink(os.path.join(path, 'record' + base_extn))
28os.unlink(os.path.join(path, 'termlist' + base_extn))
29
30# Database has full set of baseA, some old baseB
31dbr = xapian.Database(path);
32print dbr.get_doccount()
33
34db.add_document(doc)
35db.flush()
36
37# Database has full set of baseB, old baseA
38
39dbr = xapian.Database(path);
40print dbr.get_doccount()
41
42db.add_document(doc)
43db.flush()
44
45dbr = xapian.Database(path);
46print dbr.get_doccount()