A unit testing tool for Python's bottle library. We wrote this for our own testing purposes at https://www.hvst.com. Thanks brenguyen711 for the great name!
sudo pip install boddle
Assuming you have a bottle route like this:
@bottle.get('/woot')
def woot():
return bottle.request.params['name']You can unit test it like:
import unittest
from boddle import boddle
class TestIt(unittest.TestCase):
def testWoot(self):
with boddle(params={'name':'derek'}):
self.assertEqual(woot(), 'derek')See example.py.
The Bottle-specific params that are supported are:
All other keyword arguments will be assigned to the request object. For instance, we often do:
with boddle(current_user=someone):
# code that accesses bottle.request.current_userYou can also nest boddle calls. For instance:
with boddle(path='/woot'):
with boddle(params={'name':'derek'}):
# both path and params are set here
# only path is set hereALL CHANGES TO bottle.request ARE REVERTED WHEN THE WITH BLOCK ENDS.
$ git clone https://github.com/keredson/boddle.git
$ cd boddle
$ python tests.py
............
----------------------------------------------------------------------
Ran 12 tests in 0.001s
OK

