Adding unittests (#300)
* Create a custom class to handle aborting 204 properly. If this isn't covered the server will send a 500 due to a python exception * Moved py.test configuration under tool:pytest, this was causing a warning. This is new to 3.0.1 which is now the pinned version * Unittest for puppetboard.utils
This commit is contained in:
committed by
Corey Hammerton
parent
dffd42af1d
commit
3fbd182453
@@ -25,6 +25,8 @@ from puppetboard.utils import (
|
||||
jsonprint, prettyprint, Pagination
|
||||
)
|
||||
|
||||
import werkzeug.exceptions as ex
|
||||
|
||||
DEFAULT_ORDER_BY = '[{"field": "start_time", "order": "desc"}]'
|
||||
|
||||
app = Flask(__name__)
|
||||
@@ -93,6 +95,22 @@ def utility_processor():
|
||||
return dict(now=now)
|
||||
|
||||
|
||||
#
|
||||
# 204 doesn't have a mapping in werkzeug, we need to define a custom
|
||||
# class and then set it to the mappings.
|
||||
#
|
||||
class NoContent(ex.HTTPException):
|
||||
code = 204
|
||||
description = '<p>No content</p'
|
||||
|
||||
abort.mapping[204] = NoContent
|
||||
|
||||
|
||||
@app.errorhandler(204)
|
||||
def no_content(e):
|
||||
return '', 204
|
||||
|
||||
|
||||
@app.errorhandler(400)
|
||||
def bad_request(e):
|
||||
envs = environments()
|
||||
|
||||
Reference in New Issue
Block a user