def save(self, **kwargs): # while used in async method, app context is not available by default and needs to be imported from flask import current_app as app from kqueen.server import create_app try: if not app.testing: app = create_app() except RuntimeError: app = create_app() with app.app_context(): return super().save(**kwargs)
def etcd_setup(): _app = create_app() try: _app.db.client.delete(_app.config['ETCD_PREFIX'], recursive=True) except etcd.EtcdKeyNotFound: pass
def save(self, check_status=True, **kwargs): # while used in async method, app context is not available by default and needs to be imported from flask import current_app as app from kqueen.server import create_app try: if not app.testing: app = create_app() except RuntimeError: app = create_app() with app.app_context(): if check_status: self.state = self.engine_status(save=False) self.verbose_name = getattr(self.get_engine_cls(), 'verbose_name', self.engine) return super().save(**kwargs)
def app(): """Prepare app.""" global current_app current_app = create_app() current_app.testing = True return current_app
def main(): args = parser.parse_args() app = create_app() with app.app_context(): # Organization and user try: organization = Organization( id=organization_id, name=args.organization, namespace=args.namespace, created_at=datetime.utcnow() ) organization.save() print('Organization {} successfully created!'.format(organization.name)) except Exception: raise Exception('Adding {} organization failed'.format(args.organization)) try: user = User.create( None, id=user_id, username=args.username, password=args.password, email='*****@*****.**', organization=organization, created_at=datetime.utcnow(), role='superadmin', active=True ) user.save() print('User {} successfully created!'.format(user.username)) except Exception: raise Exception('Adding {} user failed'.format(args.username))
def app(): """Prepare app.""" app = create_app() return app
def app(): """Prepare app.""" app = create_app() app.testing = True return app
import requests import yaml uuid_organization = '22d8df64-4ac9-4be0-89a7-c45ea0fc85da' uuid_jenkins = 'c88b05d6-a107-4636-a3cc-eb5c90562f8f' uuid_local = '2d51891a-adac-4bbc-a725-eed20cc67849' uuid_provisioner_jenkins = 'e8de24b0-43d1-4a3c-af55-7b1d3f700554' uuid_provisioner_local = '203c50d6-3d09-4789-8b8b-1ecb00814436' uuid_provisioner_kubespray = '689de9a2-50e0-4fcd-b6a6-96930b5fadc9' kubeconfig_url = 'https://ci.mcp.mirantis.net/job/deploy-aws-k8s_ha_calico_sm/33/artifact/kubeconfig' app = create_app() with app.app_context(): # Organization and user try: organization = Organization( id=uuid_organization, name='DemoOrg', namespace='demoorg' ) organization.save() except: raise Exception('Adding DemoOrg organization failed') try: user = User( username='******',
def test_env_var_in_app(self, monkeypatch): monkeypatch.setenv('KQUEEN_DUMMY', '123') app = create_app() assert app.config.get('DUMMY') == '123'
def test_app_config(): app = create_app(config_file='nonexistent_file.py') assert hasattr(app, 'config')
def app(): app = create_app() return app
def test_app_config(): app = create_app() assert hasattr(app, 'config')
def app(): """Prepare app.""" app = create_app(config_file=config_file) return app