Merge pull request #376 from mterzo/dep_update

Dependency update
This commit is contained in:
Tim Meusel
2017-03-21 01:15:55 +01:00
committed by GitHub
6 changed files with 21 additions and 50 deletions

View File

@@ -17,7 +17,6 @@ from flask import (
)
from pypuppetdb import connect
from pypuppetdb.errors import EmptyResponseError
from pypuppetdb.QueryBuilder import *
from puppetboard.forms import (CatalogForm, QueryForm)
@@ -119,26 +118,6 @@ 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
try:
@app.errorhandler(204)
def no_content(e):
return '', 204
except KeyError:
@app.errorhandler(EmptyResponseError)
def no_content(e):
return '', 204
@app.errorhandler(400)
def bad_request(e):
envs = environments()

View File

@@ -1,14 +1,14 @@
from __future__ import unicode_literals
from __future__ import absolute_import
from flask.ext.wtf import Form
from flask_wtf import FlaskForm
from wtforms import (
HiddenField, RadioField, SelectField,
TextAreaField, BooleanField, validators
)
class QueryForm(Form):
class QueryForm(FlaskForm):
"""The form used to allow freeform queries to be executed against
PuppetDB."""
query = TextAreaField('Query', [validators.Required(
@@ -30,7 +30,7 @@ class QueryForm(Form):
rawjson = BooleanField('Raw JSON')
class CatalogForm(Form):
class CatalogForm(FlaskForm):
"""The form used to compare the catalogs of different nodes."""
compare = HiddenField('compare')
against = SelectField('against')

View File

@@ -1,9 +1,9 @@
Flask >=0.10.1
Flask-WTF >=0.12,<=0.13
Jinja2 >=2.7.2
Flask >=0.12
Flask-WTF >=0.14.2
Jinja2 >=2.9.5
MarkupSafe >=0.19
WTForms >=2.0,<3.0
Werkzeug >=0.7,<= 0.11.5
WTForms >=2.1
Werkzeug >=0.12.1
itsdangerous >=0.23
pypuppetdb >=0.3.2
requests >=2.6.0
requests >=2.13.0

View File

@@ -16,12 +16,6 @@ def mock_puppetdb_environments(mocker):
return_value=environemnts)
def test_error_no_content():
result = app.no_content(None)
assert result[0] == ''
assert result[1] == 204
def test_error_bad_request(mock_puppetdb_environments):
with app.app.test_request_context():
(output, error_code) = app.bad_request(None)

12
test/test_form.py Normal file
View File

@@ -0,0 +1,12 @@
import pytest
from puppetboard import app, forms
def test_form_valid(capsys):
for form in [forms.QueryForm, forms.CatalogForm]:
with app.app.test_request_context():
qf = form()
out, err = capsys.readouterr()
assert qf is not None
assert err == ""
assert out == ""

View File

@@ -12,7 +12,6 @@ from werkzeug.exceptions import NotFound, InternalServerError
from puppetboard import utils
from puppetboard import app
from puppetboard.app import NoContent
from bs4 import BeautifulSoup
import logging
@@ -108,19 +107,6 @@ def test_http_connection_error(mock_log):
mock_log.error.assert_called_with(err)
def test_http_empty(mock_log, mocker):
err = "Empty Response"
def connection_error():
raise EmptyResponseError(err)
flask_abort = mocker.patch('flask.abort')
with pytest.raises(NoContent):
utils.get_or_abort(connection_error)
mock_log.error.assert_called_with(err)
flask_abort.assert_called_with('204')
def test_db_version_good(mocker, mock_info_log):
mocker.patch.object(app.puppetdb, 'current_version', return_value='4.2.0')
err = 'PuppetDB Version %d.%d.%d' % (4, 2, 0)