1
0
Fork 0
gnuviechadmin-historic/backend/psycopgtest.py

50 lines
1,020 B
Python
Raw Normal View History

#!/usr/bin/env python
import unittest
import psycopg
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