2015-09-17 19:58:22 +02:00
|
|
|
#! /usr/bin/env py.test
|
2015-09-20 19:26:22 +02:00
|
|
|
"""
|
|
|
|
Checks an actual pypi-server against various clients.
|
|
|
|
|
|
|
|
The tests below are using 3 ways to startup pypi-servers:
|
|
|
|
|
2015-12-20 19:33:48 +01:00
|
|
|
- "open": a per-module server instance without any authed operations,
|
2015-09-20 19:26:22 +02:00
|
|
|
serving a single `wheel` package, on a fixed port.
|
2015-12-20 19:33:48 +01:00
|
|
|
- "open": a per-module server instance with authed 'download/upload' operations,
|
2015-09-20 19:26:22 +02:00
|
|
|
serving a single `wheel` package, on a fixed port.
|
|
|
|
- "new_server": starting a new server with any configurations on each test.
|
|
|
|
|
|
|
|
"""
|
2015-09-19 01:02:27 +02:00
|
|
|
from __future__ import print_function
|
2015-09-17 19:58:22 +02:00
|
|
|
|
2015-09-19 01:02:27 +02:00
|
|
|
from collections import namedtuple
|
2015-09-17 19:58:22 +02:00
|
|
|
import contextlib
|
2015-09-19 01:02:27 +02:00
|
|
|
import functools
|
|
|
|
import os
|
2015-09-17 19:58:22 +02:00
|
|
|
import subprocess
|
2015-09-18 18:31:12 +02:00
|
|
|
import sys
|
2015-09-19 02:36:43 +02:00
|
|
|
import tempfile
|
2015-09-17 19:58:22 +02:00
|
|
|
import time
|
2017-11-14 17:47:27 +01:00
|
|
|
from textwrap import dedent
|
|
|
|
try:
|
|
|
|
from urllib.request import urlopen
|
|
|
|
except ImportError:
|
|
|
|
from urllib import urlopen
|
2015-09-17 19:58:22 +02:00
|
|
|
|
2015-09-18 20:20:01 +02:00
|
|
|
import pip
|
2015-09-17 19:58:22 +02:00
|
|
|
from py import path # @UnresolvedImport
|
|
|
|
import pytest
|
|
|
|
|
2015-09-19 02:36:43 +02:00
|
|
|
|
2015-12-20 19:33:48 +01:00
|
|
|
_BUFF_SIZE = 2**16
|
2015-09-19 01:02:27 +02:00
|
|
|
_port = 8090
|
2017-11-14 17:47:27 +01:00
|
|
|
SLEEP_AFTER_SRV = 3 # sec
|
2015-09-18 20:20:01 +02:00
|
|
|
|
2015-09-19 01:02:27 +02:00
|
|
|
@pytest.fixture
|
|
|
|
def port():
|
|
|
|
global _port
|
|
|
|
_port += 1
|
|
|
|
return _port
|
2015-09-17 19:58:22 +02:00
|
|
|
|
2015-09-20 18:35:11 +02:00
|
|
|
Srv = namedtuple('Srv', ('proc', 'port', 'package'))
|
2015-09-19 01:02:27 +02:00
|
|
|
|
|
|
|
|
2015-09-20 19:26:22 +02:00
|
|
|
def _run_server(packdir, port, authed, other_cli=''):
|
2017-11-14 17:47:27 +01:00
|
|
|
"""Run a server, optionally with partial auth enabled."""
|
2015-09-19 01:02:27 +02:00
|
|
|
pswd_opt_choices = {
|
2017-11-14 15:41:26 +01:00
|
|
|
True: "-Ptests/htpasswd.a.a -a update,download",
|
2017-11-14 17:47:27 +01:00
|
|
|
False: "-P. -a.",
|
|
|
|
'partial': "-Ptests/htpasswd.a.a -a update",
|
2015-09-19 01:02:27 +02:00
|
|
|
}
|
2015-09-20 19:26:22 +02:00
|
|
|
pswd_opts = pswd_opt_choices[authed]
|
2015-09-21 03:51:14 +02:00
|
|
|
cmd = "%s -m pypiserver.__main__ -vvv --overwrite -p %s %s %s %s" % (
|
2015-09-20 18:35:11 +02:00
|
|
|
sys.executable, port, pswd_opts, other_cli, packdir)
|
2015-09-19 01:02:27 +02:00
|
|
|
proc = subprocess.Popen(cmd.split(), bufsize=_BUFF_SIZE)
|
2015-12-20 19:33:48 +01:00
|
|
|
time.sleep(SLEEP_AFTER_SRV)
|
2015-09-19 02:36:43 +02:00
|
|
|
assert proc.poll() is None
|
2015-09-19 01:02:27 +02:00
|
|
|
|
|
|
|
return Srv(proc, int(port), packdir)
|
|
|
|
|
|
|
|
|
|
|
|
def _kill_server(srv):
|
|
|
|
print('Killing %s' % (srv,))
|
2015-09-17 19:58:22 +02:00
|
|
|
try:
|
2015-09-19 01:02:27 +02:00
|
|
|
srv.proc.terminate()
|
|
|
|
time.sleep(1)
|
2015-09-17 19:58:22 +02:00
|
|
|
finally:
|
2015-09-19 01:02:27 +02:00
|
|
|
srv.proc.kill()
|
|
|
|
|
|
|
|
|
|
|
|
@contextlib.contextmanager
|
2015-09-20 19:26:22 +02:00
|
|
|
def new_server(packdir, port, authed=False, other_cli=''):
|
2015-09-19 01:02:27 +02:00
|
|
|
srv = _run_server(packdir, port,
|
2015-09-20 19:26:22 +02:00
|
|
|
authed=authed, other_cli=other_cli)
|
2015-09-19 01:02:27 +02:00
|
|
|
try:
|
|
|
|
yield srv
|
|
|
|
finally:
|
|
|
|
_kill_server(srv)
|
|
|
|
|
|
|
|
|
2015-09-19 02:36:43 +02:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def chdir(d):
|
|
|
|
old_d = os.getcwd()
|
|
|
|
try:
|
|
|
|
os.chdir(d)
|
|
|
|
yield
|
|
|
|
finally:
|
|
|
|
os.chdir(old_d)
|
|
|
|
|
|
|
|
|
2015-09-20 19:26:22 +02:00
|
|
|
def _run_python(cmd):
|
2015-09-20 18:35:11 +02:00
|
|
|
ncmd = '%s %s' % (sys.executable, cmd)
|
|
|
|
return os.system(ncmd)
|
|
|
|
|
|
|
|
|
2015-09-19 01:02:27 +02:00
|
|
|
@pytest.fixture(scope='module')
|
2015-09-20 19:26:22 +02:00
|
|
|
def project(request):
|
2015-09-19 02:36:43 +02:00
|
|
|
def fin():
|
|
|
|
tmpdir.remove(True)
|
|
|
|
tmpdir = path.local(tempfile.mkdtemp())
|
|
|
|
request.addfinalizer(fin)
|
|
|
|
src_setup_py = path.local().join('tests', 'centodeps-setup.py')
|
|
|
|
assert src_setup_py.check()
|
|
|
|
projdir = tmpdir.join('centodeps')
|
|
|
|
projdir.mkdir()
|
|
|
|
dst_setup_py = projdir.join('setup.py')
|
|
|
|
src_setup_py.copy(dst_setup_py)
|
|
|
|
assert dst_setup_py.check()
|
2015-09-19 01:02:27 +02:00
|
|
|
|
2015-09-20 19:26:22 +02:00
|
|
|
return projdir
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='module')
|
|
|
|
def package(project, request):
|
|
|
|
with chdir(project.strpath):
|
2015-09-20 18:35:11 +02:00
|
|
|
cmd = 'setup.py bdist_wheel'
|
2015-09-20 19:26:22 +02:00
|
|
|
assert _run_python(cmd) == 0
|
|
|
|
pkgs = list(project.join('dist').visit('centodeps*.whl'))
|
2015-09-19 02:36:43 +02:00
|
|
|
assert len(pkgs) == 1
|
|
|
|
pkg = path.local(pkgs[0])
|
|
|
|
assert pkg.check()
|
|
|
|
|
|
|
|
return pkg
|
2015-09-19 01:02:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='module')
|
|
|
|
def packdir(package):
|
|
|
|
return package.dirpath()
|
|
|
|
|
|
|
|
|
|
|
|
open_port = 8081
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='module')
|
|
|
|
def open_server(packdir, request):
|
2015-09-20 19:26:22 +02:00
|
|
|
srv = _run_server(packdir, open_port, authed=False)
|
2015-09-19 01:02:27 +02:00
|
|
|
fin = functools.partial(_kill_server, srv)
|
|
|
|
request.addfinalizer(fin)
|
|
|
|
|
|
|
|
return srv
|
|
|
|
|
|
|
|
|
|
|
|
protected_port = 8082
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='module')
|
|
|
|
def protected_server(packdir, request):
|
2015-09-20 19:26:22 +02:00
|
|
|
srv = _run_server(packdir, protected_port, authed=True)
|
2015-09-19 01:02:27 +02:00
|
|
|
fin = functools.partial(_kill_server, srv)
|
|
|
|
request.addfinalizer(fin)
|
|
|
|
|
|
|
|
return srv
|
2015-09-17 19:58:22 +02:00
|
|
|
|
|
|
|
|
2015-09-18 20:20:01 +02:00
|
|
|
@pytest.fixture
|
2015-09-19 01:02:27 +02:00
|
|
|
def empty_packdir(tmpdir):
|
|
|
|
return tmpdir.mkdir("dists")
|
|
|
|
|
|
|
|
|
|
|
|
def _build_url(port, user='', pswd=''):
|
|
|
|
auth = '%s:%s@' % (user, pswd) if user or pswd else ''
|
|
|
|
return 'http://%slocalhost:%s' % (auth, port)
|
2015-09-18 19:05:07 +02:00
|
|
|
|
2015-09-17 19:58:22 +02:00
|
|
|
|
2015-09-19 01:02:27 +02:00
|
|
|
def _run_pip(cmd):
|
|
|
|
ncmd = ("--disable-pip-version-check --retries 0 --timeout 5"
|
|
|
|
" --no-input %s"
|
|
|
|
) % cmd
|
|
|
|
print('PIP: %s' % ncmd)
|
2015-09-18 20:20:01 +02:00
|
|
|
return pip.main(ncmd.split())
|
|
|
|
|
|
|
|
|
2015-09-19 01:02:27 +02:00
|
|
|
def _run_pip_install(cmd, port, install_dir, user=None, pswd=None):
|
|
|
|
url = _build_url(port, user, pswd)
|
2015-09-19 02:36:43 +02:00
|
|
|
ncmd = '-vv install --download %s -i %s %s' % (install_dir, url, cmd)
|
2015-09-19 01:02:27 +02:00
|
|
|
return _run_pip(ncmd)
|
|
|
|
|
2015-09-18 20:20:01 +02:00
|
|
|
|
2015-09-19 01:02:27 +02:00
|
|
|
@pytest.fixture
|
|
|
|
def pipdir(tmpdir):
|
|
|
|
return tmpdir.mkdir("pip")
|
|
|
|
|
|
|
|
|
|
|
|
def test_pipInstall_packageNotFound(empty_packdir, port, pipdir, package):
|
|
|
|
with new_server(empty_packdir, port) as srv:
|
|
|
|
cmd = "centodeps"
|
|
|
|
assert _run_pip_install(cmd, port, pipdir) != 0
|
|
|
|
assert not pipdir.listdir()
|
|
|
|
|
|
|
|
|
|
|
|
def test_pipInstall_openOk(open_server, package, pipdir):
|
|
|
|
cmd = "centodeps"
|
|
|
|
assert _run_pip_install(cmd, open_server.port, pipdir) == 0
|
|
|
|
assert pipdir.join(package.basename).check()
|
|
|
|
|
|
|
|
|
2015-09-20 19:26:22 +02:00
|
|
|
def test_pipInstall_authedFails(protected_server, pipdir):
|
2015-09-19 01:02:27 +02:00
|
|
|
cmd = "centodeps"
|
|
|
|
assert _run_pip_install(cmd, protected_server.port, pipdir) != 0
|
|
|
|
assert not pipdir.listdir()
|
|
|
|
|
|
|
|
|
2015-09-20 19:26:22 +02:00
|
|
|
def test_pipInstall_authedOk(protected_server, package, pipdir):
|
2015-09-19 01:02:27 +02:00
|
|
|
cmd = "centodeps"
|
|
|
|
assert _run_pip_install(cmd, protected_server.port, pipdir,
|
|
|
|
user='a', pswd='a') == 0
|
|
|
|
assert pipdir.join(package.basename).check()
|
2015-09-18 20:20:01 +02:00
|
|
|
|
|
|
|
|
2015-09-20 18:35:11 +02:00
|
|
|
@pytest.fixture
|
|
|
|
def pypirc(port):
|
|
|
|
return {}
|
|
|
|
|
|
|
|
|
|
|
|
def update_pypirc(pypirc, port, user='foo', pswd='bar'):
|
|
|
|
url = _build_url(port, None, None)
|
|
|
|
pypirc.update({
|
|
|
|
'repository': url,
|
|
|
|
'username': user,
|
|
|
|
'password': pswd,
|
|
|
|
})
|
|
|
|
|
|
|
|
|
2015-09-20 19:26:22 +02:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def pypirc_file(txt):
|
|
|
|
pypirc_path = path.local('~/.pypirc', expanduser=1)
|
|
|
|
old_pypirc = pypirc_path.read() if pypirc_path.check() else None
|
|
|
|
pypirc_path.write(txt)
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
|
|
|
if old_pypirc:
|
|
|
|
pypirc_path.write(old_pypirc)
|
|
|
|
else:
|
|
|
|
pypirc_path.remove()
|
|
|
|
|
|
|
|
|
2015-09-21 03:51:14 +02:00
|
|
|
@pytest.mark.parametrize("pkg_frmt", ['bdist', 'bdist_wheel'])
|
|
|
|
def test_setuptoolsUpload_open(empty_packdir, port, project, package,
|
|
|
|
pkg_frmt):
|
2016-05-15 05:56:00 +02:00
|
|
|
url = _build_url(port, None, None)
|
|
|
|
with pypirc_file(dedent("""\
|
|
|
|
[distutils]
|
|
|
|
index-servers: test
|
|
|
|
|
|
|
|
[test]
|
|
|
|
repository: %s
|
|
|
|
username: ''
|
|
|
|
password: ''
|
|
|
|
""" % url)):
|
|
|
|
with new_server(empty_packdir, port):
|
|
|
|
with chdir(project.strpath):
|
|
|
|
cmd = "setup.py -vvv %s upload -r %s" % (pkg_frmt, url)
|
|
|
|
for i in range(5):
|
|
|
|
print('++Attempt #%s' % i)
|
|
|
|
assert _run_python(cmd) == 0
|
|
|
|
time.sleep(SLEEP_AFTER_SRV)
|
2015-09-20 19:26:22 +02:00
|
|
|
assert len(empty_packdir.listdir()) == 1
|
|
|
|
|
|
|
|
|
2015-09-21 03:51:14 +02:00
|
|
|
@pytest.mark.parametrize("pkg_frmt", ['bdist', 'bdist_wheel'])
|
2015-09-20 19:26:22 +02:00
|
|
|
def test_setuptoolsUpload_authed(empty_packdir, port, project, package,
|
2015-09-21 03:51:14 +02:00
|
|
|
pkg_frmt, monkeypatch):
|
2015-09-20 19:26:22 +02:00
|
|
|
url = _build_url(port)
|
|
|
|
with pypirc_file(dedent("""\
|
|
|
|
[distutils]
|
|
|
|
index-servers: test
|
2015-12-20 19:33:48 +01:00
|
|
|
|
2015-09-20 19:26:22 +02:00
|
|
|
[test]
|
|
|
|
repository: %s
|
|
|
|
username: a
|
|
|
|
password: a
|
|
|
|
""" % url)):
|
|
|
|
with new_server(empty_packdir, port, authed=True):
|
|
|
|
with chdir(project.strpath):
|
2015-09-21 03:51:14 +02:00
|
|
|
cmd = "setup.py -vvv %s register -r test upload -r test" % pkg_frmt
|
|
|
|
for i in range(5):
|
|
|
|
print('++Attempt #%s' % i)
|
|
|
|
assert _run_python(cmd) == 0
|
2015-12-20 19:33:48 +01:00
|
|
|
time.sleep(SLEEP_AFTER_SRV)
|
2015-09-20 19:26:22 +02:00
|
|
|
assert len(empty_packdir.listdir()) == 1
|
|
|
|
|
|
|
|
|
2017-11-14 17:47:27 +01:00
|
|
|
@pytest.mark.parametrize("pkg_frmt", ['bdist', 'bdist_wheel'])
|
|
|
|
def test_setuptools_upload_partial_authed(empty_packdir, port, project,
|
|
|
|
pkg_frmt):
|
|
|
|
"""Test uploading a package with setuptools with partial auth."""
|
|
|
|
url = _build_url(port)
|
|
|
|
with pypirc_file(dedent("""\
|
|
|
|
[distutils]
|
|
|
|
index-servers: test
|
|
|
|
|
|
|
|
[test]
|
|
|
|
repository: %s
|
|
|
|
username: a
|
|
|
|
password: a
|
|
|
|
""" % url)):
|
|
|
|
with new_server(empty_packdir, port, authed='partial'):
|
|
|
|
with chdir(project.strpath):
|
|
|
|
cmd = ("setup.py -vvv %s register -r test upload -r test" %
|
|
|
|
pkg_frmt)
|
|
|
|
for i in range(5):
|
|
|
|
print('++Attempt #%s' % i)
|
|
|
|
assert _run_python(cmd) == 0
|
|
|
|
time.sleep(SLEEP_AFTER_SRV)
|
|
|
|
assert len(empty_packdir.listdir()) == 1
|
|
|
|
|
|
|
|
|
|
|
|
def test_partial_authed_open_download(empty_packdir, port):
|
|
|
|
"""Validate that partial auth still allows downloads."""
|
|
|
|
url = _build_url(port) + '/simple'
|
|
|
|
with new_server(empty_packdir, port, authed='partial'):
|
|
|
|
resp = urlopen(url)
|
|
|
|
assert resp.getcode() == 200
|
|
|
|
|
|
|
|
|
2015-09-19 02:36:43 +02:00
|
|
|
@pytest.fixture
|
|
|
|
def uploader(pypirc, monkeypatch):
|
Update Tests for New Twine
* Updated .travis.yml to fix PEP 440 warnings
* Fixed twine calls
We were getting test failures on multiple branches in
`test_server.py`. I first investigated a warning message
popping up in every test run:
```
PEP440Warning,
/home/travis/virtualenv/python3.5.2/lib/python3.5/site-packages/pkg_resources/__init__.py:2510: PEP440Warning: 'setuptools (git-0.4.0)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
```
Moving the installation of setuptools, pip, sphinx, and tox
into the `install` key for Travis resolved that issue, but
`test_server.py` tests were still failing. It turns out that
Twine 1.7.0 added support for SSL cert specification and,
in the process, changed the call signature for the `upload`
and `register` internal methods.
This PR fixes the calls so that they align with Twine's new
function signature. Note that tests now fail on Twine <1.7.0,
so I have also updated the dev requirements file.
2016-07-17 20:40:06 +02:00
|
|
|
"""Return an uploader module with appropriate utils methods mocked"""
|
2015-09-19 02:36:43 +02:00
|
|
|
from twine.commands import upload
|
|
|
|
monkeypatch.setattr(upload.utils, 'get_repository_from_config',
|
|
|
|
lambda *x: pypirc)
|
Update Tests for New Twine
* Updated .travis.yml to fix PEP 440 warnings
* Fixed twine calls
We were getting test failures on multiple branches in
`test_server.py`. I first investigated a warning message
popping up in every test run:
```
PEP440Warning,
/home/travis/virtualenv/python3.5.2/lib/python3.5/site-packages/pkg_resources/__init__.py:2510: PEP440Warning: 'setuptools (git-0.4.0)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
```
Moving the installation of setuptools, pip, sphinx, and tox
into the `install` key for Travis resolved that issue, but
`test_server.py` tests were still failing. It turns out that
Twine 1.7.0 added support for SSL cert specification and,
in the process, changed the call signature for the `upload`
and `register` internal methods.
This PR fixes the calls so that they align with Twine's new
function signature. Note that tests now fail on Twine <1.7.0,
so I have also updated the dev requirements file.
2016-07-17 20:40:06 +02:00
|
|
|
monkeypatch.setattr(upload.utils, 'get_cacert', lambda *x: None)
|
|
|
|
monkeypatch.setattr(upload.utils, 'get_clientcert', lambda *x: None)
|
2017-11-14 17:47:27 +01:00
|
|
|
upload_func = upload.upload
|
|
|
|
if 'repository_url' in upload_func.__code__.co_varnames:
|
|
|
|
# Twine added a required "repository_url" kwarg in August 2016.
|
|
|
|
# See https://github.com/pypa/twine/pull/203#event-744483850
|
|
|
|
upload_func = functools.partial(upload_func, repository_url=None)
|
|
|
|
monkeypatch.setattr(upload, 'upload', upload_func)
|
2015-09-19 02:36:43 +02:00
|
|
|
return upload
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def registerer(pypirc, monkeypatch):
|
Update Tests for New Twine
* Updated .travis.yml to fix PEP 440 warnings
* Fixed twine calls
We were getting test failures on multiple branches in
`test_server.py`. I first investigated a warning message
popping up in every test run:
```
PEP440Warning,
/home/travis/virtualenv/python3.5.2/lib/python3.5/site-packages/pkg_resources/__init__.py:2510: PEP440Warning: 'setuptools (git-0.4.0)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
```
Moving the installation of setuptools, pip, sphinx, and tox
into the `install` key for Travis resolved that issue, but
`test_server.py` tests were still failing. It turns out that
Twine 1.7.0 added support for SSL cert specification and,
in the process, changed the call signature for the `upload`
and `register` internal methods.
This PR fixes the calls so that they align with Twine's new
function signature. Note that tests now fail on Twine <1.7.0,
so I have also updated the dev requirements file.
2016-07-17 20:40:06 +02:00
|
|
|
"""Return register module with appropriate utils methods mocked"""
|
2015-09-19 02:36:43 +02:00
|
|
|
from twine.commands import register
|
|
|
|
monkeypatch.setattr(register.utils, 'get_repository_from_config',
|
|
|
|
lambda *x: pypirc)
|
2017-11-14 17:47:27 +01:00
|
|
|
reg_func = register.register
|
|
|
|
if 'repository_url' in reg_func.__code__.co_varnames:
|
|
|
|
# Twine added a required "repository_url" kwarg in August 2016.
|
|
|
|
# See https://github.com/pypa/twine/pull/203#event-744483850
|
|
|
|
reg_func = functools.partial(reg_func, repository_url=None)
|
|
|
|
monkeypatch.setattr(register, 'register', reg_func)
|
2015-09-19 02:36:43 +02:00
|
|
|
return register
|
|
|
|
|
|
|
|
|
2015-09-18 20:20:01 +02:00
|
|
|
@pytest.mark.skipif(sys.version_info[:2] == (3, 2),
|
Update Tests for New Twine
* Updated .travis.yml to fix PEP 440 warnings
* Fixed twine calls
We were getting test failures on multiple branches in
`test_server.py`. I first investigated a warning message
popping up in every test run:
```
PEP440Warning,
/home/travis/virtualenv/python3.5.2/lib/python3.5/site-packages/pkg_resources/__init__.py:2510: PEP440Warning: 'setuptools (git-0.4.0)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
```
Moving the installation of setuptools, pip, sphinx, and tox
into the `install` key for Travis resolved that issue, but
`test_server.py` tests were still failing. It turns out that
Twine 1.7.0 added support for SSL cert specification and,
in the process, changed the call signature for the `upload`
and `register` internal methods.
This PR fixes the calls so that they align with Twine's new
function signature. Note that tests now fail on Twine <1.7.0,
so I have also updated the dev requirements file.
2016-07-17 20:40:06 +02:00
|
|
|
reason="urllib3 fails on twine (see https://travis-ci"
|
|
|
|
".org/ankostis/pypiserver/builds/81044993)")
|
2015-09-20 18:35:11 +02:00
|
|
|
def test_twineUpload_open(empty_packdir, port, package, uploader, pypirc):
|
Update Tests for New Twine
* Updated .travis.yml to fix PEP 440 warnings
* Fixed twine calls
We were getting test failures on multiple branches in
`test_server.py`. I first investigated a warning message
popping up in every test run:
```
PEP440Warning,
/home/travis/virtualenv/python3.5.2/lib/python3.5/site-packages/pkg_resources/__init__.py:2510: PEP440Warning: 'setuptools (git-0.4.0)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
```
Moving the installation of setuptools, pip, sphinx, and tox
into the `install` key for Travis resolved that issue, but
`test_server.py` tests were still failing. It turns out that
Twine 1.7.0 added support for SSL cert specification and,
in the process, changed the call signature for the `upload`
and `register` internal methods.
This PR fixes the calls so that they align with Twine's new
function signature. Note that tests now fail on Twine <1.7.0,
so I have also updated the dev requirements file.
2016-07-17 20:40:06 +02:00
|
|
|
"""Test twine upload with no authentication"""
|
2015-09-20 18:35:11 +02:00
|
|
|
user, pswd = 'foo', 'bar'
|
|
|
|
update_pypirc(pypirc, port, user=user, pswd=pswd)
|
|
|
|
with new_server(empty_packdir, port):
|
2015-09-20 19:26:22 +02:00
|
|
|
uploader.upload([package.strpath], repository='test',
|
2015-09-18 19:05:07 +02:00
|
|
|
sign=None, identity=None,
|
2015-09-20 18:35:11 +02:00
|
|
|
username=user, password=pswd,
|
|
|
|
comment=None, sign_with=None,
|
Update Tests for New Twine
* Updated .travis.yml to fix PEP 440 warnings
* Fixed twine calls
We were getting test failures on multiple branches in
`test_server.py`. I first investigated a warning message
popping up in every test run:
```
PEP440Warning,
/home/travis/virtualenv/python3.5.2/lib/python3.5/site-packages/pkg_resources/__init__.py:2510: PEP440Warning: 'setuptools (git-0.4.0)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
```
Moving the installation of setuptools, pip, sphinx, and tox
into the `install` key for Travis resolved that issue, but
`test_server.py` tests were still failing. It turns out that
Twine 1.7.0 added support for SSL cert specification and,
in the process, changed the call signature for the `upload`
and `register` internal methods.
This PR fixes the calls so that they align with Twine's new
function signature. Note that tests now fail on Twine <1.7.0,
so I have also updated the dev requirements file.
2016-07-17 20:40:06 +02:00
|
|
|
config_file=None, skip_existing=None,
|
|
|
|
cert=None, client_cert=None)
|
2015-12-20 19:33:48 +01:00
|
|
|
time.sleep(SLEEP_AFTER_SRV)
|
2015-09-20 19:26:22 +02:00
|
|
|
assert len(empty_packdir.listdir()) == 1
|
2015-09-20 18:35:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.skipif(sys.version_info[:2] == (3, 2),
|
Update Tests for New Twine
* Updated .travis.yml to fix PEP 440 warnings
* Fixed twine calls
We were getting test failures on multiple branches in
`test_server.py`. I first investigated a warning message
popping up in every test run:
```
PEP440Warning,
/home/travis/virtualenv/python3.5.2/lib/python3.5/site-packages/pkg_resources/__init__.py:2510: PEP440Warning: 'setuptools (git-0.4.0)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
```
Moving the installation of setuptools, pip, sphinx, and tox
into the `install` key for Travis resolved that issue, but
`test_server.py` tests were still failing. It turns out that
Twine 1.7.0 added support for SSL cert specification and,
in the process, changed the call signature for the `upload`
and `register` internal methods.
This PR fixes the calls so that they align with Twine's new
function signature. Note that tests now fail on Twine <1.7.0,
so I have also updated the dev requirements file.
2016-07-17 20:40:06 +02:00
|
|
|
reason="urllib3 fails on twine (see https://travis-ci"
|
|
|
|
".org/ankostis/pypiserver/builds/81044993)")
|
2015-09-20 19:26:22 +02:00
|
|
|
def test_twineUpload_authed(empty_packdir, port, package, uploader, pypirc):
|
Update Tests for New Twine
* Updated .travis.yml to fix PEP 440 warnings
* Fixed twine calls
We were getting test failures on multiple branches in
`test_server.py`. I first investigated a warning message
popping up in every test run:
```
PEP440Warning,
/home/travis/virtualenv/python3.5.2/lib/python3.5/site-packages/pkg_resources/__init__.py:2510: PEP440Warning: 'setuptools (git-0.4.0)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
```
Moving the installation of setuptools, pip, sphinx, and tox
into the `install` key for Travis resolved that issue, but
`test_server.py` tests were still failing. It turns out that
Twine 1.7.0 added support for SSL cert specification and,
in the process, changed the call signature for the `upload`
and `register` internal methods.
This PR fixes the calls so that they align with Twine's new
function signature. Note that tests now fail on Twine <1.7.0,
so I have also updated the dev requirements file.
2016-07-17 20:40:06 +02:00
|
|
|
"""Test authenticated twine upload"""
|
2015-09-20 18:35:11 +02:00
|
|
|
user, pswd = 'a', 'a'
|
|
|
|
update_pypirc(pypirc, port, user=user, pswd=pswd)
|
2015-09-20 19:26:22 +02:00
|
|
|
with new_server(empty_packdir, port, authed=False):
|
|
|
|
uploader.upload([package.strpath], repository='test',
|
2015-09-20 18:35:11 +02:00
|
|
|
sign=None, identity=None,
|
|
|
|
username=user, password=pswd,
|
2015-09-18 19:05:07 +02:00
|
|
|
comment=None, sign_with=None,
|
Update Tests for New Twine
* Updated .travis.yml to fix PEP 440 warnings
* Fixed twine calls
We were getting test failures on multiple branches in
`test_server.py`. I first investigated a warning message
popping up in every test run:
```
PEP440Warning,
/home/travis/virtualenv/python3.5.2/lib/python3.5/site-packages/pkg_resources/__init__.py:2510: PEP440Warning: 'setuptools (git-0.4.0)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
```
Moving the installation of setuptools, pip, sphinx, and tox
into the `install` key for Travis resolved that issue, but
`test_server.py` tests were still failing. It turns out that
Twine 1.7.0 added support for SSL cert specification and,
in the process, changed the call signature for the `upload`
and `register` internal methods.
This PR fixes the calls so that they align with Twine's new
function signature. Note that tests now fail on Twine <1.7.0,
so I have also updated the dev requirements file.
2016-07-17 20:40:06 +02:00
|
|
|
config_file=None, skip_existing=None,
|
|
|
|
cert=None, client_cert=None)
|
2015-12-20 19:33:48 +01:00
|
|
|
time.sleep(SLEEP_AFTER_SRV)
|
2015-09-20 19:26:22 +02:00
|
|
|
assert len(empty_packdir.listdir()) == 1
|
2015-09-18 19:05:07 +02:00
|
|
|
|
2015-09-19 01:02:27 +02:00
|
|
|
assert empty_packdir.join(
|
|
|
|
package.basename).check(), (package.basename, empty_packdir.listdir())
|
|
|
|
|
|
|
|
|
2017-11-14 17:47:27 +01:00
|
|
|
@pytest.mark.skipif(sys.version_info[:2] == (3, 2),
|
|
|
|
reason="urllib3 fails on twine (see https://travis-ci"
|
|
|
|
".org/ankostis/pypiserver/builds/81044993)")
|
|
|
|
def test_twine_upload_partial_authed(empty_packdir, port, package, uploader,
|
|
|
|
pypirc):
|
|
|
|
"""Test partially authenticated twine upload"""
|
|
|
|
user, pswd = 'a', 'a'
|
|
|
|
update_pypirc(pypirc, port, user=user, pswd=pswd)
|
|
|
|
with new_server(empty_packdir, port, authed='partial'):
|
|
|
|
uploader.upload([package.strpath], repository='test',
|
|
|
|
sign=None, identity=None,
|
|
|
|
username=user, password=pswd,
|
|
|
|
comment=None, sign_with=None,
|
|
|
|
config_file=None, skip_existing=None,
|
|
|
|
cert=None, client_cert=None)
|
|
|
|
time.sleep(SLEEP_AFTER_SRV)
|
|
|
|
assert len(empty_packdir.listdir()) == 1
|
|
|
|
|
|
|
|
|
2015-09-20 18:35:11 +02:00
|
|
|
@pytest.mark.skipif(sys.version_info[:2] == (3, 2),
|
Update Tests for New Twine
* Updated .travis.yml to fix PEP 440 warnings
* Fixed twine calls
We were getting test failures on multiple branches in
`test_server.py`. I first investigated a warning message
popping up in every test run:
```
PEP440Warning,
/home/travis/virtualenv/python3.5.2/lib/python3.5/site-packages/pkg_resources/__init__.py:2510: PEP440Warning: 'setuptools (git-0.4.0)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
```
Moving the installation of setuptools, pip, sphinx, and tox
into the `install` key for Travis resolved that issue, but
`test_server.py` tests were still failing. It turns out that
Twine 1.7.0 added support for SSL cert specification and,
in the process, changed the call signature for the `upload`
and `register` internal methods.
This PR fixes the calls so that they align with Twine's new
function signature. Note that tests now fail on Twine <1.7.0,
so I have also updated the dev requirements file.
2016-07-17 20:40:06 +02:00
|
|
|
reason="urllib3 fails on twine (see https://travis-ci"
|
|
|
|
".org/ankostis/pypiserver/builds/81044993)")
|
2015-09-20 18:35:11 +02:00
|
|
|
def test_twineRegister_open(open_server, package, registerer, pypirc):
|
Update Tests for New Twine
* Updated .travis.yml to fix PEP 440 warnings
* Fixed twine calls
We were getting test failures on multiple branches in
`test_server.py`. I first investigated a warning message
popping up in every test run:
```
PEP440Warning,
/home/travis/virtualenv/python3.5.2/lib/python3.5/site-packages/pkg_resources/__init__.py:2510: PEP440Warning: 'setuptools (git-0.4.0)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
```
Moving the installation of setuptools, pip, sphinx, and tox
into the `install` key for Travis resolved that issue, but
`test_server.py` tests were still failing. It turns out that
Twine 1.7.0 added support for SSL cert specification and,
in the process, changed the call signature for the `upload`
and `register` internal methods.
This PR fixes the calls so that they align with Twine's new
function signature. Note that tests now fail on Twine <1.7.0,
so I have also updated the dev requirements file.
2016-07-17 20:40:06 +02:00
|
|
|
"""Test unauthenticated twine registration"""
|
2015-09-20 18:35:11 +02:00
|
|
|
srv = open_server
|
|
|
|
update_pypirc(pypirc, srv.port)
|
|
|
|
registerer.register(package.strpath, repository='test',
|
|
|
|
username='foo', password='bar',
|
Update Tests for New Twine
* Updated .travis.yml to fix PEP 440 warnings
* Fixed twine calls
We were getting test failures on multiple branches in
`test_server.py`. I first investigated a warning message
popping up in every test run:
```
PEP440Warning,
/home/travis/virtualenv/python3.5.2/lib/python3.5/site-packages/pkg_resources/__init__.py:2510: PEP440Warning: 'setuptools (git-0.4.0)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
```
Moving the installation of setuptools, pip, sphinx, and tox
into the `install` key for Travis resolved that issue, but
`test_server.py` tests were still failing. It turns out that
Twine 1.7.0 added support for SSL cert specification and,
in the process, changed the call signature for the `upload`
and `register` internal methods.
This PR fixes the calls so that they align with Twine's new
function signature. Note that tests now fail on Twine <1.7.0,
so I have also updated the dev requirements file.
2016-07-17 20:40:06 +02:00
|
|
|
comment=None, config_file=None,
|
|
|
|
cert=None, client_cert=None)
|
2015-09-20 18:35:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.skipif(sys.version_info[:2] == (3, 2),
|
Update Tests for New Twine
* Updated .travis.yml to fix PEP 440 warnings
* Fixed twine calls
We were getting test failures on multiple branches in
`test_server.py`. I first investigated a warning message
popping up in every test run:
```
PEP440Warning,
/home/travis/virtualenv/python3.5.2/lib/python3.5/site-packages/pkg_resources/__init__.py:2510: PEP440Warning: 'setuptools (git-0.4.0)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
```
Moving the installation of setuptools, pip, sphinx, and tox
into the `install` key for Travis resolved that issue, but
`test_server.py` tests were still failing. It turns out that
Twine 1.7.0 added support for SSL cert specification and,
in the process, changed the call signature for the `upload`
and `register` internal methods.
This PR fixes the calls so that they align with Twine's new
function signature. Note that tests now fail on Twine <1.7.0,
so I have also updated the dev requirements file.
2016-07-17 20:40:06 +02:00
|
|
|
reason="urllib3 fails on twine (see https://travis-ci"
|
|
|
|
".org/ankostis/pypiserver/builds/81044993)")
|
2015-09-20 19:26:22 +02:00
|
|
|
def test_twineRegister_authedOk(protected_server, package, registerer, pypirc):
|
Update Tests for New Twine
* Updated .travis.yml to fix PEP 440 warnings
* Fixed twine calls
We were getting test failures on multiple branches in
`test_server.py`. I first investigated a warning message
popping up in every test run:
```
PEP440Warning,
/home/travis/virtualenv/python3.5.2/lib/python3.5/site-packages/pkg_resources/__init__.py:2510: PEP440Warning: 'setuptools (git-0.4.0)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
```
Moving the installation of setuptools, pip, sphinx, and tox
into the `install` key for Travis resolved that issue, but
`test_server.py` tests were still failing. It turns out that
Twine 1.7.0 added support for SSL cert specification and,
in the process, changed the call signature for the `upload`
and `register` internal methods.
This PR fixes the calls so that they align with Twine's new
function signature. Note that tests now fail on Twine <1.7.0,
so I have also updated the dev requirements file.
2016-07-17 20:40:06 +02:00
|
|
|
"""Test authenticated twine registration"""
|
2015-09-20 18:35:11 +02:00
|
|
|
srv = protected_server
|
|
|
|
user, pswd = 'a', 'a'
|
|
|
|
update_pypirc(pypirc, srv.port, user=user, pswd=pswd)
|
|
|
|
registerer.register(package.strpath, repository='test',
|
|
|
|
username=user, password=pswd,
|
Update Tests for New Twine
* Updated .travis.yml to fix PEP 440 warnings
* Fixed twine calls
We were getting test failures on multiple branches in
`test_server.py`. I first investigated a warning message
popping up in every test run:
```
PEP440Warning,
/home/travis/virtualenv/python3.5.2/lib/python3.5/site-packages/pkg_resources/__init__.py:2510: PEP440Warning: 'setuptools (git-0.4.0)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
```
Moving the installation of setuptools, pip, sphinx, and tox
into the `install` key for Travis resolved that issue, but
`test_server.py` tests were still failing. It turns out that
Twine 1.7.0 added support for SSL cert specification and,
in the process, changed the call signature for the `upload`
and `register` internal methods.
This PR fixes the calls so that they align with Twine's new
function signature. Note that tests now fail on Twine <1.7.0,
so I have also updated the dev requirements file.
2016-07-17 20:40:06 +02:00
|
|
|
comment=None, config_file=None,
|
|
|
|
cert=None, client_cert=None)
|