Beispiel #1
0
def test_get_vc_info_git(git_source_repo: Tuple[str, str]):
    """Test get_vc_info() for a git repo"""
    source_dir, commit_sha = git_source_repo
    vc_info = get_vc_info(source_dir)
    assert vc_info is not None
    expected = [('version control system', "git"),
                ('repository version', f"{commit_sha[:7]}-dirty"),
                ('commit', commit_sha), ('working copy root path', source_dir),
                ('status', " M flow.cylc")]
    assert list(vc_info.items()) == expected
Beispiel #2
0
def test_get_vc_info_svn(svn_source_repo: Tuple[str, str, str]):
    """Test get_vc_info() for an svn working copy"""
    source_dir, uuid, repo_path = svn_source_repo
    vc_info = get_vc_info(source_dir)
    assert vc_info is not None
    expected = [('version control system', "svn"),
                ('working copy root path', str(source_dir)),
                ('url', f"file://{repo_path}/project/trunk"),
                ('repository uuid', uuid), ('revision', "1"),
                ('status', "M       flow.cylc")]
    assert list(vc_info.items()) == expected
Beispiel #3
0
def test_no_base_commit_git(tmp_path: Path):
    """Test get_vc_info() and get_diff() for a recently init'd git source dir
    that does not have a base commit yet."""
    source_dir = Path(tmp_path, 'new_git_repo')
    source_dir.mkdir()
    subprocess.run(['git', 'init'], cwd=source_dir, check=True)
    flow_file = source_dir.joinpath('flow.cylc')
    flow_file.write_text(BASIC_FLOW_1)

    vc_info = get_vc_info(source_dir)
    assert vc_info is not None
    expected = [('version control system', "git"),
                ('working copy root path', str(source_dir)),
                ('status', "?? flow.cylc")]
    assert list(vc_info.items()) == expected
    assert get_diff('git', source_dir) is None
Beispiel #4
0
def test_not_repo(tmp_path: Path, monkeypatch: MonkeyPatch):
    """Test get_vc_info() and main() for a dir that is not a supported repo"""
    source_dir = Path(tmp_path, 'git_repo')
    source_dir.mkdir()
    flow_file = source_dir.joinpath('flow.cylc')
    flow_file.write_text(BASIC_FLOW_1)
    mock_write_vc_info = Mock()
    monkeypatch.setattr('cylc.flow.install_plugins.log_vc_info.write_vc_info',
                        mock_write_vc_info)
    mock_write_diff = Mock()
    monkeypatch.setattr('cylc.flow.install_plugins.log_vc_info.write_diff',
                        mock_write_diff)

    assert get_vc_info(source_dir) is None
    assert main(source_dir, None, None) is False  # type: ignore
    assert mock_write_vc_info.called is False
    assert mock_write_diff.called is False