test_helpers.py (poetry-1.1.15) | : | test_helpers.py (poetry-1.2.0) | ||
---|---|---|---|---|
from __future__ import annotations | ||||
from poetry.core.utils.helpers import parse_requires | from poetry.core.utils.helpers import parse_requires | |||
from poetry.utils._compat import Path | ||||
from poetry.utils.helpers import get_cert | from poetry.utils.helpers import safe_extra | |||
from poetry.utils.helpers import get_client_cert | ||||
def test_parse_requires(): | def test_parse_requires(): | |||
requires = """\ | requires = """\ | |||
jsonschema>=2.6.0.0,<3.0.0.0 | jsonschema>=2.6.0.0,<3.0.0.0 | |||
lockfile>=0.12.0.0,<0.13.0.0 | lockfile>=0.12.0.0,<0.13.0.0 | |||
pip-tools>=1.11.0.0,<2.0.0.0 | pip-tools>=1.11.0.0,<2.0.0.0 | |||
pkginfo>=1.4.0.0,<2.0.0.0 | pkginfo>=1.4.0.0,<2.0.0.0 | |||
pyrsistent>=0.14.2.0,<0.15.0.0 | pyrsistent>=0.14.2.0,<0.15.0.0 | |||
toml>=0.9.0.0,<0.10.0.0 | toml>=0.9.0.0,<0.10.0.0 | |||
cleo>=0.6.0.0,<0.7.0.0 | cleo>=0.6.0.0,<0.7.0.0 | |||
cachy>=0.1.1.0,<0.2.0.0 | cachy>=0.1.1.0,<0.2.0.0 | |||
cachecontrol>=0.12.4.0,<0.13.0.0 | cachecontrol>=0.12.4.0,<0.13.0.0 | |||
requests>=2.18.0.0,<3.0.0.0 | requests>=2.18.0.0,<3.0.0.0 | |||
msgpack-python>=0.5.0.0,<0.6.0.0 | msgpack-python>=0.5.0.0,<0.6.0.0 | |||
pyparsing>=2.2.0.0,<3.0.0.0 | pyparsing>=2.2.0.0,<3.0.0.0 | |||
requests-toolbelt>=0.8.0.0,<0.9.0.0 | requests-toolbelt>=0.8.0.0,<0.9.0.0 | |||
[:(python_version >= "2.7.0.0" and python_version < "2.8.0.0") or (python_versio | [:(python_version >= "2.7.0.0" and python_version < "2.8.0.0")\ | |||
n >= "3.4.0.0" and python_version < "3.5.0.0")] | or (python_version >= "3.4.0.0" and python_version < "3.5.0.0")] | |||
typing>=3.6.0.0,<4.0.0.0 | typing>=3.6.0.0,<4.0.0.0 | |||
[:python_version >= "2.7.0.0" and python_version < "2.8.0.0"] | [:python_version >= "2.7.0.0" and python_version < "2.8.0.0"] | |||
virtualenv>=15.2.0.0,<16.0.0.0 | virtualenv>=15.2.0.0,<16.0.0.0 | |||
pathlib2>=2.3.0.0,<3.0.0.0 | pathlib2>=2.3.0.0,<3.0.0.0 | |||
[:python_version >= "3.4.0.0" and python_version < "3.6.0.0"] | [:python_version >= "3.4.0.0" and python_version < "3.6.0.0"] | |||
zipfile36>=0.1.0.0,<0.2.0.0 | zipfile36>=0.1.0.0,<0.2.0.0 | |||
[dev] | [dev] | |||
isort@ git+git://github.com/timothycrosley/isort.git@e63ae06ec7d70b06df9e5283576 50281a3d3ec22#egg=isort | isort@ git+git://github.com/timothycrosley/isort.git@e63ae06ec7d70b06df9e5283576 50281a3d3ec22#egg=isort | |||
""" | """ # noqa: E501 | |||
result = parse_requires(requires) | result = parse_requires(requires) | |||
# fmt: off | ||||
expected = [ | expected = [ | |||
"jsonschema>=2.6.0.0,<3.0.0.0", | "jsonschema>=2.6.0.0,<3.0.0.0", | |||
"lockfile>=0.12.0.0,<0.13.0.0", | "lockfile>=0.12.0.0,<0.13.0.0", | |||
"pip-tools>=1.11.0.0,<2.0.0.0", | "pip-tools>=1.11.0.0,<2.0.0.0", | |||
"pkginfo>=1.4.0.0,<2.0.0.0", | "pkginfo>=1.4.0.0,<2.0.0.0", | |||
"pyrsistent>=0.14.2.0,<0.15.0.0", | "pyrsistent>=0.14.2.0,<0.15.0.0", | |||
"toml>=0.9.0.0,<0.10.0.0", | "toml>=0.9.0.0,<0.10.0.0", | |||
"cleo>=0.6.0.0,<0.7.0.0", | "cleo>=0.6.0.0,<0.7.0.0", | |||
"cachy>=0.1.1.0,<0.2.0.0", | "cachy>=0.1.1.0,<0.2.0.0", | |||
"cachecontrol>=0.12.4.0,<0.13.0.0", | "cachecontrol>=0.12.4.0,<0.13.0.0", | |||
"requests>=2.18.0.0,<3.0.0.0", | "requests>=2.18.0.0,<3.0.0.0", | |||
"msgpack-python>=0.5.0.0,<0.6.0.0", | "msgpack-python>=0.5.0.0,<0.6.0.0", | |||
"pyparsing>=2.2.0.0,<3.0.0.0", | "pyparsing>=2.2.0.0,<3.0.0.0", | |||
"requests-toolbelt>=0.8.0.0,<0.9.0.0", | "requests-toolbelt>=0.8.0.0,<0.9.0.0", | |||
'typing>=3.6.0.0,<4.0.0.0 ; (python_version >= "2.7.0.0" and python_vers | 'typing>=3.6.0.0,<4.0.0.0 ; (python_version >= "2.7.0.0" and python_vers | |||
ion < "2.8.0.0") or (python_version >= "3.4.0.0" and python_version < "3.5.0.0") | ion < "2.8.0.0") or (python_version >= "3.4.0.0" and python_version < "3.5.0.0") | |||
', | ', # noqa: E501 | |||
'virtualenv>=15.2.0.0,<16.0.0.0 ; python_version >= "2.7.0.0" and python | 'virtualenv>=15.2.0.0,<16.0.0.0 ; python_version >= "2.7.0.0" and python | |||
_version < "2.8.0.0"', | _version < "2.8.0.0"', # noqa: E501 | |||
'pathlib2>=2.3.0.0,<3.0.0.0 ; python_version >= "2.7.0.0" and python_ver | 'pathlib2>=2.3.0.0,<3.0.0.0 ; python_version >= "2.7.0.0" and python_ver | |||
sion < "2.8.0.0"', | sion < "2.8.0.0"', # noqa: E501 | |||
'zipfile36>=0.1.0.0,<0.2.0.0 ; python_version >= "3.4.0.0" and python_ve | 'zipfile36>=0.1.0.0,<0.2.0.0 ; python_version >= "3.4.0.0" and python_ve | |||
rsion < "3.6.0.0"', | rsion < "3.6.0.0"', # noqa: E501 | |||
'isort@ git+git://github.com/timothycrosley/isort.git@e63ae06ec7d70b06df | 'isort@ git+git://github.com/timothycrosley/isort.git@e63ae06ec7d70b06df | |||
9e528357650281a3d3ec22#egg=isort ; extra == "dev"', | 9e528357650281a3d3ec22#egg=isort ; extra == "dev"', # noqa: E501 | |||
] | ] | |||
# fmt: on | ||||
assert result == expected | assert result == expected | |||
def test_get_cert(config): | def test_safe_extra(): | |||
ca_cert = "path/to/ca.pem" | extra = "pandas.CSVDataSet" | |||
config.merge({"certificates": {"foo": {"cert": ca_cert}}}) | result = safe_extra(extra) | |||
expected = "pandas.csvdataset" | ||||
assert get_cert(config, "foo") == Path(ca_cert) | assert result == expected | |||
def test_get_client_cert(config): | ||||
client_cert = "path/to/client.pem" | ||||
config.merge({"certificates": {"foo": {"client-cert": client_cert}}}) | ||||
assert get_client_cert(config, "foo") == Path(client_cert) | ||||
End of changes. 8 change blocks. | ||||
17 lines changed or deleted | 20 lines changed or added |