~bac/charmworld/bug-1257878

« back to all changes in this revision

Viewing changes to charmworld/tests/test_search.py

  • Committer: Tarmac
  • Author(s): Brad Crittenden
  • Date: 2013-11-15 20:11:46 UTC
  • mfrom: (461.2.4 fix-search-api)
  • Revision ID: tarmac-20131115201146-5agh31m3xiimpnc7
Handle api_searchs with ~user

Treat them as a search "owner: user" as we do in the in-site search.
Also don't puke if special characters in the user-entered search
cause an ElasticHttpError.

https://codereview.appspot.com/23330046/

R=gary.

Approved by Juju Gui Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
449
449
        ids = [r['data']['_id'] for r in result]
450
450
        self.assertItemsEqual([charm1['_id'], charm2['_id']], ids)
451
451
 
 
452
    def test_special_characters_return_no_results(self):
 
453
        self.makeCharm(name='foo')
 
454
        result = self.index_client.api_search('fo~o', autocomplete=True)
 
455
        ids = [r['data']['_id'] for r in result]
 
456
        self.assertItemsEqual([], ids)
 
457
        result = self.index_client.api_search('fo~o', autocomplete=False)
 
458
        ids = [r['data']['_id'] for r in result]
 
459
        self.assertItemsEqual([], ids)
 
460
 
452
461
    def get_charms_and_bundles(self, text='', type_=None, doctype=CHARM,
453
462
                               *args, **kwargs):
454
463
        filters = dict((key, [value]) for key, value in kwargs.items())