def create_app(config_path): """ Factory pattern to create different app instances. Currently only supports INI files as input. """ app = Flask(__name__, template_folder="blueprints/templates", static_folder="blueprints/static") app.register_blueprint(api) app.register_blueprint(web_app) app.before_request(unmunge_request) app.before_request(extract_action_log) app.after_request(munge_response) config = ConfigParser() config.read(config_path) app.config['DEBUG'] = config.get('flask', 'DEBUG') app.config['SERVER_ADDRESS'] = config.get('flask', 'SERVER_ADDRESS') app.config['ERROR_INCLUDE_MESSAGE'] = False app.config['JSONIFY_PRETTYPRINT_REGULAR'] = False app.config['APPLICATION'] = Application(controller_mailbox=mailbox) socketio.init_app(app) # set_error_handlers(app) return app
import json import pytest from application.application_adapter import Application from application.system.user import User from exceptions.user_not_found_exception import UserNotFoundException from tests.application.mockups.search_handler_test_mockup import SearchHandler from tests.application.mockups.master_test_mockup import Master from exceptions.user_not_found_exception import UserNotFoundException app = Application(SearchHandler(), Master()) """ Component test! For /SAxx0/ notation see documentation/Qualitätssicherung.pdf """ def test_get_credentials_by_user(): """ /SA710/ """ try: user = User.get_user_by_username("creduser") except UserNotFoundException: user = User("creduser", "token123") request = { "username": "******", } json_string = json.dumps(request)
def flask_app(): app = create_app() app.config['ADAPTER'] = Application() app.testing= True return app.test_client()