Example #1
0
def test_plz_config_detects_local_file(mock_load_config, mock_isfile):
    # Arrange
    mock_isfile.return_value = True

    # Act
    plz_config()

    # Assert
    mock_load_config.assert_called_with("plz.yaml")
Example #2
0
def test_plz_config_aborts_if_null_root(mock_git_root, mock_isfile):
    # Arrange
    mock_git_root.return_value = None
    mock_isfile.return_value = False

    # Act
    # Assert
    with pytest.raises(Exception):
        plz_config()
Example #3
0
def test_plz_config_exception_calls_sys_exit_1(mock_exit, mock_find_file,
                                               exception):
    # Arrange
    mock_find_file.side_effect = exception

    # Act
    plz_config()

    # Assert
    mock_exit.assert_called_once_with(1)
Example #4
0
def test_plz_config_aborts_if_empty_git_root(mock_invalid_directory,
                                             mock_git_root, mock_isfile):
    # Arrange
    mock_git_root.return_value = ""
    mock_isfile.return_value = False

    # Act
    plz_config()

    # Assert
    mock_invalid_directory.assert_called_once_with()
Example #5
0
def test_plz_config_aborts_if_InvalidYamlException(mock_invalid_yaml,
                                                   mock_load_config,
                                                   mock_isfile):
    # Arrange
    mock_isfile.return_value = True
    mock_load_config.side_effect = InvalidYamlException("filename")

    # Act
    plz_config()

    # Assert
    mock_invalid_yaml.assert_called_once_with("filename")
Example #6
0
def test_plz_config_falls_back_to_legacy_filename(mock_load_config,
                                                  mock_git_root, mock_isfile):
    # Arrange
    mock_isfile.side_effect = [False, False, True]
    mock_git_root.return_value = "git"

    # Act
    plz_config()

    # Assert
    assert mock_isfile.call_count == 3
    mock_load_config.assert_called_with(".plz.yaml")
Example #7
0
def test_plz_config_falls_back_to_git_root_file(mock_load_config,
                                                mock_git_root, mock_isfile):
    # Arrange
    test_path = "/test/root/path"
    mock_git_root.return_value = test_path
    mock_isfile.side_effect = [False, True]

    # Act
    plz_config()

    # Assert
    mock_load_config.assert_called_with("{}/plz.yaml".format(test_path))
Example #8
0
def test_plz_config_handles_extra_trailing_slash(mock_load_config,
                                                 mock_git_root, mock_isfile):
    # Arrange
    test_path = "/test/root/path"
    mock_git_root.return_value = test_path + "/"
    mock_isfile.side_effect = [False, True]

    # Act
    plz_config()

    # Assert
    mock_load_config.assert_called_with("{}/plz.yaml".format(test_path))
Example #9
0
def test_plz_config_handles_extra_trailing_slash(mock_load_config,
                                                 mock_git_root, mock_isfile):
    # Arrange
    test_path = '/test/root/path'
    mock_git_root.return_value = test_path + "/"
    mock_isfile.return_value = False

    # Act
    plz_config()

    # Assert
    mock_load_config.assert_called_with('{}/.plz.yaml'.format(test_path))
Example #10
0
def test_plz_config_falls_back_to_git_root_file(mock_load_config,
                                                mock_git_root, mock_isfile):
    # Arrange
    test_path = '/test/root/path'
    mock_git_root.return_value = test_path
    mock_isfile.return_value = False

    # Act
    plz_config()

    # Assert
    mock_load_config.assert_called_with('{}/.plz.yaml'.format(test_path))