source: exist/trunk/python/ndgeXist/test_eXistInterface.py @ 3110

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/exist/trunk/python/ndgeXist/test_eXistInterface.py@3110
Revision 3110, 1.4 KB checked in by lawrence, 12 years ago (diff)

Attempts to eggify the ndg exist interfaces continue

Line 
1import unittest,os
2from eXistInterface import *
3
4class TestCase(unittest.TestCase):
5    def setUp(self):
6        ''' Try to connect to the exist databases available '''
7        try:
8            passwordFile='passwords.txt'
9            f=open(passwordFile,'r')
10            pw={}
11            for line in f.readlines():
12                host,userid,password=line.strip().split(' ')
13                pw[host]=(userid,password)
14            f.close()
15            self.pw=pw
16        except IOError,e:
17            raise IOError('''\n
18        Running this test requires a "passwords.txt" file in directory %s 
19        This file should include one or more lines of the form:
20                hostname username password
21        and this test routine will use the *last* one of these to test things!
22        '''%os.getcwd())
23       
24    def test_listCollections(self):
25        ''' Test we can list collections in the database '''
26        for host in self.pw:
27            xmldb=ndg_eXist(db=host)
28            xq='''for $s in xmldb:get-child-collections('/db') return <collection>{$s}</collection>'''
29            id,summary=xmldb.executeQuery(xq)
30            self.assertEqual(True,(summary['hits']>0))
31            for i in range(summary['hits']): print host,xmldb.retrieveNext(id,i)
32            xmldb.release(id)
33
34    #def test_xqueryLib(self):
35    #    ''' Test the installed xquery lib is the same as the source xquery lib '''
36    #    pass
37   
38if __name__=="__main__":
39    unittest.main()
Note: See TracBrowser for help on using the repository browser.