コード例 #1
0
ファイル: test_app.py プロジェクト: ehenneken/harbour-service
    def test_load_s3_create_app_mongo_load_success(self):
        """
        Test that when the application is created, that the mongo user data
        is loaded from s3, if available.
        """
        stub_mongogut_users = {
            '*****@*****.**': 'cb16a523-cdba-406b-bfff-edfd428248be.json'
        }

        s3_resource = boto3.resource('s3')
        s3_resource.create_bucket(Bucket='adsabs-mongogut')
        bucket = s3_resource.Bucket('adsabs-mongogut')

        # First is libraries
        bucket.put_object(
            Key='users.json',
            Body=json.dumps(stub_mongogut_users)
        )

        app = create_app()

        self.assertTrue(app.config['ADS_TWO_POINT_OH_LOADED_USERS'])
        self.assertEqual(
            app.config['ADS_TWO_POINT_OH_USERS'],
            stub_mongogut_users
        )
コード例 #2
0
    def test_load_s3_create_app_mongo_load_success(self, mock_resource):
        """
        Test that when the application is created, that the mongo user data
        is loaded from s3, if available.
        """
        mock_resource.side_effect = Exception

        app = create_app()

        self.assertFalse(app.config['ADS_TWO_POINT_OH_LOADED_USERS'])
        self.assertEqual(app.config['ADS_TWO_POINT_OH_USERS'], {})
コード例 #3
0
ファイル: test_app.py プロジェクト: ehenneken/harbour-service
    def test_load_s3_create_app_mongo_load_success(self, mock_resource):
        """
        Test that when the application is created, that the mongo user data
        is loaded from s3, if available.
        """
        mock_resource.side_effect = Exception

        app = create_app()

        self.assertFalse(app.config['ADS_TWO_POINT_OH_LOADED_USERS'])
        self.assertEqual(app.config['ADS_TWO_POINT_OH_USERS'], {})
コード例 #4
0
ファイル: base.py プロジェクト: ehenneken/harbour-service
    def create_app(self):
        """
        Create the wsgi application
        """
        app_ = app.create_app()
        app_.config['CLASSIC_LOGGING'] = {}
        app_.config['SQLALCHEMY_BINDS'] = {}
        app_.config['ADS_CLASSIC_MIRROR_LIST'] = [
            'mirror.com', 'other.mirror.com'
        ]
        app_.config['ADS_TWO_POINT_OH_MIRROR'] = 'mirror.com'
        app_.config['SQLALCHEMY_BINDS']['harbour'] = \
            TestBaseDatabase.postgresql_url

        return app_
コード例 #5
0
    def create_app(self):
        """
        Create the wsgi application
        """
        app_ = app.create_app()
        app_.config['CLASSIC_LOGGING'] = {}
        app_.config['SQLALCHEMY_BINDS'] = {}
        app_.config['ADS_CLASSIC_MIRROR_LIST'] = [
            'mirror.com', 'other.mirror.com'
        ]
        app_.config['ADS_TWO_POINT_OH_MIRROR'] = 'mirror.com'
        app_.config['SQLALCHEMY_BINDS']['harbour'] = \
            TestBaseDatabase.postgresql_url

        return app_
コード例 #6
0
ファイル: base.py プロジェクト: marblestation/harbour-service
 def create_app(self):
     """
     Create the wsgi application
     """
     a = app.create_app(
         **{
             'CLASSIC_LOGGING': {},
             'ADS_CLASSIC_MIRROR_LIST': ['mirror.com', 'other.mirror.com'],
             'ADS_TWO_POINT_OH_MIRROR': 'mirror.com',
             'SQLALCHEMY_DATABASE_URI': TestBaseDatabase.postgresql_url,
             'SQLALCHEMY_ECHO': True,
             'TESTING': True,
             'PROPAGATE_EXCEPTIONS': True,
             'TRAP_BAD_REQUEST_ERRORS': True,
             'SOLR_SERVICE_DISALLOWED_FIELDS': ['full', 'bar']
         })
     return a
コード例 #7
0
    def create_app(self):
        """
        Create the wsgi application
        """
        # Setup S3 mock data
        TestADSTwoPointOhLibraries.helper_s3_mock_setup()

        # Setup the app
        app_ = create_app()
        app_.config['CLASSIC_LOGGING'] = {}
        app_.config['SQLALCHEMY_BINDS'] = {}
        app_.config['ADS_CLASSIC_MIRROR_LIST'] = [
            'mirror.com', 'other.mirror.com'
        ]
        app_.config['SQLALCHEMY_BINDS']['harbour'] = \
            TestBaseDatabase.postgresql_url

        return app_
コード例 #8
0
    def create_app(self):
        """
        Create the wsgi application
        """
        # Setup S3 mock data
        TestADSTwoPointOhLibraries.helper_s3_mock_setup()

        # Setup the app
        app_ = create_app()
        app_.config['CLASSIC_LOGGING'] = {}
        app_.config['SQLALCHEMY_BINDS'] = {}
        app_.config['ADS_CLASSIC_MIRROR_LIST'] = [
            'mirror.com', 'other.mirror.com'
        ]
        app_.config['SQLALCHEMY_BINDS']['harbour'] = \
            TestBaseDatabase.postgresql_url

        return app_
