def get_test_prodapi_app(extra_config=None): """ Create and return configured test prod api flask app. :param extra_config: extra settings :return: eve.flaskapp.Eve """ test_config = { 'DEBUG': True, 'TESTING': True, 'SUPERDESK_TESTING': True, 'MONGO_CONNECT': False, 'MONGO_MAX_POOL_SIZE': 1, 'MONGO_DBNAME': MONGO_DB, 'MONGO_URI': get_mongo_uri('MONGO_URI', MONGO_DB), 'ELASTICSEARCH_INDEX': ELASTICSEARCH_INDEX, 'PRODAPI_URL': 'http://localhost:5500', 'MEDIA_PREFIX': 'http://localhost:5500/prodapi/v1/assets', 'PRODAPI_URL_PREFIX': 'prodapi', 'URL_PREFIX': 'prodapi', 'AUTH_SERVER_SHARED_SECRET': AUTH_SERVER_SHARED_SECRET } if extra_config: test_config.update(extra_config) prodapi_app = get_prodapi_api(test_config) # put elastic mapping with prodapi_app.app_context(): prodapi_app.data.elastic.init_index() return prodapi_app
def get_test_prodapi_app(extra_config=None): """ Create and return configured test prod api flask app. :param extra_config: extra settings :return: eve.flaskapp.Eve """ test_config = { "DEBUG": True, "TESTING": True, "SUPERDESK_TESTING": True, "MONGO_CONNECT": False, "MONGO_MAX_POOL_SIZE": 1, "MONGO_DBNAME": MONGO_DB, "MONGO_URI": get_mongo_uri("MONGO_URI", MONGO_DB), "ELASTICSEARCH_INDEX": ELASTICSEARCH_INDEX, "PRODAPI_URL": "http://localhost:5500", "MEDIA_PREFIX": "http://localhost:5500/prodapi/v1/assets", "PRODAPI_URL_PREFIX": "prodapi", "URL_PREFIX": "prodapi", "AUTH_SERVER_SHARED_SECRET": AUTH_SERVER_SHARED_SECRET, } if extra_config: test_config.update(extra_config) prodapi_app = get_prodapi_api(test_config) # put elastic mapping with prodapi_app.app_context(): prodapi_app.data.elastic.init_index() return prodapi_app
def get_test_superdesk_app(extra_config=None): """ Create and return configured test superdesk flask app. :param extra_config: extra settings :return: eve.flaskapp.Eve """ test_config = { 'MONGO_URI': get_mongo_uri('MONGO_URI', MONGO_DB), 'ELASTICSEARCH_INDEX': ELASTICSEARCH_INDEX, 'AUTH_SERVER_SHARED_SECRET': AUTH_SERVER_SHARED_SECRET, } if extra_config: test_config.update(extra_config) def context(): pass context.app = None context.ctx = None context.client = None setup(context=context, config=test_config, app_factory=get_sd_app) return context.app
def get_test_prodapi_app(extra_config=None): """ Create and return configured test prod api flask app. :param extra_config: extra settings :return: eve.flaskapp.Eve """ test_config = { "DEBUG": True, "TESTING": True, "SUPERDESK_TESTING": True, "MONGO_CONNECT": False, "MONGO_MAX_POOL_SIZE": 1, "MONGO_DBNAME": MONGO_DB, "MONGO_URI": get_mongo_uri("MONGO_URI", MONGO_DB), "ELASTICSEARCH_INDEX": ELASTICSEARCH_INDEX, "PRODAPI_URL": "http://localhost:5500", "MEDIA_PREFIX": "http://localhost:5500/prodapi/v1/assets", "PRODAPI_URL_PREFIX": "prodapi", "URL_PREFIX": "prodapi", "AUTH_SERVER_SHARED_SECRET": AUTH_SERVER_SHARED_SECRET, } if extra_config: test_config.update(extra_config) prodapi_app = get_prodapi_api(test_config) # patch Events API with dates schema # otherwise queries against it will fail (due to default sort) # this will not happen in a production environment # as the index/types should already be created EventsResource.schema = {"dates": events_schema["dates"]} # put elastic mapping with prodapi_app.app_context(): prodapi_app.data.elastic.init_index() return prodapi_app