'If the search criteria is not a valid key, a NO result is returned to
the client (resulting in an error callback), and an IllegalQueryError is
logged on the server side.'

def test_searchInvalidCriteria(self):

    queryTerms = 'FOO'
    def search():
        return self.client.search(queryTerms)
    d = self.connected.addCallback(strip(search))
    d = self.assertFailure(d, imap4.IMAP4Exception)
    def errorReceived(results):
        "\n                                                Verify    that    the    server    logs    an    IllegalQueryError    and    the\n                                                client    raises    an    IMAP4Exception    with    'Search    failed:...'\n                                                "
        self.client.transport.loseConnection()
        self.server.transport.loseConnection()
        errors = self.flushLoggedErrors(imap4.IllegalQueryError)
        self.assertEqual(len(errors), 1)
        self.assertEqual('SEARCH    failed:    Invalid    search    command    FOO', networkString(str(results)))
    d.addCallback(errorReceived)
    d.addErrback(self._ebGeneral)
    self.loopback()
    return d