コード例 #9
0
    def create_app(self):
        """
        Create the wsgi application
        """
        # Setup S3 mock data
        TestExportADSTwoPointOhLibraries.helper_s3_mock_setup()

        # Setup the app
        app_ = create_app()
        app_.config['CLASSIC_LOGGING'] = {}
        app_.config['SQLALCHEMY_BINDS'] = {}

        app_.config['ADS_CLASSIC_MIRROR_LIST'] = [
            'mirror.com', 'other.mirror.com'
        ]
        app_.config['SQLALCHEMY_BINDS']['harbour'] = \
            TestBaseDatabase.postgresql_url
        app_.config['HARBOUR_EXPORT_SERVICE_URL'] = 'http://fakeapi.adsabs'
        app_.config['SQLALCHEMY_DATABASE_URI'] = app_.config['SQLALCHEMY_BINDS']['harbour']
        return app_
コード例 #10
0
    def create_app(self):
        """
        Create the wsgi application
        """
        # Setup S3 mock data
        TestExportADSTwoPointOhLibraries.helper_s3_mock_setup()

        # Setup the app
        app_ = create_app()
        app_.config['CLASSIC_LOGGING'] = {}
        app_.config['SQLALCHEMY_BINDS'] = {}

        app_.config['ADS_CLASSIC_MIRROR_LIST'] = [
            'mirror.com', 'other.mirror.com'
        ]
        app_.config['SQLALCHEMY_BINDS']['harbour'] = \
            TestBaseDatabase.postgresql_url
        app_.config['HARBOUR_EXPORT_SERVICE_URL'] = 'http://fakeapi.adsabs'
        app_.config['SQLALCHEMY_DATABASE_URI'] = app_.config[
            'SQLALCHEMY_BINDS']['harbour']
        return app_
コード例 #11
0
    def test_load_s3_create_app_mongo_load_success(self):
        """
        Test that when the application is created, that the mongo user data
        is loaded from s3, if available.
        """
        stub_mongogut_users = {
            '*****@*****.**': 'cb16a523-cdba-406b-bfff-edfd428248be.json'
        }

        s3_resource = boto3.resource('s3')
        s3_resource.create_bucket(Bucket='adsabs-mongogut')
        bucket = s3_resource.Bucket('adsabs-mongogut')

        # First is libraries
        bucket.put_object(Key='users.json',
                          Body=json.dumps(stub_mongogut_users))

        app = create_app()

        self.assertTrue(app.config['ADS_TWO_POINT_OH_LOADED_USERS'])
        self.assertEqual(app.config['ADS_TWO_POINT_OH_USERS'],
                         stub_mongogut_users)
コード例 #12
0
ファイル: manage.py プロジェクト: golnazads/harbour-service
"""
General manage commands for the harbour-service
"""
import os
import sys
PROJECT_HOME = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(PROJECT_HOME)

from flask_script import Manager, Command
from flask_migrate import Migrate, MigrateCommand
from harbour.models import Base
from harbour.app import create_app

# Load the app with the factory
app = create_app()


class CreateDatabase(Command):
    """
    Creates the database based on models.py
    """
    @staticmethod
    def run(app=app):
        """
        Creates the database in the application context
        :return: no return
        """
        with app.app_context():
            Base.metadata.create_all(bind=app.db.engine)

コード例 #13
0
ファイル: wsgi.py プロジェクト: ehenneken/harbour-service
# -*- coding: utf-8 -*-
"""
    wsgi
    ~~~~

    entrypoint wsgi script
"""

from werkzeug.serving import run_simple
from harbour import app

application = app.create_app()

if __name__ == "__main__":
    run_simple(
        '0.0.0.0', 4000, application, use_reloader=False, use_debugger=True
    )
コード例 #14
0
# -*- coding: utf-8 -*-
"""
    wsgi
    ~~~~

    entrypoint wsgi script
"""

from werkzeug.serving import run_simple
from harbour import app

application = app.create_app()

if __name__ == "__main__":
    run_simple('0.0.0.0',
               4000,
               application,
               use_reloader=False,
               use_debugger=True)
コード例 #15
0
ファイル: manage.py プロジェクト: ehenneken/harbour-service
"""
General manage commands for the harbour-service
"""
import os
import sys
PROJECT_HOME = os.path.abspath(
    os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(PROJECT_HOME)

from flask.ext.script import Manager, Command
from flask.ext.migrate import Migrate, MigrateCommand
from models import db
from harbour.app import create_app

# Load the app with the factory
app = create_app()


class CreateDatabase(Command):
    """
    Creates the database based on models.py
    """
    @staticmethod
    def run(app=app):
        """
        Creates the database in the application context
        :return: no return
        """
        with app.app_context():
            db.create_all()
            db.session.commit()