annotate bindings/python/tests/InitialisationRelated.py @ 718:14568e432e73

segfaults are gone, but the new bits still aren't quite behaving correctly. Also, some weird behavior when the query result is blank
author map01bf
date Thu, 24 Jun 2010 16:38:32 +0000
parents 159becb0701e
children 8e796b7b7a47
rev   line source
map01bf@662 1 #!/usr/bin/env python
map01bf@662 2 # encoding: utf-8
map01bf@662 3 """
map01bf@662 4 InitialisationRelated.py
map01bf@662 5
map01bf@662 6 designed to mirror the numbering for the C/C++ api's unit tests
map01bf@662 7 this performs tests 0001, 0002, 0003
map01bf@662 8
map01bf@662 9
map01bf@662 10 Created by Ben Fields on 2010-01-11.
map01bf@662 11 """
map01bf@662 12
map01bf@662 13 import sys
map01bf@662 14 import os,os.path
map01bf@662 15 import pyadb
map01bf@717 16 import numpy as np
map01bf@662 17 import struct
map01bf@662 18 import unittest
map01bf@662 19
map01bf@662 20
map01bf@662 21 class CreateADBTests(unittest.TestCase):
map01bf@662 22 def setUp(self):
map01bf@662 23 self.adb = pyadb.Pyadb("test.adb")
map01bf@662 24 def test_DBcreation(self):
map01bf@662 25 self.assert_(os.path.exists(self.adb.path))
map01bf@662 26 self.assertRaises(TypeError, pyadb.Pyadb)
map01bf@662 27 def test_DBstatus(self):
map01bf@662 28 try:
map01bf@662 29 self.adb.status()
map01bf@662 30 except:
map01bf@662 31 self.assert_(False)
map01bf@717 32 def test_1DinsertionFromFileSelfQuery(self):
map01bf@662 33 tH = open("testfeature", 'w')
map01bf@662 34 tH.write(struct.pack("=id",1,1))
map01bf@662 35 tH.close()
map01bf@718 36 self.adb.insert("testfeature", key='testfeature')
map01bf@662 37 self.adb.configQuery["seqLength"] = 1
map01bf@662 38 result = self.adb.query("testfeature")
map01bf@662 39 self.assert_(len(result.rawData) == 1)
map01bf@662 40 self.assert_(result.rawData.has_key("testfeature"))
map01bf@662 41 self.assert_(len(result.rawData["testfeature"]) == 1)
map01bf@662 42 self.assert_(result.rawData["testfeature"][0] == (float("-inf"), 0,0))
map01bf@717 43 os.remove(self.adb.path)#delete the db
map01bf@717 44 def test_1DinsertionFromArraySelfQuery(self):
map01bf@718 45 test1 = np.ones(1)
map01bf@717 46 print "test1: " + str(test1)
map01bf@717 47 self.adb.insert(featData=test1, key="testfeature")
map01bf@717 48 self.adb.configQuery["seqLength"] = 1
map01bf@717 49 result = self.adb.query(key="testfeature")
map01bf@717 50 self.assert_(len(result.rawData) == 1)
map01bf@717 51 self.assert_(result.rawData.has_key("testfeature"))
map01bf@717 52 self.assert_(len(result.rawData["testfeature"]) == 1)
map01bf@717 53 self.assert_(result.rawData["testfeature"][0] == (float("-inf"), 0,0))
map01bf@662 54
map01bf@662 55
map01bf@662 56
map01bf@662 57 if __name__ == '__main__':
map01bf@662 58 unittest.main()