Ejemplo n.º 1
0
def test_bazaar__get_url_rev_and_auth(url, expected):
    """
    Test Bazaar.get_url_rev_and_auth().
    """
    bzr = Bazaar(url=url)
    actual = bzr.get_url_rev_and_auth(url)
    assert actual == (expected, None, (None, None))
Ejemplo n.º 2
0
def test_export_rev(script, tmpdir):
    """Test that a Bazaar branch can be exported, specifying a rev."""
    source_dir = tmpdir / 'test-source'
    source_dir.mkdir()

    # Create a single file that is changed by two revisions.
    create_file(source_dir / 'test_file', 'something initial')
    _vcs_add(script, str(source_dir), vcs='bazaar')

    create_file(source_dir / 'test_file', 'something new')
    script.run(
        'bzr',
        'commit',
        '-q',
        '--author',
        'pip <*****@*****.**>',
        '-m',
        'change test file',
        cwd=source_dir,
    )

    bzr = Bazaar('bzr+' + _test_path_to_file_url(source_dir) + '@1')
    export_dir = tmpdir / 'export'
    bzr.export(str(export_dir))

    with open(export_dir / 'test_file', 'r') as f:
        assert f.read() == 'something initial'
Ejemplo n.º 3
0
def test_export(script, tmpdir):
    """Test that a Bazaar branch can be exported."""
    source_dir = tmpdir / 'test-source'
    source_dir.mkdir()

    create_file(source_dir / 'test_file', 'something')

    _vcs_add(script, str(source_dir), vcs='bazaar')

    bzr = Bazaar('bzr+' + _test_path_to_file_url(source_dir))
    export_dir = str(tmpdir / 'export')
    bzr.export(export_dir)

    assert os.listdir(export_dir) == ['test_file']
Ejemplo n.º 4
0
def test_export(script, tmpdir):
    """Test that a Bazaar branch can be exported."""
    source_dir = tmpdir / 'test-source'
    source_dir.mkdir()

    create_file(source_dir / 'test_file', 'something')

    _vcs_add(script, str(source_dir), vcs='bazaar')

    bzr = Bazaar('bzr+' + _test_path_to_file_url(source_dir))
    export_dir = str(tmpdir / 'export')
    bzr.export(export_dir)

    assert os.listdir(export_dir) == ['test_file']
Ejemplo n.º 5
0
def test_export_rev(script, tmpdir):
    """Test that a Bazaar branch can be exported, specifying a rev."""
    source_dir = tmpdir / 'test-source'
    source_dir.mkdir()

    # Create a single file that is changed by two revisions.
    create_file(source_dir / 'test_file', 'something initial')
    _vcs_add(script, str(source_dir), vcs='bazaar')

    create_file(source_dir / 'test_file', 'something new')
    script.run(
        'bzr',
        'commit',
        '-q',
        '--author',
        'pip <*****@*****.**>',
        '-m',
        'change test file',
        cwd=source_dir,
    )

    export_dir = tmpdir / 'export'
    url = hide_url('bzr+' + _test_path_to_file_url(source_dir) + '@1')
    Bazaar().export(str(export_dir), url=url)

    with open(export_dir / 'test_file') as f:
        assert f.read() == 'something initial'
Ejemplo n.º 6
0
def test_get_remote_url__no_remote(script: PipTestEnvironment, tmpdir: Path) -> None:
    repo_dir = tmpdir / "temp-repo"
    repo_dir.mkdir()

    script.run("bzr", "init", repo_dir)

    with pytest.raises(RemoteNotFoundError):
        Bazaar().get_remote_url(repo_dir)
Ejemplo n.º 7
0
def test_get_remote_url__no_remote(script, tmpdir):
    repo_dir = tmpdir / 'temp-repo'
    repo_dir.mkdir()
    repo_dir = str(repo_dir)

    script.run('bzr', 'init', repo_dir)

    with pytest.raises(RemoteNotFoundError):
        Bazaar().get_remote_url(repo_dir)
Ejemplo n.º 8
0
def test_get_remote_url__no_remote(script, tmpdir):
    repo_dir = tmpdir / "temp-repo"
    repo_dir.mkdir()
    repo_dir = str(repo_dir)

    script.run("bzr", "init", repo_dir)

    with pytest.raises(RemoteNotFoundError):
        Bazaar().get_remote_url(repo_dir)
