def create_app(self):
     """
     Create the wsgi application
     """
     app_ = app.create_app()
     app_.config['SQLALCHEMY_DATABASE_URI'] = "sqlite://"
     app_.config['MC_LOGGING'] = {}
     return app_
 def _provision(self, service):
     """
     Run the provision for a given service
     """
     app = create_app()
     app.config['DEPENDENCIES']['CONSUL']['PORT'] = self.port
     with app.app_context():
         ConsulProvisioner(service)()
Exemple #3
0
 def create_app(self):
     """
     Create the wsgi application
     """
     app_ = app.create_app()
     app_.config['SQLALCHEMY_DATABASE_URI'] = "sqlite://"
     app_.config['GITHUB_SECRET'] = 'unittest-secret'
     return app_
 def create_app(self):
     """
     Create the wsgi application
     """
     app_ = app.create_app()
     app_.config['SQLALCHEMY_DATABASE_URI'] = "sqlite://"
     app_.config['MC_LOGGING'] = {}
     return app_
 def _provision(self, service):
     """
     Run the provision for a given service
     """
     # Modifying a live application's config is the most straightforward
     # way to connect to a non-default port for this test case
     app = create_app()
     app.config['DEPENDENCIES']['POSTGRES']['PORT'] = self.port
     with app.app_context():
         PostgresProvisioner(service)()
    def get_db_params():
        """
        finds the parameters necessary to connect to the postgres instance.
        :return: string uri of the postgres instance
        """
        try:
            config = current_app.config
        except RuntimeError:  # Outside of application context
            config = create_app().config

        return config['DEPENDENCIES']['POSTGRES']
 def create_app(self):
     """
     Called once at the beginning of the tests; must return the application
     instance
     :return: flask.Flask application instance
     """
     _app = create_app()
     # Override whatever database uri is in the config for tests;
     # Use an in-memory sqlite database to ensure that no production data
     # are touched
     _app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite://"
     _app.config['MC_LOGGING'] = {}
     return _app
 def create_app(self):
     """
     Called once at the beginning of the tests; must return the application
     instance
     :return: flask.Flask application instance
     """
     _app = create_app()
     # Override whatever database uri is in the config for tests;
     # Use an in-memory sqlite database to ensure that no production data
     # are touched
     _app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite://"
     _app.config['MC_LOGGING'] = {}
     return _app
    def get_cli_params():
        """
        finds the command line parameters necessary to pass to `psql`
        :returns string containing psql-specifically formatted params
        """
        try:
            config = current_app.config
        except RuntimeError:  # Outside of application context
            config = create_app().config
        config = config['DEPENDENCIES']['CONSUL']

        cli = "{port}".format(port=config.get('PORT', 8500), )

        return cli
    def test_get_cli_params(self):
        """
        This @staticmethod should return a string.
        The function should work both with and without an application context
        """
        cli = PostgresProvisioner.get_cli_params()
        self.assertIsInstance(cli, basestring)

        with create_app().app_context():
            self.assertEqual(cli, PostgresProvisioner.get_cli_params())
            # Delete the requires config value to see if the method tries to
            # access it. Expect KeyError
            with self.assertRaises(KeyError):
                del current_app.config["DEPENDENCIES"]["POSTGRES"]
                PostgresProvisioner.get_cli_params()
    def test_get_cli_params(self):
        """
        This @staticmethod should return a string.
        The function should work both with and without an application context
        """
        cli = PostgresProvisioner.get_cli_params()
        self.assertIsInstance(cli, basestring)

        with create_app().app_context():
            self.assertEqual(cli, PostgresProvisioner.get_cli_params())
            # Delete the requires config value to see if the method tries to
            # access it. Expect KeyError
            with self.assertRaises(KeyError):
                del current_app.config['DEPENDENCIES']['POSTGRES']
                PostgresProvisioner.get_cli_params()
    def get_cli_params():
        """
        finds the command line parameters necessary to pass to `psql`
        :returns string containing psql-specifically formatted params
        """
        try:
            config = current_app.config
        except RuntimeError:  # Outside of application context
            config = create_app().config
        config = config['DEPENDENCIES']['CONSUL']

        cli = "{port}".format(
            port=config.get('PORT', 8500),
        )

        return cli
 def test_get_boto_session(self, Session):
     """
     get_boto_session should call Session with the current app's config
     """
     instance = Session.return_value
     app_ = app.create_app()
     app_.config["AWS_REGION"] = "unittest-region"
     app_.config["AWS_ACCESS_KEY"] = "unittest-access"
     app_.config["AWS_SECRET_KEY"] = "unittest-secret"
     with self.assertRaises(RuntimeError):  # app-context must be available
         get_boto_session()
     with app_.app_context():
         get_boto_session()
     Session.assert_called_with(
         aws_access_key_id="unittest-access", aws_secret_access_key="unittest-secret", region_name="unittest-region"
     )
