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 )
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'], {})
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_
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
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_
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_
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_
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)
""" 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)
# -*- 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 )
# -*- 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)
""" 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()