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:
parent
98ae40b366
commit
683f2ff4ef
1 changed files with 46 additions and 27 deletions
|
@ -1,31 +1,50 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import unittest
|
||||
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 --"
|
||||
cr.execute('SELECT * FROM mailalias')
|
||||
cnx.commit()
|
||||
print self.cr.description
|
||||
|
||||
print cr.description
|
||||
|
||||
result = cr.fetchall()
|
||||
for line in result:
|
||||
result = self.cr.fetchall()
|
||||
for line in result:
|
||||
print line
|
||||
|
||||
print "-- Information from mailpasswd --"
|
||||
cr.execute('SELECT * FROM mailpasswd')
|
||||
cnx.commit()
|
||||
result = cr.fetchall()
|
||||
for line in result:
|
||||
def testSelectMailPasswd(self):
|
||||
"""
|
||||
select all mail passwords
|
||||
"""
|
||||
self.cr.execute('SELECT * FROM mailpasswd')
|
||||
self.cnx.commit()
|
||||
|
||||
print self.cr.description
|
||||
|
||||
result = cr.fetchall()
|
||||
for line in result:
|
||||
print line
|
||||
|
||||
print "-- Domains --"
|
||||
cr.execute('SELECT DISTINCT domain FROM mailalias')
|
||||
cnx.commit()
|
||||
result = cr.fetchall()
|
||||
for line in result:
|
||||
def testSelectDomains(self):
|
||||
"""
|
||||
select all domains
|
||||
"""
|
||||
self.cr.execute('SELECT DISTINCT domain FROM mailalias')
|
||||
self.cnx.commit()
|
||||
|
||||
print self.cr.description
|
||||
|
||||
result = cr.fetchall()
|
||||
for line in result:
|
||||
print line
|
Loading…
Reference in a new issue