changeset 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 72810ed81817
children bcc7a6ddb2c8
files bindings/python/tests/InitialisationRelated.py
diffstat 1 files changed, 47 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bindings/python/tests/InitialisationRelated.py	Wed Jan 13 15:07:58 2010 +0000
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+# encoding: utf-8
+"""
+InitialisationRelated.py
+
+designed to mirror the numbering for the C/C++ api's unit tests
+this performs tests 0001, 0002, 0003
+
+
+Created by Ben Fields on 2010-01-11.
+"""
+
+import sys
+import os,os.path
+import pyadb
+import struct
+import unittest
+
+
+class CreateADBTests(unittest.TestCase):
+	def setUp(self):
+		self.adb = pyadb.Pyadb("test.adb")
+	def test_DBcreation(self):
+		self.assert_(os.path.exists(self.adb.path))
+		self.assertRaises(TypeError, pyadb.Pyadb)
+	def test_DBstatus(self):
+		try:
+			self.adb.status()
+		except:
+			self.assert_(False)
+	def test_1DinsertionSelfQuery(self):
+		tH = open("testfeature", 'w')
+		tH.write(struct.pack("=id",1,1))
+		tH.close()
+		self.adb.insert("testfeature")
+		self.adb.configQuery["seqLength"] = 1
+		result = self.adb.query("testfeature")
+		self.assert_(len(result.rawData) == 1)
+		self.assert_(result.rawData.has_key("testfeature"))
+		self.assert_(len(result.rawData["testfeature"]) == 1)
+		self.assert_(result.rawData["testfeature"][0] == (float("-inf"), 0,0))
+		
+		
+
+
+if __name__ == '__main__':
+	unittest.main()
\ No newline at end of file