'Testing whether the event endpoint returns search results when we have search results available'

@deferred(timeout=20)
def test_search_results(self):

    def verify_search_results(results):
        self.assertEqual(len(results), 2)
    self.messages_to_wait_for = 2
    def send_notifications(_):
        self.session.lm.api_manager.root_endpoint.events_endpoint.start_new_query()
        results_dict = {'keywords': ['test'], 'result_list': [(('a',) * 10)]}
        self.session.notifier.notify(SIGNAL_CHANNEL, SIGNAL_ON_SEARCH_RESULTS, None, results_dict)
        self.session.notifier.notify(SIGNAL_TORRENT, SIGNAL_ON_SEARCH_RESULTS, None, results_dict)
    self.socket_open_deferred.addCallback(send_notifications)
    return self.events_deferred.addCallback(verify_search_results)
