1
0
Fork 0

transform psycopgtest to a unit test

git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/gnuviech.info/gnuviechadmin/trunk@155 a67ec6bc-e5d5-0310-a910-815c51eb3124
This commit is contained in:
Jan Dittberner 2006-02-20 20:42:45 +00:00
parent 98ae40b366
commit 683f2ff4ef

View file

@ -1,31 +1,50 @@
#!/usr/bin/env python #!/usr/bin/env python
import unittest
import psycopg import psycopg
cnx = psycopg.connect("host=localhost user=exim4 password=CotOgigmeIk5 dbname=gnuviechadmin") class TestDBConnection(unittest.TestCase):
def setUp(self):
"""
set up database connection used in tests
"""
self.cnx = psycopg.connect("host=localhost user=gnuviech password=SIKKnsyXsV5yU dbname=gnuviechadmin")
self.cr = self.cnx.cursor()
cr = cnx.cursor() def testSelectMailAliases(self):
"""
select all mail aliases
"""
self.cr.execute('SELECT * FROM mailalias')
self.cnx.commit()
print "-- Information from mailalias --" print self.cr.description
cr.execute('SELECT * FROM mailalias')
cnx.commit()
print cr.description result = self.cr.fetchall()
for line in result:
print line
def testSelectMailPasswd(self):
"""
select all mail passwords
"""
self.cr.execute('SELECT * FROM mailpasswd')
self.cnx.commit()
print self.cr.description
result = cr.fetchall() result = cr.fetchall()
for line in result: for line in result:
print line print line
print "-- Information from mailpasswd --" def testSelectDomains(self):
cr.execute('SELECT * FROM mailpasswd') """
cnx.commit() select all domains
result = cr.fetchall() """
for line in result: self.cr.execute('SELECT DISTINCT domain FROM mailalias')
print line self.cnx.commit()
print self.cr.description
print "-- Domains --"
cr.execute('SELECT DISTINCT domain FROM mailalias')
cnx.commit()
result = cr.fetchall() result = cr.fetchall()
for line in result: for line in result:
print line print line