# Path: thefuck/const.py
# class _GenConst(object):
#     def __init__(self, name):
#     def __repr__(self):
# KEY_UP = _GenConst('↑')
# KEY_DOWN = _GenConst('↓')
# KEY_CTRL_C = _GenConst('Ctrl+C')
# KEY_CTRL_N = _GenConst('Ctrl+N')
# KEY_CTRL_P = _GenConst('Ctrl+P')
# KEY_MAPPING = {'\x0e': KEY_CTRL_N,
#                '\x03': KEY_CTRL_C,
#                '\x10': KEY_CTRL_P}
# ACTION_SELECT = _GenConst('select')
# ACTION_ABORT = _GenConst('abort')
# ACTION_PREVIOUS = _GenConst('previous')
# ACTION_NEXT = _GenConst('next')
# ALL_ENABLED = _GenConst('All rules enabled')
# DEFAULT_RULES = [ALL_ENABLED]
# DEFAULT_PRIORITY = 1000
# DEFAULT_SETTINGS = {'rules': DEFAULT_RULES,
#                     'exclude_rules': [],
#                     'wait_command': 3,
#                     'require_confirmation': True,
#                     'no_colors': False,
#                     'debug': False,
#                     'priority': {},
#                     'history_limit': None,
#                     'alter_history': True,
#                     'wait_slow_command': 15,
#                     'slow_commands': ['lein', 'react-native', 'gradle',
#                                       './gradlew', 'vagrant'],
#                     'repeat': False,
#                     'instant_mode': False,
#                     'num_close_matches': 3,
#                     'env': {'LC_ALL': 'C', 'LANG': 'C', 'GIT_TRACE': '1'},
#                     'excluded_search_path_prefixes': []}
# ENV_TO_ATTR = {'THEFUCK_RULES': 'rules',
#                'THEFUCK_EXCLUDE_RULES': 'exclude_rules',
#                'THEFUCK_WAIT_COMMAND': 'wait_command',
#                'THEFUCK_REQUIRE_CONFIRMATION': 'require_confirmation',
#                'THEFUCK_NO_COLORS': 'no_colors',
#                'THEFUCK_DEBUG': 'debug',
#                'THEFUCK_PRIORITY': 'priority',
#                'THEFUCK_HISTORY_LIMIT': 'history_limit',
#                'THEFUCK_ALTER_HISTORY': 'alter_history',
#                'THEFUCK_WAIT_SLOW_COMMAND': 'wait_slow_command',
#                'THEFUCK_SLOW_COMMANDS': 'slow_commands',
#                'THEFUCK_REPEAT': 'repeat',
#                'THEFUCK_INSTANT_MODE': 'instant_mode',
#                'THEFUCK_NUM_CLOSE_MATCHES': 'num_close_matches',
#                'THEFUCK_EXCLUDED_SEARCH_PATH_PREFIXES': 'excluded_search_path_prefixes'}
# SETTINGS_HEADER = u"""# The Fuck settings file
# #
# # The rules are defined as in the example bellow:
# #
# # rules = ['cd_parent', 'git_push', 'python_command', 'sudo']
# #
# # The default values are as follows. Uncomment and change to fit your needs.
# # See https://github.com/nvbn/thefuck#settings for more information.
# #
# 
# """
# ARGUMENT_PLACEHOLDER = 'THEFUCK_ARGUMENT_PLACEHOLDER'
# CONFIGURATION_TIMEOUT = 60
# USER_COMMAND_MARK = u'\u200B' * 10
# LOG_SIZE_IN_BYTES = 1024 * 1024
# LOG_SIZE_TO_CLEAN = 10 * 1024
# DIFF_WITH_ALIAS = 0.5
# SHELL_LOGGER_SOCKET_ENV = 'SHELL_LOGGER_SOCKET'
# SHELL_LOGGER_LIMIT = 5


import pytest
import six
import os
from mock import Mock
from thefuck import const


@pytest.mark.usefixtures('load_source')
class TestSettingsFromEnv(object):
    def test_from_env(self, os_environ, settings):
        os_environ.update({'THEFUCK_RULES': 'bash:lisp',
                           'THEFUCK_EXCLUDE_RULES': 'git:vim',
                           'THEFUCK_WAIT_COMMAND': '55',
                           'THEFUCK_REQUIRE_CONFIRMATION': 'true',
                           'THEFUCK_NO_COLORS': 'false',
                           'THEFUCK_PRIORITY': 'bash=10:lisp=wrong:vim=15',
                           'THEFUCK_WAIT_SLOW_COMMAND': '999',
                           'THEFUCK_SLOW_COMMANDS': 'lein:react-native:./gradlew',
                           'THEFUCK_NUM_CLOSE_MATCHES': '359',
                           'THEFUCK_EXCLUDED_SEARCH_PATH_PREFIXES': '/media/:/mnt/'})
        settings.init()
        assert settings.rules == ['bash', 'lisp']
        assert settings.exclude_rules == ['git', 'vim']
        assert settings.wait_command == 55
        assert settings.require_confirmation is True
        assert settings.no_colors is False
        assert settings.priority == {'bash': 10, 'vim': 15}
        assert settings.wait_slow_command == 999
        assert settings.slow_commands == ['lein', 'react-native', './gradlew']
        assert settings.num_close_matches == 359
        assert settings.excluded_search_path_prefixes == ['/media/', '/mnt/']

    def test_from_env_with_DEFAULT(self, os_environ, settings):
        os_environ.update({'THEFUCK_RULES': 'DEFAULT_RULES:bash:lisp'})
        settings.init()

