chiark / gitweb /
test to verify current dbversion behavior
[disorder] / tests / dbversion.py
1 #! /usr/bin/env python
2 import dtest,time,disorder,sys,re
3
4 def test():
5     """Database version tests"""
6     # Start up with dbversion 1
7     config = "%s/config" % dtest.testroot
8     configsave = "%s.save" % config
9     dtest.copyfile(config, configsave)
10     open(config, "a").write("dbversion 1\n")
11     dtest.start_daemon()
12     time.sleep(2)
13     dtest.stop_daemon()
14     # Revert to default configuration
15     dtest.copyfile(configsave, config)
16     dtest.start_daemon()
17     time.sleep(2)
18     c = disorder.client()
19     try:
20         v = c.version()
21         print "unexpected success"
22         ok = False
23     except disorder.communicationError, e:
24         if re.search("connection refused", str(e)):
25             print "unexpected error: %s" % e
26             ok = False
27         else:
28             ok = True
29     dtest.stop_daemon()
30     if not ok:
31         sys.exit(1)
32
33 if __name__ == '__main__':
34     dtest.run(test)