# Path: postgraas_server/create_app.py
# def create_app(config):
#     app = Flask(__name__)
# 
#     app.config['SQLALCHEMY_DATABASE_URI'] = get_meta_db_config_path(config)
#     app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
#     app.config['BUNDLE_ERRORS'] = True
#     app_config = get_application_config(config)
# 
#     for key in app_config:
#         app.config[key.upper()] = int(app_config[key]) if key.upper() in INT_OPTIONS else app_config[key]
#     app.config['SENTRY_INCLUDE_PATHS'] = [
#         'postgraas_server',
#     ]
#     app.config['SENTRY_RELEASE'] = postgraas_server.__version__
#     sentry.init_app(app)
# 
#     restful_api = Api(app)
#     restful_api.add_resource(DBInstanceResource, "/api/v2/postgraas_instances/<int:id>")
#     restful_api.add_resource(DBInstanceCollectionResource, "/api/v2/postgraas_instances")
#     db.init_app(app)
#     app.postgraas_backend = get_backend(config)
# 
#     @app.route('/health')
#     def health():
#         return "ok"
# 
#     return app


import os
import uuid
import json
import pytest
import postgraas_server.configuration as configuration
import postgraas_server.backends.postgres_cluster.postgres_cluster_driver as pgcd
    from StringIO import StringIO
    from io import StringIO
from postgraas_server.create_app import create_app
    from postgraas_server.management_resources import db
        "username": os.environ.get('PGUSER', 'postgres'),
        "password": os.environ.get('PGPASSWORD', 'postgres'),
    }
}

CONFIGS = {
    'pg_cluster': CLUSTER_CONFIG,
}


def remove_digits(s):
    return ''.join(c for c in s if not c.isdigit())


def delete_test_database_and_user(db_name, username, config):
    try:
        pgcd.delete_database(db_name, config)
    except ValueError as e:
        pass
        # print(ValueError(e.args[0]))
    try:
        pgcd.delete_user(username, config)
    except ValueError as e:
        pass
        # print(ValueError(e.args[0]))


@pytest.fixture(params=['pg_cluster'])
def parametrized_setup(request, tmpdir):
    config = CONFIGS[request.param]

# Path: postgraas_server/create_app.py
# def create_app(config):
#     app = Flask(__name__)
# 
#     app.config['SQLALCHEMY_DATABASE_URI'] = get_meta_db_config_path(config)
#     app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
#     app.config['BUNDLE_ERRORS'] = True
#     app_config = get_application_config(config)
# 
#     for key in app_config:
#         app.config[key.upper()] = int(app_config[key]) if key.upper() in INT_OPTIONS else app_config[key]
#     app.config['SENTRY_INCLUDE_PATHS'] = [
#         'postgraas_server',
#     ]
#     app.config['SENTRY_RELEASE'] = postgraas_server.__version__
#     sentry.init_app(app)
# 
#     restful_api = Api(app)
#     restful_api.add_resource(DBInstanceResource, "/api/v2/postgraas_instances/<int:id>")
#     restful_api.add_resource(DBInstanceCollectionResource, "/api/v2/postgraas_instances")
#     db.init_app(app)
#     app.postgraas_backend = get_backend(config)
# 
#     @app.route('/health')
#     def health():
#         return "ok"
# 
#     return app


# Path: tests/test_integration/backends/postgres_cluster/test_postgres_cluster_driver.py
import os
import uuid
import json
import pytest
import postgraas_server.configuration as configuration
import postgraas_server.backends.postgres_cluster.postgres_cluster_driver as pgcd
    from StringIO import StringIO
    from io import StringIO
from postgraas_server.create_app import create_app
    from postgraas_server.management_resources import db

        "username": os.environ.get('PGUSER', 'postgres'),
        "password": os.environ.get('PGPASSWORD', 'postgres'),
    }
}

CONFIGS = {
    'pg_cluster': CLUSTER_CONFIG,
}


def remove_digits(s):
    return ''.join(c for c in s if not c.isdigit())


def delete_test_database_and_user(db_name, username, config):
    try:
        pgcd.delete_database(db_name, config)
    except ValueError as e:
        pass
        # print(ValueError(e.args[0]))
    try:
        pgcd.delete_user(username, config)
    except ValueError as e:
        pass
        # print(ValueError(e.args[0]))


@pytest.fixture(params=['pg_cluster'])
def parametrized_setup(request, tmpdir):
    config = CONFIGS[request.param]

    this_app = create_app(config)