# Path: thefuck/const.py
# class _GenConst(object):
#     def __init__(self, name):
#     def __repr__(self):
# KEY_UP = _GenConst('↑')
# KEY_DOWN = _GenConst('↓')
# KEY_CTRL_C = _GenConst('Ctrl+C')
# KEY_CTRL_N = _GenConst('Ctrl+N')
# KEY_CTRL_P = _GenConst('Ctrl+P')
# KEY_MAPPING = {'\x0e': KEY_CTRL_N,
#                '\x03': KEY_CTRL_C,
#                '\x10': KEY_CTRL_P}
# ACTION_SELECT = _GenConst('select')
# ACTION_ABORT = _GenConst('abort')
# ACTION_PREVIOUS = _GenConst('previous')
# ACTION_NEXT = _GenConst('next')
# ALL_ENABLED = _GenConst('All rules enabled')
# DEFAULT_RULES = [ALL_ENABLED]
# DEFAULT_PRIORITY = 1000
# DEFAULT_SETTINGS = {'rules': DEFAULT_RULES,
#                     'exclude_rules': [],
#                     'wait_command': 3,
#                     'require_confirmation': True,
#                     'no_colors': False,
#                     'debug': False,
#                     'priority': {},
#                     'history_limit': None,
#                     'alter_history': True,
#                     'wait_slow_command': 15,
#                     'slow_commands': ['lein', 'react-native', 'gradle',
#                                       './gradlew', 'vagrant'],
#                     'repeat': False,
#                     'instant_mode': False,
#                     'num_close_matches': 3,
#                     'env': {'LC_ALL': 'C', 'LANG': 'C', 'GIT_TRACE': '1'},
#                     'excluded_search_path_prefixes': []}
# ENV_TO_ATTR = {'THEFUCK_RULES': 'rules',
#                'THEFUCK_EXCLUDE_RULES': 'exclude_rules',
#                'THEFUCK_WAIT_COMMAND': 'wait_command',
#                'THEFUCK_REQUIRE_CONFIRMATION': 'require_confirmation',
#                'THEFUCK_NO_COLORS': 'no_colors',
#                'THEFUCK_DEBUG': 'debug',
#                'THEFUCK_PRIORITY': 'priority',
#                'THEFUCK_HISTORY_LIMIT': 'history_limit',
#                'THEFUCK_ALTER_HISTORY': 'alter_history',
#                'THEFUCK_WAIT_SLOW_COMMAND': 'wait_slow_command',
#                'THEFUCK_SLOW_COMMANDS': 'slow_commands',
#                'THEFUCK_REPEAT': 'repeat',
#                'THEFUCK_INSTANT_MODE': 'instant_mode',
#                'THEFUCK_NUM_CLOSE_MATCHES': 'num_close_matches',
#                'THEFUCK_EXCLUDED_SEARCH_PATH_PREFIXES': 'excluded_search_path_prefixes'}
# SETTINGS_HEADER = u"""# The Fuck settings file
# #
# # The rules are defined as in the example bellow:
# #
# # rules = ['cd_parent', 'git_push', 'python_command', 'sudo']
# #
# # The default values are as follows. Uncomment and change to fit your needs.
# # See https://github.com/nvbn/thefuck#settings for more information.
# #
# 
# """
# ARGUMENT_PLACEHOLDER = 'THEFUCK_ARGUMENT_PLACEHOLDER'
# CONFIGURATION_TIMEOUT = 60
# USER_COMMAND_MARK = u'\u200B' * 10
# LOG_SIZE_IN_BYTES = 1024 * 1024
# LOG_SIZE_TO_CLEAN = 10 * 1024
# DIFF_WITH_ALIAS = 0.5
# SHELL_LOGGER_SOCKET_ENV = 'SHELL_LOGGER_SOCKET'
# SHELL_LOGGER_LIMIT = 5


# Path: tests/test_conf.py
import pytest
import six
import os
from mock import Mock
from thefuck import const



@pytest.mark.usefixtures('load_source')
class TestSettingsFromEnv(object):
    def test_from_env(self, os_environ, settings):
        os_environ.update({'THEFUCK_RULES': 'bash:lisp',
                           'THEFUCK_EXCLUDE_RULES': 'git:vim',
                           'THEFUCK_WAIT_COMMAND': '55',
                           'THEFUCK_REQUIRE_CONFIRMATION': 'true',
                           'THEFUCK_NO_COLORS': 'false',
                           'THEFUCK_PRIORITY': 'bash=10:lisp=wrong:vim=15',
                           'THEFUCK_WAIT_SLOW_COMMAND': '999',
                           'THEFUCK_SLOW_COMMANDS': 'lein:react-native:./gradlew',
                           'THEFUCK_NUM_CLOSE_MATCHES': '359',
                           'THEFUCK_EXCLUDED_SEARCH_PATH_PREFIXES': '/media/:/mnt/'})
        settings.init()
        assert settings.rules == ['bash', 'lisp']
        assert settings.exclude_rules == ['git', 'vim']
        assert settings.wait_command == 55
        assert settings.require_confirmation is True
        assert settings.no_colors is False
        assert settings.priority == {'bash': 10, 'vim': 15}
        assert settings.wait_slow_command == 999
        assert settings.slow_commands == ['lein', 'react-native', './gradlew']
        assert settings.num_close_matches == 359
        assert settings.excluded_search_path_prefixes == ['/media/', '/mnt/']

    def test_from_env_with_DEFAULT(self, os_environ, settings):
        os_environ.update({'THEFUCK_RULES': 'DEFAULT_RULES:bash:lisp'})
        settings.init()

        assert settings.rules == const.DEFAULT_RULES + ['bash', 'lisp']