comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:b0942f44413f
1 Test toolbox search
2 ===================
3
4 Ensure toolbox search does what we want it to. First, create some
5 projects::
6
7 >>> app.get('/')
8 []
9 >>> project = {'name': 'bzconsole', 'description': 'interact with bugzilla from the command line', 'url': 'http://k0s.org/mozilla/hg/bzconsole'}
10 >>> response = app.new(**project)
11 >>> project = {'name': 'my crazy addon', 'description': 'a crazy addon i made', 'url': 'http://a.m.o'}
12 >>> response = app.new(**project)
13 >>> [i['name'] for i in app.get('/')]
14 [u'my crazy addon', u'bzconsole']
15
16 Define a search interface for our convenience::
17
18 >>> def search(query):
19 ... return [i['name'] for i in app.get('/', params=dict(q=query))]
20 >>> search('addon')
21 [u'my crazy addon']
22
23 You should be able to search for a name::
24
25 >>> search('bzconsole')
26 [u'bzconsole']