<commit_before>import flask
import pytest

import util
import indexd

from indexd.index.errors import IndexConfigurationError
from indexd.alias.errors import AliasConfigurationError

from indexd.index.sqlite import SQLiteIndexDriver
from indexd.alias.sqlite import SQLiteAliasDriver


INDEX_CONFIG = {
    'driver': SQLiteIndexDriver,
    'SQLITE3': {
        'host': 'index.sq3',
    }
}

ALIAS_CONFIG = {
    'driver': SQLiteAliasDriver,
    'SQLITE3': {
        'host': 'alias.sq3',
    }
}

@util.removes(INDEX_CONFIG['SQLITE3']['host'])
@util.removes(ALIAS_CONFIG['SQLITE3']['host'])
def test_flask_blueprint():
    '''
    Tests standing up the server using flask.
    '''
    app = flask.Flask(__name__)

    app.config['INDEX'] = INDEX_CONFIG
    app.config['ALIAS'] = ALIAS_CONFIG

    app.register_blueprint(indexd.index_blueprint)
    app.register_blueprint(indexd.alias_blueprint)

@util.removes(ALIAS_CONFIG['SQLITE3']['host'])
def test_flask_blueprint_missing_index_config():
    '''
    Tests standing up the server using flask without an index config.
    '''
    app = flask.Flask(__name__)

    app.config['ALIAS'] = ALIAS_CONFIG

    with pytest.raises(IndexConfigurationError):
        app.register_blueprint(indexd.index_blueprint)

    app.register_blueprint(indexd.alias_blueprint)

@util.removes(ALIAS_CONFIG['SQLITE3']['host'])
def test_flask_blueprint_invalid_index_config():
    '''
    Tests standing up the server using flask without an index config.
    '''
    app = flask.Flask(__name__)

    app.config['INDEX'] = None
    app.config['ALIAS'] = ALIAS_CONFIG

    with pytest.raises(IndexConfigurationError):
        app.register_blueprint(indexd.index_blueprint)

    app.register_blueprint(indexd.alias_blueprint)

@util.removes(INDEX_CONFIG['SQLITE3']['host'])
def test_flask_blueprint_missing_alias_config():
    '''
    Tests standing up the server using flask without an alias config.
    '''
    app = flask.Flask(__name__)

    app.config['INDEX'] = INDEX_CONFIG

    with pytest.raises(AliasConfigurationError):
        app.register_blueprint(indexd.alias_blueprint)

    app.register_blueprint(indexd.index_blueprint)

@util.removes(INDEX_CONFIG['SQLITE3']['host'])
def test_flask_blueprint_invalid_alias_config():
    '''
    Tests standing up the server using flask without an alias config.
    '''
    app = flask.Flask(__name__)

    app.config['INDEX'] = INDEX_CONFIG
    app.config['ALIAS'] = None

    with pytest.raises(AliasConfigurationError):
        app.register_blueprint(indexd.alias_blueprint)

    app.register_blueprint(indexd.index_blueprint)<commit_msg>updates blueprint testing to use new ones<commit_after>import flask
import pytest

import util
import indexd

from indexd.index.blueprint import blueprint as indexd_index_blueprint
from indexd.alias.blueprint import blueprint as indexd_alias_blueprint

from indexd.index.errors import IndexConfigurationError
from indexd.alias.errors import AliasConfigurationError

from indexd.index.sqlite import SQLiteIndexDriver
from indexd.alias.sqlite import SQLiteAliasDriver


INDEX_CONFIG = {
    'driver': SQLiteIndexDriver,
    'SQLITE3': {
        'host': 'index.sq3',
    }
}

ALIAS_CONFIG = {
    'driver': SQLiteAliasDriver,
    'SQLITE3': {
        'host': 'alias.sq3',
    }
}

@util.removes(INDEX_CONFIG['SQLITE3']['host'])
@util.removes(ALIAS_CONFIG['SQLITE3']['host'])
def test_flask_blueprint():
    '''
    Tests standing up the server using flask.
    '''
    app = flask.Flask(__name__)

    app.config['INDEX'] = INDEX_CONFIG
    app.config['ALIAS'] = ALIAS_CONFIG

    app.register_blueprint(indexd_index_blueprint)
    app.register_blueprint(indexd_alias_blueprint)

@util.removes(ALIAS_CONFIG['SQLITE3']['host'])
def test_flask_blueprint_missing_index_config():
    '''
    Tests standing up the server using flask without an index config.
    '''
    app = flask.Flask(__name__)

    app.config['ALIAS'] = ALIAS_CONFIG

    with pytest.raises(IndexConfigurationError):
        app.register_blueprint(indexd_index_blueprint)

    app.register_blueprint(indexd_alias_blueprint)

@util.removes(ALIAS_CONFIG['SQLITE3']['host'])
def test_flask_blueprint_invalid_index_config():
    '''
    Tests standing up the server using flask without an index config.
    '''
    app = flask.Flask(__name__)

    app.config['INDEX'] = None
    app.config['ALIAS'] = ALIAS_CONFIG

    with pytest.raises(IndexConfigurationError):
        app.register_blueprint(indexd_index_blueprint)

    app.register_blueprint(indexd_alias_blueprint)

@util.removes(INDEX_CONFIG['SQLITE3']['host'])
def test_flask_blueprint_missing_alias_config():
    '''
    Tests standing up the server using flask without an alias config.
    '''
    app = flask.Flask(__name__)

    app.config['INDEX'] = INDEX_CONFIG

    with pytest.raises(AliasConfigurationError):
        app.register_blueprint(indexd_alias_blueprint)

    app.register_blueprint(indexd_index_blueprint)

@util.removes(INDEX_CONFIG['SQLITE3']['host'])
def test_flask_blueprint_invalid_alias_config():
    '''
    Tests standing up the server using flask without an alias config.
    '''
    app = flask.Flask(__name__)

    app.config['INDEX'] = INDEX_CONFIG
    app.config['ALIAS'] = None

    with pytest.raises(AliasConfigurationError):
        app.register_blueprint(indexd_alias_blueprint)

    app.register_blueprint(indexd_index_blueprint)
{'fraction_non_alphanumeric': 0.10816817929246157, 'fraction_numerical': 0.003704389701796629, 'mean_word_length': 4.476673427991886, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2815300', 'n_tokens_mistral': 1762, 'n_tokens_neox': 1718, 'n_words': 311}