summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsis Lovecruft <isis@torproject.org>2013-02-18 18:05:41 +0000
committerIsis Lovecruft <isis@torproject.org>2013-02-18 18:05:41 +0000
commit1c634ab52225386549ac323a4fa832df3a040125 (patch)
tree0cc813aea97d995a9c0bd0a30da49fcde50f3086
parent81d67b90e88979b127728507b70407d2d3aa1754 (diff)
Switch AliasResolver unittest script to twisted.trial version offeature/unittests-trial
src/leap/mx/tests/test_alias_resolver.py.
-rw-r--r--src/leap/mx/tests/test_alias_resolver.py53
1 files 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()