[Greater-commits] r392 - trunk/GREAT-ER-DB/impl/postgresql/test
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Jul 8 17:37:43 CEST 2011
Author: bricks
Date: 2011-07-08 17:37:42 +0200 (Fri, 08 Jul 2011)
New Revision: 392
Modified:
trunk/GREAT-ER-DB/impl/postgresql/test/test_pg_p_bin_obj.py
Log:
Update all bin_obj test to reflect the current api behaviour
Fix indentation and formatting
Modified: trunk/GREAT-ER-DB/impl/postgresql/test/test_pg_p_bin_obj.py
===================================================================
--- trunk/GREAT-ER-DB/impl/postgresql/test/test_pg_p_bin_obj.py 2011-07-08 15:36:35 UTC (rev 391)
+++ trunk/GREAT-ER-DB/impl/postgresql/test/test_pg_p_bin_obj.py 2011-07-08 15:37:42 UTC (rev 392)
@@ -54,10 +54,22 @@
f = open(filename, 'rb')
buf = f.read()
bin_obj_record = DA_S_bin_obj({'bin_obj_id':0,'object_id':2,'name':filename,'user_id':'anonym','privs':6,'obj_type':'CATCHMENT','obj_sub_type':'RIVERNET','file_type':'DBF','file_obj':buf,'file_size':filesize,'cre_date':'30-11-2003','mod_date':'29-11-2003','write':'2','remark':'remark_string here!'})
- self.res = da_insert_bin_obj(bin_obj_record)
+ da_insert_bin_obj(bin_obj_record)
da_db_commit()
- self.assertEquals(self.res,None)
+ bin_obj = da_get_bin_obj(2, "CATCHMENT", bin_obj_record.bin_obj_id, "Y")
+ self.assertEquals(len(bin_obj), 1)
+ self.assertEquals(bin_obj[0].object_id, 2)
+ self.assertEquals(bin_obj[0].name, filename)
+ self.assertEquals(bin_obj[0].user_id, "ANONYM")
+ self.assertEquals(bin_obj[0].privs, 6)
+ self.assertEquals(bin_obj[0].obj_type, "CATCHMENT")
+ self.assertEquals(bin_obj[0].obj_sub_type, "RIVERNET")
+ self.assertEquals(bin_obj[0].file_type, "DBF")
+ self.assertEquals(bin_obj[0].file_size, filesize)
+ self.assertEquals(bin_obj[0].write, 'Y')
+ self.assertEquals(bin_obj[0].remark, "remark_string here!")
+
def test_1_load_bin_obj(self):
filename = "itterrivernet.dbf"
filepath = os.path.abspath("data")
@@ -78,7 +90,7 @@
'remark':'remark_string here!'
})
try:
- self.res = da_load_bin_obj(bin_obj_record, "Y", filepath, filename)
+ res = da_load_bin_obj(bin_obj_record, "Y", filepath, filename)
self.fail("file_obj must be either a string or None")
except TypeError:
pass
@@ -97,27 +109,51 @@
'write':'2',
'remark':'remark_string here!'
})
- self.res = da_load_bin_obj(bin_obj_record, "Y", filepath, filename)
+ res = da_load_bin_obj(bin_obj_record, "Y", filepath, filename)
da_db_commit()
- self.assertEquals(self.res,None)
- self.res = da_load_bin_obj(bin_obj_record, "N", filepath, filename)
+ self.assertEquals(res,None)
+ res = da_load_bin_obj(bin_obj_record, "N", filepath, filename)
da_db_commit()
- self.assertEquals(self.res,None)
+ self.assertEquals(res,None)
def test_2_get_bin_obj(self):
- self.res = da_get_bin_obj(1,"catchment",201,"Y")
- self.assertNotEquals(len(self.res[0].file_obj),0)
- self.res = da_get_bin_obj(2,"CATCHMENT",202,"Y")
- self.assertNotEquals(len(self.res[0].file_obj),0)
- self.res = da_get_bin_obj(2,"CATCHMENT",202,"N")
- self.assertEquals(self.res[0].file_obj,None)
- self.assertNotEquals(len(self.res),0)
- self.res = da_get_bin_obj(2,'CATCHMENT',203,"Y")
- self.assertNotEquals(len(self.res[0].file_obj),0)
- self.assertNotEquals(len(self.res),0)
- self.res = da_get_bin_obj(1,"catchment",205,"Y")
- self.assertEquals(len(self.res),0)
+ res = da_get_bin_obj(1, "catchment", 1, "N")
+ self.assertEquals(len(res), 0)
+ res = da_get_bin_obj(2, "CATCHMENT", 202, "Y")
+ self.assertEquals(len(res), 1)
+ self.assertNotEquals(len(res[0].file_obj), 0)
+ self.assertNotEquals(res[0].file_size, 0)
+
+ res = da_get_bin_obj(2, "catchment", 201, "Y")
+ self.assertEquals(len(res), 1)
+ self.assertEquals(res[0].file_obj, None)
+ self.assertEquals(res[0].file_size, 215283)
+
+ # test for lowercase
+ res = da_get_bin_obj(2, "catchment", 202, "Y")
+ self.assertEquals(len(res), 0)
+
+ res = da_get_bin_obj(2, "CATCHMENT", 202, "N")
+ self.assertEquals(len(res), 1)
+ self.assertEquals(res[0].file_obj, None)
+ self.assertEquals(res[0].file_size, 0)
+
+ res = da_get_bin_obj(2, 'CATCHMENT', 203, "Y")
+ self.assertEquals(len(res), 1)
+ self.assertNotEquals(len(res[0].file_obj), 0)
+
+ # get all CATCHMENTS
+ res = da_get_bin_obj(-1, "CATCHMENT", -1, "N")
+ self.assertEquals(len(res), 3)
+
+ # test for lowercase
+ res = da_get_bin_obj(-1, "catchment", -1, "N")
+ self.assertEquals(len(res), 1)
+
+ res = da_get_bin_obj(1, "catchment", 205, "Y")
+ self.assertEquals(len(res), 0)
+
def test_3_compare_bin_obj(self):
import hashlib
filename = os.path.abspath(os.path.join("data", "itterrivernet.dbf"))
@@ -134,22 +170,22 @@
self.assertEquals(res_hash.digest(), orig_hash.digest())
def test_4_update_bin_obj(self):
- self.res = da_get_bin_obj(1,"catchment",201,"Y")
-# print self.res[0].name
- self.res[0].name = "irgendeinName"
-# print self.res[0].name
- self.res = da_update_bin_obj(self.res[0])
- self.res = da_get_bin_obj(1,"catchment",201,"Y")
-# print self.res[0].name
- self.assertNotEquals(len(self.res),0)
+ res = da_get_bin_obj(1,"catchment",201,"Y")
+# print res[0].name
+ res[0].name = "irgendeinName"
+# print res[0].name
+ res = da_update_bin_obj(res[0])
+ res = da_get_bin_obj(1,"catchment",201,"Y")
+# print res[0].name
+ self.assertNotEquals(len(res),0)
def test_5_delete_bin_obj(self):
- self.res = da_get_bin_obj(1,"catchment",201,"Y")
- self.assertNotEquals(len(self.res),0)
- self.res = da_delete_bin_obj(201)
+ res = da_get_bin_obj(1,"catchment",201,"Y")
+ self.assertNotEquals(len(res),0)
+ res = da_delete_bin_obj(201)
da_db_commit()
- self.res = da_get_bin_obj(1,"catchment",201,"Y")
- self.assertEquals(len(self.res),0)
+ res = da_get_bin_obj(1,"catchment",201,"Y")
+ self.assertEquals(len(res),0)
def tearDown(self):
More information about the Greater-commits
mailing list