[Greater-commits] r349 - trunk/GREAT-ER-DB/impl/postgresql/test
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Jul 4 15:49:16 CEST 2011
Author: bricks
Date: 2011-07-04 15:49:15 +0200 (Mon, 04 Jul 2011)
New Revision: 349
Modified:
trunk/GREAT-ER-DB/impl/postgresql/test/test_pg_m_group.py
Log:
Update group tests
Modified: trunk/GREAT-ER-DB/impl/postgresql/test/test_pg_m_group.py
===================================================================
--- trunk/GREAT-ER-DB/impl/postgresql/test/test_pg_m_group.py 2011-07-01 14:57:02 UTC (rev 348)
+++ trunk/GREAT-ER-DB/impl/postgresql/test/test_pg_m_group.py 2011-07-04 13:49:15 UTC (rev 349)
@@ -14,12 +14,13 @@
# $Id: test_pg_m_group.py,v 1.2 2003-11-26 13:14:53 harjo Exp $
import unittest
-import os, sys
import support
import postgressupport
support.init()
+from datetime import date
+
# import Sybase
# sys.path.insert()
@@ -44,44 +45,69 @@
def setUp(self):
set_api_interface("_dagreater_pg")
self.server = postgressupport.get_test_server()
- self.connection_target = self.server.known_dbs["static_db"].get_connection_target()
- da_db_connect("anonym", "123", self.connection_target)
+ self.connection_target = self.server.known_dbs["static_db"].get_connection_target()
+ da_db_connect("anonym", "123", self.connection_target)
def test_0_insert_group(self):
- group_record = DA_S_group({'group_id':0,'name':'GUEST','admin':'0','cre_date':'30-11-2003','mod_date':'29-11-2003','status':'ready','remark':'remark_string here!'})
- self.res = da_insert_group(group_record)
- da_db_commit()
- self.assertEquals(self.res,None)
+ group_record = DA_S_group({'group_id':0,'name':'GUEST',
+ 'admin':'0',
+ 'cre_date':'30-11-2003',
+ 'mod_date':'29-11-2003',
+ 'status':'ready',
+ 'remark':'remark_string here!'})
+ today = date.today().strftime("%Y-%m-%d")
+ da_insert_group(group_record)
+ da_db_commit()
+ self.assertEquals(group_record.name, "GUEST")
+ self.assertEquals(group_record.admin, "0")
+ self.assertEquals(group_record.cre_date, today)
+ self.assertEquals(group_record.mod_date, today)
+ self.assertEquals(group_record.status, "ready")
+ self.assertEquals(group_record.remark, "remark_string here!")
+
+ group = da_get_group(group_record.group_id)
+ self.assertEquals(len(group), 1)
+ self.assertEquals(group[0].name, "GUEST")
+ self.assertEquals(group[0].admin, "0")
+ self.assertEquals(group[0].cre_date, today)
+ self.assertEquals(group[0].mod_date, today)
+ self.assertEquals(group[0].status, "ready")
+ self.assertEquals(group[0].remark, "remark_string here!")
+
def test_1_get_group(self):
- self.res = da_get_group(101)
- self.assertNotEquals(len(self.res),0)
- self.res = da_get_group(102)
- self.assertNotEquals(len(self.res),0)
- self.res = da_get_group(103)
- self.assertEquals(len(self.res),0)
- self.res = da_get_group(-1)
- self.assertNotEquals(len(self.res),0)
- self.res = da_get_group(-2)
- self.assertEquals(len(self.res),0)
-
+ res = da_get_group(101)
+ self.assertEquals(len(res), 1)
+ res = da_get_group(102)
+ self.assertEquals(len(res), 1)
+ res = da_get_group(103)
+ self.assertEquals(len(res), 0)
+ res = da_get_group(-1)
+ self.assertEquals(len(res), 2)
+ res = da_get_group(-2)
+ self.assertEquals(len(res), 0)
def test_2_update_group(self):
- self.group = da_get_group(102)
- self.group[0].name = 'UPDATE'
- self.res = da_update_group(self.group[0])
- self.assertEquals(self.res,None)
-
+ group = da_get_group(102)
+ self.assertNotEquals(group, None)
+ self.assertEquals(len(group), 1)
+ group[0].name = 'UPDATE'
+ da_update_group(group[0])
+ group = da_get_group(102)
+ self.assertEquals(len(group), 1)
+ self.assertEquals(group[0].name, "UPDATE")
+
def test_3_delete_group(self):
- self.res = da_get_group(102)
- self.assertNotEquals(len(self.res),0)
- self.res = da_delete_group(102)
- da_db_commit()
- self.res = da_get_group(102)
- self.assertEquals(len(self.res),0)
-
+ res = da_get_group(102)
+ self.assertNotEquals(len(res), 0)
+ da_delete_group(102)
+ da_db_commit()
+ res = da_get_group(102)
+ self.assertEquals(len(res), 0)
+
def tearDown(self):
- da_db_disconnect()
-
+ da_db_disconnect()
+
+
if __name__ == "__main__":
support.run_tests()
More information about the Greater-commits
mailing list