How to use puppetboard - 10 common examples

To help you get started, we’ve selected a few puppetboard examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github voxpupuli / puppetboard / test / test_utils.py View on Github external
def test_get():
    x = "hello world"

    def test_get_or_abort():
        return x

    assert x == utils.get_or_abort(test_get_or_abort)
github voxpupuli / puppetboard / test / test_utils.py View on Github external
def test_http_connection_error(mock_log):
    err = "ConnectionError"

    def connection_error():
        x = Response()
        x.status_code = 500
        x.reason = err
        raise ConnectionError(err, response=x)

    with pytest.raises(InternalServerError):
        utils.get_or_abort(connection_error)
        mock_log.error.assert_called_with(err)
github voxpupuli / puppetboard / test / test_form.py View on Github external
def test_form_valid(capsys):
    for form in [forms.QueryForm]:
        with app.app.test_request_context():
            qf = form()
            out, err = capsys.readouterr()
            assert qf is not None
            assert err == ""
            assert out == ""
github voxpupuli / puppetboard / test / test_app_error.py View on Github external
def test_error_server(mock_puppetdb_environments):
    with app.app.test_request_context():
        (output, error_code) = server_error(None)
        soup = BeautifulSoup(output, 'html.parser')

        assert 'Internal Server Error' in soup.h2.text
        assert error_code == 500
github voxpupuli / puppetboard / test / test_app_error.py View on Github external
def test_early_error_server(mock_server_error):
    with app.app.test_request_context():
        (output, error_code) = server_error(None)
        soup = BeautifulSoup(output, 'html.parser')
        assert 'Internal Server Error' in soup.h2.text
        assert error_code == 500
github voxpupuli / puppetboard / test / test_app_error.py View on Github external
def test_error_forbidden(mock_puppetdb_environments):
    with app.app.test_request_context():
        (output, error_code) = forbidden(None)
        soup = BeautifulSoup(output, 'html.parser')

        long_string = "%s %s" % ('What you were looking for has',
                                 'been disabled by the administrator')
        assert long_string in soup.p.text
        assert error_code == 403
github voxpupuli / puppetboard / test / test_app_error.py View on Github external
def test_error_precond(mock_puppetdb_environments):
    with app.app.test_request_context():
        (output, error_code) = precond_failed(None)
        soup = BeautifulSoup(output, 'html.parser')

        long_string = "%s %s" % ('You\'ve configured Puppetboard with an API',
                                 'version that does not support this feature.')
        assert long_string in soup.p.text
        assert error_code == 412
github voxpupuli / puppetboard / test / test_app_error.py View on Github external
def test_error_bad_request(mock_puppetdb_environments):
    with app.app.test_request_context():
        (output, error_code) = bad_request(None)
        soup = BeautifulSoup(output, 'html.parser')

        assert 'The request sent to PuppetDB was invalid' in soup.p.text
        assert error_code == 400
github voxpupuli / puppetboard / test / test_app_error.py View on Github external
def test_error_not_found(mock_puppetdb_environments):
    with app.app.test_request_context():
        (output, error_code) = not_found(None)
        soup = BeautifulSoup(output, 'html.parser')

        long_string = "%s %s" % ('What you were looking for could not',
                                 'be found in PuppetDB.')
        assert long_string in soup.p.text
        assert error_code == 404
github voxpupuli / puppetboard / test / test_utils.py View on Github external
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)
    result = utils.get_db_version(app.puppetdb)
    mock_info_log.assert_called_with(err)
    assert (4, 0, 0) < result
    assert (4, 2, 0) == result
    assert (3, 2, 0) < result
    assert (4, 3, 0) > result
    assert (5, 0, 0) > result
    assert (4, 2, 1) > result