Beispiel #1
0
 def __init__(self, redis):
     """
     :param txredisapi.lazyConnectionPool redis: 
     """
     self.redis = redis
     self.ttl = 5
     ResolverBase.__init__(self)
Beispiel #2
0
 def __init__(self, domain, savedir=None):
     self.savefile = None if savedir is None else os.path.join(savedir, domain)
     ResolverBase.__init__(self)
     self._cache = {}
     self.records = {}
     self.domain = domain
     self.load()
     self.create_soa()
Beispiel #3
0
 def __init__(self, domain, savedir=None):
     self.savefile = None if savedir is None else os.path.join(savedir, domain)
     ResolverBase.__init__(self)
     self._cache = {}
     self.records = {}
     self.domain = domain
     self.load()
     self.create_soa()
Beispiel #4
0
 def test_typeToMethodDispatch(self):
     """
     L{ResolverBase.query} looks up a method to invoke using the type of the
     query passed to it and the C{typeToMethod} mapping on itself.
     """
     results = []
     resolver = ResolverBase()
     resolver.typeToMethod = {
         12345: lambda query, timeout: results.append((query, timeout))}
     query = Query(name=b"example.com", type=12345)
     resolver.query(query, 123)
     self.assertEqual([(b"example.com", 123)], results)
Beispiel #5
0
 def test_typeToMethodDispatch(self):
     """
     L{ResolverBase.query} looks up a method to invoke using the type of the
     query passed to it and the C{typeToMethod} mapping on itself.
     """
     results = []
     resolver = ResolverBase()
     resolver.typeToMethod = {
         12345: lambda query, timeout: results.append((query, timeout))}
     query = Query(name=b"example.com", type=12345)
     resolver.query(query, 123)
     self.assertEqual([(b"example.com", 123)], results)
Beispiel #6
0
 def test_unknownQueryType(self):
     """
     L{ResolverBase.query} returns a L{Deferred} which fails with
     L{NotImplementedError} when called with a query of a type not present in
     its C{typeToMethod} dictionary.
     """
     resolver = ResolverBase()
     resolver.typeToMethod = {}
     query = Query(name=b"example.com", type=12345)
     queryDeferred = resolver.query(query, 123)
     result = []
     queryDeferred.addBoth(result.append)
     self.assertIsInstance(result[0], Failure)
     result[0].trap(NotImplementedError)
Beispiel #7
0
 def test_typeToMethodResult(self):
     """
     L{ResolverBase.query} returns a L{Deferred} which fires with the result
     of the method found in the C{typeToMethod} mapping for the type of the
     query passed to it.
     """
     expected = object()
     resolver = ResolverBase()
     resolver.typeToMethod = {54321: lambda query, timeout: expected}
     query = Query(name=b"example.com", type=54321)
     queryDeferred = resolver.query(query, 123)
     result = []
     queryDeferred.addBoth(result.append)
     self.assertEqual(expected, result[0])
Beispiel #8
0
 def test_typeToMethodResult(self):
     """
     L{ResolverBase.query} returns a L{Deferred} which fires with the result
     of the method found in the C{typeToMethod} mapping for the type of the
     query passed to it.
     """
     expected = object()
     resolver = ResolverBase()
     resolver.typeToMethod = {54321: lambda query, timeout: expected}
     query = Query(name=b"example.com", type=54321)
     queryDeferred = resolver.query(query, 123)
     result = []
     queryDeferred.addBoth(result.append)
     self.assertEqual(expected, result[0])
Beispiel #9
0
 def test_unknownQueryType(self):
     """
     L{ResolverBase.query} returns a L{Deferred} which fails with
     L{NotImplementedError} when called with a query of a type not present in
     its C{typeToMethod} dictionary.
     """
     resolver = ResolverBase()
     resolver.typeToMethod = {}
     query = Query(name=b"example.com", type=12345)
     queryDeferred = resolver.query(query, 123)
     result = []
     queryDeferred.addBoth(result.append)
     self.assertIsInstance(result[0], Failure)
     result[0].trap(NotImplementedError)
Beispiel #10
0
 def __init__(self, defaults, savedir):
     ResolverBase.__init__(self)
     self.defaults = defaults
     self.authorities = {}
     self.savedir = savedir
Beispiel #11
0
 def setUp(self):
     self.exceptionForCode = ResolverBase().exceptionForCode
Beispiel #12
0
 def __init__(self, defaults, savedir):
     ResolverBase.__init__(self)
     self.defaults = defaults
     self.authorities = {}
     self.savedir = savedir
 def __init__(self, store):
     ResolverBase.__init__(self)
     assert isinstance(store, RecordStore), 'This is not a record store'
     self.store = store