Example #1
0
def test_load_config_logs_not_valid_path(mocker):
    mocker.patch('passpie.utils.open',
                 mock_open(MagicMock(side_effect=IOError)),
                 create=True)
    mock_logging = mocker.patch('passpie.utils.logging')

    load_config({}, {})

    assert mock_logging.debug.called
Example #2
0
def test_load_config_logs_debug_message_when_malformed_config(mocker):
    mocker.patch('passpie.utils.open', mock_open(), create=True)
    mocker.patch('passpie.utils.yaml.load',
                 side_effect=yaml.scanner.ScannerError)
    mock_logging = mocker.patch('passpie.utils.logging')

    load_config({}, {})

    assert mock_logging.debug.called
Example #3
0
def test_load_config_logs_not_valid_path(mocker):
    mocker.patch('passpie.utils.open',
                 mock_open(MagicMock(side_effect=IOError)),
                 create=True)
    mock_logging = mocker.patch('passpie.utils.logging')

    load_config({}, {})

    assert mock_logging.debug.called
Example #4
0
def test_load_config_logs_debug_message_when_malformed_config(mocker):
    mocker.patch('passpie.utils.open', mock_open(), create=True)
    mocker.patch('passpie.utils.yaml.load',
                 side_effect=yaml.scanner.ScannerError)
    mock_logging = mocker.patch('passpie.utils.logging')

    load_config({}, {})

    assert mock_logging.debug.called
Example #5
0
def test_load_config_replaces_sets_user_config_element(mocker):
    DEFAULT_CONFIG = {'path': 'default_path', 'short_commands': True}
    USER_CONFIG = {'path': 'user_path'}
    mocker.patch('passpie.utils.os.path.exists', return_value=True)
    mocker.patch('passpie.utils.os.path.isfile', return_value=True)
    mocker.patch('passpie.utils.open', mock_open(), create=True)
    mocker.patch('passpie.utils.yaml.load', return_value=USER_CONFIG)

    config = load_config(DEFAULT_CONFIG, 'configrc')

    assert config.path == USER_CONFIG['path']
    assert config.short_commands == DEFAULT_CONFIG['short_commands']
Example #6
0
def test_load_config_replaces_sets_user_config_element(mocker):
    DEFAULT_CONFIG = {'path': 'default_path', 'short_commands': True}
    USER_CONFIG = {'path': 'user_path'}
    mocker.patch('passpie.utils.os.path.exists', return_value=True)
    mocker.patch('passpie.utils.os.path.isfile', return_value=True)
    mocker.patch('passpie.utils.open', mock_open(), create=True)
    mocker.patch('passpie.utils.yaml.load', return_value=USER_CONFIG)

    config = load_config(DEFAULT_CONFIG, 'configrc')

    assert config.path == USER_CONFIG['path']
    assert config.short_commands == DEFAULT_CONFIG['short_commands']