#NEWLINE# def _queryTest( self , filter ) : #NEWLINE# #INDENT# '\n        Invoke L{Resolver._query} and verify that it sends the correct DNS\n        query.  Deliver a canned response to the query and return whatever the\n        L{Deferred} returned by L{Resolver._query} fires with.\n\n        @param filter: The value to pass for the C{filter} parameter to\n            L{Resolver._query}.\n        ' #NEWLINE# reactor = MemoryReactor ( ) #NEWLINE# resolver = Resolver ( [ ] , reactor = reactor ) #NEWLINE# d = resolver . _query ( Query ( b'foo.example.com' , A , IN ) , [ ( '1.1.2.3' , 1053 ) ] , ( 30 , ) , filter ) #NEWLINE# ( portNumber , transport ) = reactor . udpPorts . popitem ( ) #NEWLINE# [ ( packet , address ) ] = transport . _sentPackets #NEWLINE# message = Message ( ) #NEWLINE# message . fromStr ( packet ) #NEWLINE# self . assertEqual ( message . queries , [ Query ( b'foo.example.com' , A , IN ) ] ) #NEWLINE# self . assertEqual ( message . answers , [ ] ) #NEWLINE# self . assertEqual ( message . authority , [ ] ) #NEWLINE# self . assertEqual ( message . additional , [ ] ) #NEWLINE# response = [ ] #NEWLINE# d . addCallback ( response . append ) #NEWLINE# self . assertEqual ( filter , [ ] ) #NEWLINE# del message . queries [ : ] #NEWLINE# message . answer = 1 #NEWLINE# message . answers . append ( RRHeader ( b'foo.example.com' , payload = Record_A ( '5.8.13.21' ) ) ) #NEWLINE# transport . _protocol . datagramReceived ( message . toStr ( ) , ( '1.1.2.3' , 1053 ) ) #NEWLINE# return response [ 0 ]