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