コード例 #1
0
ファイル: test_common.py プロジェクト: 0004c/VTK
 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)
コード例 #2
0
ファイル: test_common.py プロジェクト: 0004c/VTK
 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)
コード例 #3
0
ファイル: test_common.py プロジェクト: 309972460/software
 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)
コード例 #4
0
ファイル: test_common.py プロジェクト: 0004c/VTK
 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])
コード例 #5
0
ファイル: test_common.py プロジェクト: 309972460/software
 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])