def app(): """Return a session-wide application configured in TEST mode.""" # _app = create_app('testing') _app = Flask(__name__) _app.config.from_object(get_named_config('testing')) db.init_app(_app) return _app
import os import nats from entity_queue_common.messages import create_filing_msg from entity_queue_common.service import QueueServiceManager from entity_queue_common.service_utils import FilingException, QueueException, logger from flask import Flask from legal_api import db from legal_api.models import Filing from sentry_sdk import capture_message from sqlalchemy.exc import OperationalError from entity_pay import config qsm = QueueServiceManager() # pylint: disable=invalid-name APP_CONFIG = config.get_named_config(os.getenv('DEPLOYMENT_ENV', 'production')) FLASK_APP = Flask(__name__) FLASK_APP.config.from_object(APP_CONFIG) db.init_app(FLASK_APP) def extract_payment_token(msg: nats.aio.client.Msg) -> dict: """Return a dict of the json string in the Msg.data.""" return json.loads(msg.data.decode('utf-8')) def get_filing_by_payment_id(payment_id: int) -> Filing: """Return the outcome of Filing.get_filing_by_payment_token.""" return Filing.get_filing_by_payment_token(str(payment_id))