<commit_before>import os
import pytest

from hadoop_env_config import env_config

def get_abspath_test_path():

    return os.path.dirname(os.path.abspath(__file__))

def get_settings_path():

    return os.path.join(get_abspath_test_path(), 'resources/settings/')


@pytest.fixture(params=['hdp-with-server.settings', 'hdp-wo-server.settings'])
def hdp_settings_path(request):

    return os.path.join(get_settings_path(), request.param)


@pytest.fixture(params=['hdp-with-server.settings', 'hdp-wo-server.settings'])
def hdp_settings_path(request):

    return os.path.join(get_settings_path(), request.param)


def test_env_config_undefined_settings():

    with pytest.raises(env_config.UndefinedSettingsFile):
        conf = env_config.HadoopEnvConfig(None)


def test_env_config_empty_settings():

    with pytest.raises(env_config.IncorrectJsonFormat):
        conf = env_config.HadoopEnvConfig(os.path.join(get_settings_path(), 'empty.settings'))

def test_env_config_incorrect_path_to_settings():

    with pytest.raises(env_config.IncorrectJsonFormat):
        conf = env_config.HadoopEnvConfig(os.path.join(get_settings_path(), 'shadow.settings'))


# def test_env_config_prepare_settings(hdp_settings_path):
#
#     conf = env_config.HadoopEnvConfig(hdp_settings_path)
#     assert 0
<commit_msg>[*] refactoring of reading json files<commit_after>import os
import pytest

from hadoop_env_config import env_config

def get_abspath_test_path():

    return os.path.dirname(os.path.abspath(__file__))

def get_settings_path():

    return os.path.join(get_abspath_test_path(), 'resources/settings/')


@pytest.fixture(params=['hdp-with-server.settings', 'hdp-wo-server.settings'])
def hdp_settings_path(request):

    return os.path.join(get_settings_path(), request.param)


@pytest.fixture(params=['hdp-with-server.settings', 'hdp-wo-server.settings'])
def hdp_settings_path(request):

    return os.path.join(get_settings_path(), request.param)


def test_env_config_undefined_settings():

    with pytest.raises(env_config.UndefinedSettingsFile):
        conf = env_config.HadoopEnvConfig(None)


def test_env_config_empty_settings():

    with pytest.raises(env_config.IncorrectJsonFormat):
        conf = env_config.HadoopEnvConfig(os.path.join(get_settings_path(), 'empty.settings'))

def test_env_config_incorrect_path_to_settings():

    with pytest.raises(env_config.IncorrectJsonFormat):
        conf = env_config.HadoopEnvConfig(os.path.join(get_settings_path(), 'shadow.settings'))


def test_env_config_prepare_settings(hdp_settings_path):

    conf = env_config.HadoopEnvConfig(hdp_settings_path)
    print conf
    assert 0

{'fraction_non_alphanumeric': 0.11509433962264151, 'fraction_numerical': 0.0007547169811320754, 'mean_word_length': 5.814910025706941, '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': '4406942', 'n_tokens_mistral': 924, 'n_tokens_neox': 899, 'n_words': 121}