view test/test_search.txt @ 0:b0942f44413f

import from git://github.com/mozilla/toolbox.git
author Jeff Hammel <k0scist@gmail.com>
date Sun, 11 May 2014 09:15:35 -0700
parents
children
line wrap: on
line source

Test toolbox search
===================

Ensure toolbox search does what we want it to.  First, create some
projects::

    >>> app.get('/')
    []
    >>> project = {'name': 'bzconsole', 'description': 'interact with bugzilla from the command line', 'url': 'http://k0s.org/mozilla/hg/bzconsole'}
    >>> response = app.new(**project)
    >>> project = {'name': 'my crazy addon', 'description': 'a crazy addon i made', 'url': 'http://a.m.o'}
    >>> response = app.new(**project)
    >>> [i['name'] for i in app.get('/')]
    [u'my crazy addon', u'bzconsole']

Define a search interface for our convenience::

    >>> def search(query):
    ...     return [i['name'] for i in app.get('/', params=dict(q=query))]
    >>> search('addon')
    [u'my crazy addon']

You should be able to search for a name::

    >>> search('bzconsole')
    [u'bzconsole']