Ejemplo n.º 9
0
def test_export_rev(script, tmpdir):
    """Test that a Bazaar branch can be exported, specifying a rev."""
    source_dir = tmpdir / 'test-source'
    source_dir.mkdir()

    # Create a single file that is changed by two revisions.
    create_file(source_dir / 'test_file', 'something initial')
    _vcs_add(script, str(source_dir), vcs='bazaar')

    create_file(source_dir / 'test_file', 'something new')
    script.run(
        'bzr', 'commit', '-q',
        '--author', 'pip <*****@*****.**>',
        '-m', 'change test file', cwd=source_dir,
    )

    bzr = Bazaar('bzr+' + _test_path_to_file_url(source_dir) + '@1')
    export_dir = tmpdir / 'export'
    bzr.export(str(export_dir))

    with open(export_dir / 'test_file', 'r') as f:
        assert f.read() == 'something initial'
Ejemplo n.º 10
0
def test_bazaar__get_url_rev_and_auth(url: str, expected: str) -> None:
    """
    Test Bazaar.get_url_rev_and_auth().
    """
    actual = Bazaar.get_url_rev_and_auth(url)
    assert actual == (expected, None, (None, None))
Ejemplo n.º 11
0
def test_bazaar_simple_urls():
    """
    Test bzr url support.

    SSH and launchpad have special handling.
    """
    http_bzr_repo = Bazaar(
        url='bzr+http://bzr.myproject.org/MyProject/trunk/#egg=MyProject'
    )
    https_bzr_repo = Bazaar(
        url='bzr+https://bzr.myproject.org/MyProject/trunk/#egg=MyProject'
    )
    ssh_bzr_repo = Bazaar(
        url='bzr+ssh://bzr.myproject.org/MyProject/trunk/#egg=MyProject'
    )
    ftp_bzr_repo = Bazaar(
        url='bzr+ftp://bzr.myproject.org/MyProject/trunk/#egg=MyProject'
    )
    sftp_bzr_repo = Bazaar(
        url='bzr+sftp://bzr.myproject.org/MyProject/trunk/#egg=MyProject'
    )
    launchpad_bzr_repo = Bazaar(
        url='bzr+lp:MyLaunchpadProject#egg=MyLaunchpadProject'
    )

    assert http_bzr_repo.get_url_rev() == (
        'http://bzr.myproject.org/MyProject/trunk/', None,
    )
    assert https_bzr_repo.get_url_rev() == (
        'https://bzr.myproject.org/MyProject/trunk/', None,
    )
    assert ssh_bzr_repo.get_url_rev() == (
        'bzr+ssh://bzr.myproject.org/MyProject/trunk/', None,
    )
    assert ftp_bzr_repo.get_url_rev() == (
        'ftp://bzr.myproject.org/MyProject/trunk/', None,
    )
    assert sftp_bzr_repo.get_url_rev() == (
        'sftp://bzr.myproject.org/MyProject/trunk/', None,
    )
    assert launchpad_bzr_repo.get_url_rev() == (
        'lp:MyLaunchpadProject', None,
    )
Ejemplo n.º 12
0
from tests.lib import pyversion

if pyversion >= '3':
    VERBOSE_FALSE = False
else:
    VERBOSE_FALSE = 0


def test_rev_options_repr():
    rev_options = RevOptions(Git(), 'develop')
    assert repr(rev_options) == "<RevOptions git: rev='develop'>"


@pytest.mark.parametrize(('vcs', 'expected1', 'expected2', 'kwargs'), [
    # First check VCS-specific RevOptions behavior.
    (Bazaar(), [], ['-r', '123'], {}),
    (Git(), ['HEAD'], ['123'], {}),
    (Mercurial(), [], ['123'], {}),
    (Subversion(), [], ['-r', '123'], {}),
    # Test extra_args.  For this, test using a single VersionControl class.
    (Git(), ['HEAD', 'opt1', 'opt2'], ['123', 'opt1', 'opt2'],
        dict(extra_args=['opt1', 'opt2'])),
])
def test_rev_options_to_args(vcs, expected1, expected2, kwargs):
    """
    Test RevOptions.to_args().
    """
    assert RevOptions(vcs, **kwargs).to_args() == expected1
    assert RevOptions(vcs, '123', **kwargs).to_args() == expected2