'Testing whether the API returns the right terms when getting search completion terms'

@deferred(timeout=10)
def test_completions(self):

    torrent_db_handler = self.session.open_dbhandler(NTFY_TORRENTS)
    torrent_db_handler.getAutoCompleteTerms = (lambda keyword, max_terms: [('%s    %d' % (keyword, ind)) for ind in xrange(max_terms)])
    expected_json = {'completions': [('tribler    %d' % ind) for ind in xrange(5)]}
    return self.do_request('search/completions?q=tribler', expected_code=200, expected_json=expected_json)
