Mercurial > hg > audiodb
comparison bindings/python/tests/InitialisationRelated.py @ 662:01af8c56eb8d
added the first three unit tests for python bindings.
currently tests have to be manually run like this:
>python tests/InitialisationRelated.py
ensuring that the python location can see the pyadb library
(i.e. it's installed and in the search path or you've move to the local copy's location)
This should run all 3 tests with some moderate output.
All three tests should succeed.
author | map01bf |
---|---|
date | Wed, 13 Jan 2010 15:07:58 +0000 |
parents | |
children | 159becb0701e |
comparison
equal
deleted
inserted
replaced
661:72810ed81817 | 662:01af8c56eb8d |
---|---|
1 #!/usr/bin/env python | |
2 # encoding: utf-8 | |
3 """ | |
4 InitialisationRelated.py | |
5 | |
6 designed to mirror the numbering for the C/C++ api's unit tests | |
7 this performs tests 0001, 0002, 0003 | |
8 | |
9 | |
10 Created by Ben Fields on 2010-01-11. | |
11 """ | |
12 | |
13 import sys | |
14 import os,os.path | |
15 import pyadb | |
16 import struct | |
17 import unittest | |
18 | |
19 | |
20 class CreateADBTests(unittest.TestCase): | |
21 def setUp(self): | |
22 self.adb = pyadb.Pyadb("test.adb") | |
23 def test_DBcreation(self): | |
24 self.assert_(os.path.exists(self.adb.path)) | |
25 self.assertRaises(TypeError, pyadb.Pyadb) | |
26 def test_DBstatus(self): | |
27 try: | |
28 self.adb.status() | |
29 except: | |
30 self.assert_(False) | |
31 def test_1DinsertionSelfQuery(self): | |
32 tH = open("testfeature", 'w') | |
33 tH.write(struct.pack("=id",1,1)) | |
34 tH.close() | |
35 self.adb.insert("testfeature") | |
36 self.adb.configQuery["seqLength"] = 1 | |
37 result = self.adb.query("testfeature") | |
38 self.assert_(len(result.rawData) == 1) | |
39 self.assert_(result.rawData.has_key("testfeature")) | |
40 self.assert_(len(result.rawData["testfeature"]) == 1) | |
41 self.assert_(result.rawData["testfeature"][0] == (float("-inf"), 0,0)) | |
42 | |
43 | |
44 | |
45 | |
46 if __name__ == '__main__': | |
47 unittest.main() |