コード例 #1
0
class BaseTest:
    def alter_config(self):
        pass

    def setup_method(self, test_method):
        # config
        self.config = Config()
        self.config.load_user_config()
        self.alter_config()
コード例 #2
0
 def setup_method(self, test_method):
     # config
     self.config = Config()
     self.config.load_user_config()
     self.alter_config()
     # database
     self.database = DataBase(config=self.config)
     self.database.delete_tables()
     self.database.create_tables()
     # signals
     _reset_signals()
     setup_signals(self.config, self.database)
コード例 #3
0
 def setup_method(self, test_method):
     # config
     self.config = Config()
     self.config.load_user_config()
     self.alter_config()
     # database
     self.database = DataBase(config=self.config)
     self.database.delete_tables()
     self.database.create_tables()
     # signals
     _reset_signals()
     # don't call - setup_signals(self.config, self.database) - create_app will
     # flask app
     self.webapp = create_app(config=self.config)
     self.webapp.config['TESTING'] = True
     self.flaskclient = self.webapp.test_client()
コード例 #4
0
def create_app(config=None):
    if not config:
        config = Config()
        config.load_user_config()

    if config.sentry_dsn:
        sentry_sdk.init(dsn=config.sentry_dsn,
                        integrations=[FlaskIntegration()])

    logging_config_file_full_path = os.path.expanduser(
        '~/.config/ocdskingfisher-process/logging.json')
    if os.path.isfile(logging_config_file_full_path):
        with open(logging_config_file_full_path) as f:
            logging.config.dictConfig(json.load(f))

    database = DataBase(config=config)

    ocdskingfisherprocess.signals.signals.setup_signals(config, database)

    app = Flask(__name__)
    app.kingfisher_config = config
    app.kingfisher_database = database
    app.kingfisher_web_logger = logging.getLogger('ocdskingfisher.web')

    app.add_url_rule('/', view_func=hello)
    app.add_url_rule('/robots.txt', view_func=robots_txt)
    app.add_url_rule('/api', view_func=api)

    app.add_url_rule('/prometheus', view_func=prometheus_index)
    app.add_url_rule('/prometheus/metrics', view_func=prometheus_metrics)

    app.add_url_rule('/app', view_func=app_index)
    app.add_url_rule('/app/collection', view_func=app_collections)
    app.add_url_rule('/app/collection/<collection_id>',
                     view_func=app_collection_index)
    app.add_url_rule('/app/collection/<collection_id>/file',
                     view_func=app_collection_files)

    app.add_url_rule('/api/v1/',
                     view_func=views_api_v1.RootV1View.as_view('api_v1_root'))
    app.add_url_rule(
        '/api/v1/submit/end_collection_store/',
        view_func=views_api_v1.SubmitEndCollectionStoreView.as_view(
            'api_v1_submit_end_collection_store'))
    app.add_url_rule(
        '/api/v1/submit/file/',
        view_func=views_api_v1.SubmitFileView.as_view('api_v1_submit_file'))
    app.add_url_rule(
        '/api/v1/submit/item/',
        view_func=views_api_v1.SubmitItemView.as_view('api_v1_submit_item'))
    app.add_url_rule('/api/v1/submit/file_errors/',
                     view_func=views_api_v1.SubmitFileErrorsView.as_view(
                         'api_v1_submit_file_errors'))

    return app
コード例 #5
0
 def setup_method(self, test_method):
     # config
     self.config = Config()
     self.config.load_user_config()
     self.alter_config()
コード例 #6
0
from __future__ import with_statement

from alembic import context
from sqlalchemy import engine_from_config, pool

from ocdskingfisherprocess.config import Config

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config

kingfisher_config = Config()
kingfisher_config.load_user_config()

config.set_main_option("sqlalchemy.url", kingfisher_config.database_uri)

# We do NOT set up logging here; our command line tool already does that.
# Also if this code is being used as a library, it's up to the calling code to configure logging, not us.

# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
target_metadata = None

# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.