def test_initialize_project_missing_all_cli_args(mock_logger):
    # TODO: Is it possible to test all variations easily in one test?
    # Parametrize doesn't work great because we can't easily swap the param name being used
    message = 'At least one git operation and one list must be provided to run github-archive.'
    with pytest.raises(ValueError) as error:
        github_archive = GithubArchive()
        github_archive.initialize_project()

    mock_logger.assert_called_with(message)
    assert message == str(error.value)
def test_initialize_project_missing_operation(mock_logger):
    # TODO: Is it possible to test all variations easily in one test?
    # Parametrize doesn't work great because we can't easily swap the param name being used
    message = 'A list must be provided when a git operation is specified.'
    with pytest.raises(ValueError) as error:
        github_archive = GithubArchive(clone=True, )
        github_archive.initialize_project()

    mock_logger.assert_called_with(message)
    assert message == str(error.value)
def test_initialize_project_include_exclude_together(mock_logger):
    # TODO: Is it possible to test all variations easily in one test?
    # Parametrize doesn't work great because we can't easily swap the param name being used
    message = 'The include and exclude flags are mutually exclusive. Only one can be used on each run.'
    with pytest.raises(ValueError) as error:
        github_archive = GithubArchive(
            users='justintime50',
            clone=True,
            include='mock-repo',
            exclude='another-mock-repo',
        )
        github_archive.initialize_project()

    mock_logger.assert_called_with(message)
    assert message == str(error.value)
Example #4
0
def test_initialize_project(mock_make_dirs, mock_dir_exist):
    GithubArchive.initialize_project()
    assert mock_make_dirs.call_count == 2
Example #5
0
def test_initialize_project_no_github_token(mock_logger):
    message = 'GITHUB_TOKEN must be present to run github-archive.'
    with pytest.raises(ValueError) as error:
        GithubArchive.initialize_project()
    assert mock_logger.critical.called_with(message)
    assert message == str(error.value)