image
Boddle
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!
Install
sudo pip install boddle
Usage
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 <example.py>`__.
Options
The Bottle-specific params that are supported are:
Argument |
Notes |
|---|---|
params |
Populates request.params. Takes a dict or list of pairs. Useful for both POST and GET params. |
path |
The path component of the url. Populates request.path, which always has a preceeding /. |
method |
POST, GET, etc. Bottle will uppercase the value. |
headers |
Any HTTP headers. Takes a dict. |
json |
Takes anything that can be consumed by json.dumps(). Also sets the content type of the request. |
url |
The full URL, protocol, domain, port, path, etc. Will be parsed until its urlparts before populating request.url. |
body |
The raw body of the request. Takes either a str or a file-like object. strs will be converted into file-like objects. Populated request.body. |
query |
Populates request.query. Takes a dict. |
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_user
You 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 here
ALL CHANGES TO ``bottle.request`` ARE REVERTED WHEN THE WITH BLOCK ENDS.
Testing
image
$ git clone https://github.com/keredson/boddle.git $ cd boddle $ python tests.py ............ ---------------------------------------------------------------------- Ran 12 tests in 0.001s OK
Metadata
Release files for boddle 0.2.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| boddle-0.2.9.tar.gz | 4.1 kB | Without provenance | Details for boddle-0.2.9.tar.gz |
Release files / boddle-0.2.9.tar.gz
| Download URL | boddle-0.2.9.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b651650b2ab1adb64293bab746159df94ac86e51164459dc117c6c60c5726b5c
|
|
BLAKE2b-256 checksum How to use checksums |
cf7379ed51ed60edbf53c3c2fb2e148fa78b7aa0a57041da0f2b7090f15aacb6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.8
|
Security for boddle 0.2.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.