2019-01-07 00:49:16 +01:00
|
|
|
"""
|
|
|
|
Contains functional tests of the Bazaar class.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
2019-01-21 23:42:41 +01:00
|
|
|
import pytest
|
|
|
|
|
2019-08-21 12:22:57 +02:00
|
|
|
from pip._internal.utils.misc import hide_url
|
2019-01-07 00:49:16 +01:00
|
|
|
from pip._internal.vcs.bazaar import Bazaar
|
2019-01-21 23:42:41 +01:00
|
|
|
from tests.lib import (
|
2019-07-22 06:45:27 +02:00
|
|
|
_test_path_to_file_url,
|
|
|
|
_vcs_add,
|
|
|
|
create_file,
|
|
|
|
is_bzr_installed,
|
|
|
|
need_bzr,
|
2019-01-21 23:42:41 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.skipif(
|
|
|
|
'TRAVIS' not in os.environ,
|
|
|
|
reason='Bazaar is only required under Travis')
|
|
|
|
def test_ensure_bzr_available():
|
|
|
|
"""Make sure that bzr is available when running in Travis."""
|
|
|
|
assert is_bzr_installed()
|
2019-01-07 00:49:16 +01:00
|
|
|
|
|
|
|
|
|
|
|
@need_bzr
|
|
|
|
def test_export(script, tmpdir):
|
|
|
|
"""Test that a Bazaar branch can be exported."""
|
2019-01-27 03:53:16 +01:00
|
|
|
source_dir = tmpdir / 'test-source'
|
|
|
|
source_dir.mkdir()
|
2019-01-07 00:49:16 +01:00
|
|
|
|
2019-01-27 03:53:16 +01:00
|
|
|
create_file(source_dir / 'test_file', 'something')
|
2019-01-07 00:49:16 +01:00
|
|
|
|
2019-01-27 03:53:16 +01:00
|
|
|
_vcs_add(script, str(source_dir), vcs='bazaar')
|
2019-01-07 00:49:16 +01:00
|
|
|
|
|
|
|
export_dir = str(tmpdir / 'export')
|
2019-08-21 12:22:57 +02:00
|
|
|
url = hide_url('bzr+' + _test_path_to_file_url(source_dir))
|
2019-04-14 10:13:50 +02:00
|
|
|
Bazaar().export(export_dir, url=url)
|
2019-01-07 00:49:16 +01:00
|
|
|
|
|
|
|
assert os.listdir(export_dir) == ['test_file']
|
2019-01-27 03:53:16 +01:00
|
|
|
|
|
|
|
|
|
|
|
@need_bzr
|
|
|
|
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 <pypa-dev@googlegroups.com>',
|
|
|
|
'-m', 'change test file', cwd=source_dir,
|
|
|
|
)
|
|
|
|
|
|
|
|
export_dir = tmpdir / 'export'
|
2019-08-21 12:22:57 +02:00
|
|
|
url = hide_url('bzr+' + _test_path_to_file_url(source_dir) + '@1')
|
2019-04-14 10:13:50 +02:00
|
|
|
Bazaar().export(str(export_dir), url=url)
|
2019-01-27 03:53:16 +01:00
|
|
|
|
|
|
|
with open(export_dir / 'test_file', 'r') as f:
|
|
|
|
assert f.read() == 'something initial'
|