Exemple #14
0
 def test_get_boto_session(self, Session):
     """
     get_boto_session should call Session with the current app's config
     """
     app_ = app.create_app()
     app_.config['AWS_REGION'] = "unittest-region"
     app_.config['AWS_ACCESS_KEY'] = "unittest-access"
     app_.config['AWS_SECRET_KEY'] = "unittest-secret"
     with self.assertRaises(RuntimeError):  # app-context must be available
         get_boto_session()
     with app_.app_context():
         get_boto_session()
     Session.assert_called_with(
         aws_access_key_id="unittest-access",
         aws_secret_access_key="unittest-secret",
         region_name="unittest-region",
     )
    def test_get_database_params(self):
        """
        This @statmicmethod should return a dictionary.
        The function should work both with and without and application context.
        It retreives the relevant parameters from postgres, for consul.
        """

        db = ConsulProvisioner.get_db_params()
        self.assertIsInstance(db, dict)

        with create_app().app_context():
            self.assertEqual(db, ConsulProvisioner.get_db_params())
            # Delete the requires config value to see if the method tries to
            # access it. Expect KeyError
            with self.assertRaises(KeyError):
                del current_app.config["DEPENDENCIES"]["POSTGRES"]
                ConsulProvisioner.get_db_params()
    def get_cli_params():
        """
        finds the command line parameters necessary to pass to `psql`
        :returns string containing psql-specifically formatted params
        """
        try:
            config = current_app.config
        except RuntimeError:  # Outside of application context
            config = create_app().config
        config = config['DEPENDENCIES']['POSTGRES']

        cli = "--username {username} --port {port} --host {host}".format(
            username=config.get('USERNAME', 'postgres'),
            port=config.get('PORT', 5432),
            host=config.get('HOST', 'localhost'),
        )

        return cli
    def get_cli_params():
        """
        finds the command line parameters necessary to pass to `psql`
        :returns string containing psql-specifically formatted params
        """
        try:
            config = current_app.config
        except RuntimeError:  # Outside of application context
            config = create_app().config
        config = config['DEPENDENCIES']['POSTGRES']

        cli = "--username {username} --port {port} --host {host}".format(
            username=config.get('USERNAME', 'postgres'),
            port=config.get('PORT', 5432),
            host=config.get('HOST', 'localhost'),
        )

        return cli
# -*- coding: utf-8 -*-
"""
    wsgi
    ~~~~

    entrypoint wsgi script
"""

from werkzeug.serving import run_simple
from mc import app

application = app.create_app()

if __name__ == "__main__":
    run_simple("0.0.0.0", 4000, application, use_reloader=False, use_debugger=True)
Exemple #19
0
 def create_app(self):
     app = create_app()
     app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///"
     return app
Exemple #20
0
 def test_create_celery(self):
     a = app.create_app(name='unittest')
     celery = app.create_celery(app=a)
     self.assertIsInstance(celery, Celery)
     self.assertEqual(celery.main, 'unittest')
 def create_app(self):
     app_ = app.create_app()
     app_.config['SQLALCHEMY_DATABASE_URI'] = "sqlite://"
     app_.config['MC_LOGGING'] = {}
     return app_
 def test_create_app(self):
     a = app.create_app(name='unittest')
     self.assertIsInstance(a, Flask)
     self.assertEqual(a.import_name, 'unittest')
Exemple #23
0
 def create_app(self):
     return app.create_app()
Exemple #24
0
 def create_app(self):
     return create_app()
 def create_app(self):
     return app.create_app()
Exemple #26
0
 def test_create_app(self):
     a = app.create_app(name='unittest')
     self.assertIsInstance(a, Flask)
     self.assertEqual(a.import_name, 'unittest')
Exemple #27
0
PROJECT_HOME = os.path.abspath(
    os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(PROJECT_HOME)
from dateutil import parser
import requests
from flask.ext.script import Manager, Command, Option
from flask.ext.migrate import Migrate, MigrateCommand
from flask import current_app
from mc.models import db, Build, Commit
from mc.app import create_app
from mc.tasks import build_docker, register_task_revision, update_service, run_task
from mc.builders import ECSBuilder
from sqlalchemy import or_
from sqlalchemy.orm.exc import NoResultFound

app = create_app()
migrate = Migrate(app, db)
manager = Manager(app)


class CreateDatabase(Command):
    """
    Creates the database based on models.py
    """

    def run(self):
        with app.app_context():
            db.create_all()


class BuildDockerImage(Command):
Exemple #28
0
# -*- coding: utf-8 -*-
"""
    wsgi
    ~~~~

    entrypoint wsgi script
"""

from werkzeug.serving import run_simple
from mc import app

application = app.create_app()

if __name__ == "__main__":
    run_simple(
        '0.0.0.0', 4000, application, use_reloader=False, use_debugger=True
    )
Exemple #29
0
 def create_app(self):
     app_ = app.create_app()
     app_.config['SQLALCHEMY_DATABASE_URI'] = "sqlite://"
     app_.config['MC_LOGGING'] = {}
     return app_
PROJECT_HOME = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(PROJECT_HOME)
from dateutil import parser
import requests
from flask.ext.script import Manager, Command, Option
from flask.ext.migrate import Migrate, MigrateCommand
from flask import current_app
from mc.models import db, Build, Commit
from mc.app import create_app
from mc.tasks import build_docker, register_task_revision, update_service, \
    start_test_environment, stop_test_environment, run_ci_test, run_task
from mc.builders import ECSBuilder
from sqlalchemy import or_
from sqlalchemy.orm.exc import NoResultFound

app = create_app()
migrate = Migrate(app, db)
manager = Manager(app)


class ManageTestCluster(Command):
    """
    Script to allow the management of the test cluster
    """
    option_list = (
        Option('--command',
               '-c',
               dest='command',
               choices=['start', 'stop', 'run'],
               required=True),
        Option('--id', '-i', dest='test_id', required=False, default=None),
 def create_app(self):
     app = create_app()
     app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///"
     return app
 def test_create_celery(self):
     a = app.create_app(name='unittest')
     celery = app.create_celery(app=a)
     self.assertIsInstance(celery, Celery)
     self.assertEqual(celery.main, 'unittest')
 def create_app(self):
     return create_app()