From 1c634ab52225386549ac323a4fa832df3a040125 Mon Sep 17 00:00:00 2001 From: Isis Lovecruft Date: Mon, 18 Feb 2013 18:05:41 +0000 Subject: Switch AliasResolver unittest script to twisted.trial version of src/leap/mx/tests/test_alias_resolver.py. --- src/leap/mx/tests/test_alias_resolver.py | 53 +++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/src/leap/mx/tests/test_alias_resolver.py b/src/leap/mx/tests/test_alias_resolver.py index c8d7952..e5f4221 100644 --- a/src/leap/mx/tests/test_alias_resolver.py +++ b/src/leap/mx/tests/test_alias_resolver.py @@ -10,26 +10,49 @@ Unittests for /leap/mx/alias_resolver.py. @copyright: copyright 2013 Isis Agora Lovecruft ''' -from twisted.internet import address +import os +import socket +import stat + +from twisted.internet import address, defer, reactor from twisted.mail import maildir, alias from twisted.protocols import postfix +from twisted.trial import unittest from leap.mx import alias_resolver from leap.mx.util import config, log, net +config.filename = 'mx.conf.private' +config.loadConfig() + +user = config.couch.user +pswd = config.couch.passwd +host = config.couch.host +port = config.couch.port + +## xxx dbName should be a config setting +connection = alias_resolver.ConnectedCouchDB(host, port, + dbName="users", + username=user, + password=pswd) +connection.listDB() +print connection + +class TestAliasResolverServer(unittest.TestCase): + def setUp(self, *args, **kwargs): + self.factory = alias_resolver.AliasResolverFactory( + data={'isis@leap.se': '0x2cdbb35'}) + self.protocol = self.factory.buildProtocol() + + client_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + if (os.path.exists(client_socket) and + os.stat(socket).st_mode & ( + stat.S_IRGP | stat.S_IRUSR | stat.S_IROTH)): + self.client_connection = (reactor, client_socket) + self.client = UnixClientEndpoint(self.client_connection) + + if __name__ == "__main__": - config.filename = 'mx.conf.private' - config.loadConfig() - - user = config.couch.user - pswd = config.couch.passwd - host = config.couch.host - port = config.couch.port - - connection = alias_resolver.ConnectedCouchDB(host, port, - dbName="users", - username=user, - password=pswd) - connection.listDB() - print connection + + tars = TestAliasResolverServer() -- cgit v1.2.3