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()
def testSelectMailAliases(self):
"""
select all mail aliases
"""
self.cr.execute('SELECT * FROM mailalias')
self.cnx.commit()
print self.cr.description
result = self.cr.fetchall()
for line in result:
print line
cr = cnx.cursor() def testSelectMailPasswd(self):
"""
print "-- Information from mailalias --" select all mail passwords
cr.execute('SELECT * FROM mailalias') """
cnx.commit() self.cr.execute('SELECT * FROM mailpasswd')
self.cnx.commit()
print cr.description
print self.cr.description
result = cr.fetchall()
for line in result: result = cr.fetchall()
print line for line in result:
print line
print "-- Information from mailpasswd --"
cr.execute('SELECT * FROM mailpasswd') def testSelectDomains(self):
cnx.commit() """
result = cr.fetchall() select all domains
for line in result: """
print line self.cr.execute('SELECT DISTINCT domain FROM mailalias')
self.cnx.commit()
print "-- Domains --"
cr.execute('SELECT DISTINCT domain FROM mailalias') print self.cr.description
cnx.commit()
result = cr.fetchall() result = cr.fetchall()
for line in result: for line in result:
print line print line