'Test whether we are creating a search response when we receive a search request'

def test_on_search(self):

    def log_incoming_searches(sock_addr, keywords):
        log_incoming_searches.called = True
    log_incoming_searches.called = False
    def create_search_response(id, results, candidate):
        create_search_response.called = True
        self.assertEqual(id, 'abc')
        self.assertEqual(results, [])
        self.assertEqual(candidate.sock_addr, '1234')
    create_search_response.called = False
    def search_names(keywords, local=False, keys=None):
        return []
    self.search_community._torrent_db = MockObject()
    self.search_community._torrent_db.searchNames = search_names
    fake_message = MockObject()
    fake_message.candidate = MockObject()
    fake_message.candidate.sock_addr = '1234'
    fake_message.payload = MockObject()
    fake_message.payload.keywords = 'test'
    fake_message.payload.identifier = 'abc'
    self.search_community._create_search_response = create_search_response
    self.search_community.log_incoming_searches = log_incoming_searches
    self.search_community.on_search([fake_message])
    self.assertTrue(log_incoming_searches.called)
    self.assertTrue(create_search_response.called)
