summaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
authorctolentino8 <ctolentino8@bloomberg.net>2018-09-24 10:32:45 +0100
committerChandan Singh <chandan.devel@gmail.com>2018-11-02 16:41:54 +0000
commitde59ebdbf755ca65c7c9d389204f6ce508f84e7e (patch)
tree546e291d2d52dee54120eab0a7045452484fd652 /tests/integration
parent7f79b9ce511f1421851821bf2928352ba569b8f0 (diff)
downloadbuildstream-de59ebdbf755ca65c7c9d389204f6ce508f84e7e.tar.gz
plugins/sources/pip.py: Accomodate characters '-','.','_' for packages
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/pip_source.py47
1 files changed, 35 insertions, 12 deletions
diff --git a/tests/integration/pip_source.py b/tests/integration/pip_source.py
index fc5b56a7c..84cf5dda9 100644
--- a/tests/integration/pip_source.py
+++ b/tests/integration/pip_source.py
@@ -4,6 +4,7 @@ import pytest
from buildstream import _yaml
from tests.testutils import cli_integration as cli
+from tests.testutils.python_repo import setup_pypi_repo
from tests.testutils.integration import assert_contains
@@ -17,12 +18,21 @@ DATA_DIR = os.path.join(
@pytest.mark.datafiles(DATA_DIR)
-def test_pip_source_import(cli, tmpdir, datafiles):
+def test_pip_source_import(cli, tmpdir, datafiles, setup_pypi_repo):
project = os.path.join(datafiles.dirname, datafiles.basename)
checkout = os.path.join(cli.directory, 'checkout')
element_path = os.path.join(project, 'elements')
element_name = 'pip/hello.bst'
+ # check that exotically named packages are imported correctly
+ myreqs_packages = ['hellolib']
+ packages = ['app2', 'app.3', 'app-4', 'app_5', 'app.no.6', 'app-no-7', 'app_no_8']
+
+ # create mock pypi repository
+ pypi_repo = os.path.join(project, 'files', 'pypi-repo')
+ os.makedirs(pypi_repo, exist_ok=True)
+ setup_pypi_repo(myreqs_packages + packages, pypi_repo)
+
element = {
'kind': 'import',
'sources': [
@@ -32,9 +42,9 @@ def test_pip_source_import(cli, tmpdir, datafiles):
},
{
'kind': 'pip',
- 'url': 'file://{}'.format(os.path.realpath(os.path.join(project, 'files', 'pypi-repo'))),
+ 'url': 'file://{}'.format(os.path.realpath(pypi_repo)),
'requirements-files': ['myreqs.txt'],
- 'packages': ['app2']
+ 'packages': packages
}
]
}
@@ -51,16 +61,31 @@ def test_pip_source_import(cli, tmpdir, datafiles):
assert result.exit_code == 0
assert_contains(checkout, ['/.bst_pip_downloads',
- '/.bst_pip_downloads/HelloLib-0.1.tar.gz',
- '/.bst_pip_downloads/App2-0.1.tar.gz'])
+ '/.bst_pip_downloads/hellolib-0.1.tar.gz',
+ '/.bst_pip_downloads/app2-0.1.tar.gz',
+ '/.bst_pip_downloads/app.3-0.1.tar.gz',
+ '/.bst_pip_downloads/app-4-0.1.tar.gz',
+ '/.bst_pip_downloads/app_5-0.1.tar.gz',
+ '/.bst_pip_downloads/app.no.6-0.1.tar.gz',
+ '/.bst_pip_downloads/app-no-7-0.1.tar.gz',
+ '/.bst_pip_downloads/app_no_8-0.1.tar.gz'])
@pytest.mark.datafiles(DATA_DIR)
-def test_pip_source_build(cli, tmpdir, datafiles):
+def test_pip_source_build(cli, tmpdir, datafiles, setup_pypi_repo):
project = os.path.join(datafiles.dirname, datafiles.basename)
element_path = os.path.join(project, 'elements')
element_name = 'pip/hello.bst'
+ # check that exotically named packages are imported correctly
+ myreqs_packages = ['hellolib']
+ packages = ['app2', 'app.3', 'app-4', 'app_5', 'app.no.6', 'app-no-7', 'app_no_8']
+
+ # create mock pypi repository
+ pypi_repo = os.path.join(project, 'files', 'pypi-repo')
+ os.makedirs(pypi_repo, exist_ok=True)
+ setup_pypi_repo(myreqs_packages + packages, pypi_repo)
+
element = {
'kind': 'manual',
'depends': ['base.bst'],
@@ -71,16 +96,15 @@ def test_pip_source_build(cli, tmpdir, datafiles):
},
{
'kind': 'pip',
- 'url': 'file://{}'.format(os.path.realpath(os.path.join(project, 'files', 'pypi-repo'))),
+ 'url': 'file://{}'.format(os.path.realpath(pypi_repo)),
'requirements-files': ['myreqs.txt'],
- 'packages': ['app2']
+ 'packages': packages
}
],
'config': {
'install-commands': [
'pip3 install --no-index --prefix %{install-root}/usr .bst_pip_downloads/*.tar.gz',
- 'chmod +x app1.py',
- 'install app1.py %{install-root}/usr/bin/'
+ 'install app1.py %{install-root}/usr/bin/'
]
}
}
@@ -95,5 +119,4 @@ def test_pip_source_build(cli, tmpdir, datafiles):
result = cli.run(project=project, args=['shell', element_name, '/usr/bin/app1.py'])
assert result.exit_code == 0
- assert result.output == """Hello App1!
-"""
+ assert result.output == "Hello App1! This is hellolib\n"