2005-09-19 20:55:40 +02:00
|
|
|
#!/usr/bin/env python
|
2006-02-20 21:42:45 +01:00
|
|
|
import unittest
|
2005-09-19 20:40:21 +02:00
|
|
|
import psycopg
|
|
|
|
|
2006-02-20 21:42:45 +01:00
|
|
|
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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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
|