Esempio n. 1
0
    def test_k8s_client_is_configured(self):
        token = "token"
        cert = "/path/to/cert.crt"
        DEFAULT_CONFIG['APISERVER_TOKEN'] = token
        DEFAULT_CONFIG['APISERVER_CA_CERT'] = cert
        create_app(DEFAULT_CONFIG)

        assert config.api_token == token
        assert config.verify_ssl == cert
Esempio n. 2
0
 def test_error_handler(self, action, code):
     app = create_app(DEFAULT_CONFIG)
     resp = action(app.test_client())
     assert resp.status_code == code
     body = loads(resp.data.decode(resp.charset))
     assert body["code"] == code
     assert all(x in body.keys() for x in ("name", "description"))
Esempio n. 3
0
def test_status_bootstrap_filter():
    app = create_app(DEFAULT_CONFIG)
    assert app.jinja_env.filters['status_bootstrap'](
        'not_a_valid_status') == 'warning'
    assert app.jinja_env.filters['status_bootstrap']('UNKNOWN') == 'warning'
    assert app.jinja_env.filters['status_bootstrap']('SUCCESS') == 'success'
    assert app.jinja_env.filters['status_bootstrap']('RUNNING') == 'info'
    assert app.jinja_env.filters['status_bootstrap']('FAILED') == 'danger'
Esempio n. 4
0
 def test_app_uses_config_object(self, monkeypatch):
     token = 'token'
     monkeypatch.setenv('APISERVER_TOKEN', token)
     monkeypatch.setenv('APISERVER_CA_CERT', "/path/to/cert.crt")
     monkeypatch.setenv('ARTIFACTORY_USER', "default_username")
     monkeypatch.setenv('ARTIFACTORY_PWD', "default_password")
     app = create_app()
     assert app.config['APISERVER_TOKEN'] == token
Esempio n. 5
0
def client():
    app = create_app(DEFAULT_CONFIG)
    with app.app_context():
        with app.test_client() as client:
            yield client
Esempio n. 6
0
def main():
    app = create_app()
    app.run(host="0.0.0.0",
            port=int(app.config['PORT']),
            debug=bool(app.config['DEBUG']))