[Greater-commits] r308 - trunk/GREAT-ER-DB/impl/postgresql/test
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Jun 29 16:45:50 CEST 2011
Author: bricks
Date: 2011-06-29 16:45:50 +0200 (Wed, 29 Jun 2011)
New Revision: 308
Modified:
trunk/GREAT-ER-DB/impl/postgresql/test/test_pg_l_user.py
Log:
Extend and improve user related testcases
Modified: trunk/GREAT-ER-DB/impl/postgresql/test/test_pg_l_user.py
===================================================================
--- trunk/GREAT-ER-DB/impl/postgresql/test/test_pg_l_user.py 2011-06-29 14:44:12 UTC (rev 307)
+++ trunk/GREAT-ER-DB/impl/postgresql/test/test_pg_l_user.py 2011-06-29 14:45:50 UTC (rev 308)
@@ -18,6 +18,8 @@
import support
import postgressupport
+from datetime import date
+
support.init()
# import Sybase
@@ -48,37 +50,123 @@
# time.sleep(60)
def test_0_insert_user(self):
- user_record = DA_S_user({'user_id':'hans_wurst',
+ user_record = DA_S_user({'user_id':'john_doe',
'group_id':101,
'cre_date':'30-11-2003',
'mod_date':'29-11-2003',
'status':'VALID',
'remark':'Standard User!'})
- self.res = da_insert_user(user_record, "hallo")
+ res = da_insert_user(user_record, "hallo")
da_db_commit()
- self.assertEquals(self.res,None)
+ self.assertEquals(res, None)
+ res = da_get_user('john_doe')
+ self.assertEquals(len(res), 1);
+ # we always get the user_id in uppercase
+ self.assertEquals(res[0].user_id, 'JOHN_DOE');
+ res = da_delete_user('john_doe')
+ da_db_commit()
def test_1_get_user(self):
- self.res = da_get_user('anonym')
- self.assertNotEquals(len(self.res),0)
- self.res = da_get_user('hans_wurst')
- self.assertNotEquals(len(self.res),0)
- self.res = da_get_user('icjicjab')
- self.assertEquals(len(self.res),0)
+ today = date.today().strftime("%Y-%m-%d")
+ res = da_get_user('anonym')
+ self.assertEquals(len(res), 1)
+ self.assertEquals(res[0].user_id, "ANONYM")
+ res = da_get_user('icjicjab')
+ self.assertEquals(len(res), 0)
+ res = da_get_user("");
+ self.assertEquals(len(res), 3);
+ self.assertEquals(res[0].user_id, "ANONYM")
+ user_record = DA_S_user({'user_id':'john_doe',
+ 'group_id':101,
+ 'cre_date':'30-11-2003',
+ 'mod_date':'29-11-2003',
+ 'status':'VALID',
+ 'remark':'Standard User!'})
+ res = da_insert_user(user_record, "hallo")
+ da_db_commit()
+ res = da_get_user('john_doe')
+ self.assertEquals(len(res), 1)
+ self.assertEquals(res[0].user_id, "JOHN_DOE");
+ self.assertEquals(res[0].group_id, 101);
+ self.assertEquals(res[0].cre_date, today);
+ self.assertEquals(res[0].mod_date, today);
+ self.assertEquals(res[0].status, "VALID");
+ self.assertEquals(res[0].remark, "Standard User!");
+
+ res = da_get_user("JOHN_DOE")
+ self.assertEquals(len(res), 1)
+ self.assertEquals(res[0].user_id, "JOHN_DOE");
+ self.assertEquals(res[0].group_id, 101);
+ self.assertEquals(res[0].cre_date, today);
+ self.assertEquals(res[0].mod_date, today);
+ self.assertEquals(res[0].status, "VALID");
+ self.assertEquals(res[0].remark, "Standard User!");
+
+ res = da_get_user("john_DOE")
+ self.assertEquals(len(res), 1)
+ self.assertEquals(res[0].user_id, "JOHN_DOE");
+ self.assertEquals(res[0].group_id, 101);
+ self.assertEquals(res[0].cre_date, today);
+ self.assertEquals(res[0].mod_date, today);
+ self.assertEquals(res[0].status, "VALID");
+ self.assertEquals(res[0].remark, "Standard User!");
+
+ # test request for all users
+ res = da_get_user("");
+ self.assertEquals(len(res), 4);
+ self.assertEquals(res[0].user_id, "ANONYM")
+ self.assertEquals(res[1].user_id, "ANONYM_GREATER");
+ self.assertEquals(res[2].user_id, "GREATER200");
+ self.assertEquals(res[3].user_id, "JOHN_DOE")
+ res = da_delete_user('john_doe')
+ da_db_commit()
+
def test_2_update_user(self):
- self.user = da_get_user('hans_wurst')
- self.user[0].status = 'INVALID'
- self.res = da_update_user(self.user[0])
- self.assertEquals(self.res,None)
+ today = date.today().strftime("%Y-%m-%d")
+ user_record = DA_S_user({'user_id':'john_doe',
+ 'group_id':101,
+ 'cre_date':'30-11-2003',
+ 'mod_date':'29-11-2003',
+ 'status':'VALID',
+ 'remark':'Standard User!'})
+ res = da_insert_user(user_record, "hallo")
+ da_db_commit()
+ user = da_get_user('john_doe')
+ self.assertEquals(len(user), 1)
+ user[0].status = 'INVALID'
+ res = da_update_user(user[0])
+ self.assertEquals(res, None)
+ res = da_get_user('john_doe')
+ self.assertEquals(len(res), 1)
+ self.assertEquals(res[0].user_id, "JOHN_DOE");
+ self.assertEquals(res[0].group_id, 101);
+ self.assertEquals(res[0].cre_date, today);
+ self.assertEquals(res[0].mod_date, today);
+ self.assertEquals(res[0].status, "INVALID");
+ self.assertEquals(res[0].remark, "Standard User!");
+ res = da_delete_user('john_doe')
+ da_db_commit()
+
def test_3_delete_user(self):
- self.res = da_get_user('hans_wurst')
- self.assertNotEquals(len(self.res),0)
- self.res = da_delete_user('hans_wurst')
+ user_record = DA_S_user({'user_id':'john_doe',
+ 'group_id':101,
+ 'cre_date':'30-11-2003',
+ 'mod_date':'29-11-2003',
+ 'status':'VALID',
+ 'remark':'Standard User!'})
+ res = da_insert_user(user_record, "hallo")
da_db_commit()
- self.res = da_get_user('hans_wurst')
- self.assertEquals(len(self.res),0)
+ res = da_get_user('john_doe')
+ self.assertEquals(len(res), 1)
+ res = da_get_user('john_doe')
+ self.assertEquals(len(res), 1)
+ self.assertEquals(res[0].user_id, "JOHN_DOE");
+ res = da_delete_user('john_doe')
+ da_db_commit()
+ res = da_get_user('john_doe')
+ self.assertEquals(len(res), 0)
def tearDown(self):
da_db_disconnect()
More information about the Greater-commits
mailing list