Skip to content

Commit

Permalink
Updated tests according to authenticator changes
Browse files Browse the repository at this point in the history
  • Loading branch information
maayanbar13 committed May 27, 2022
1 parent be3e319 commit 986fb2b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 64 deletions.
53 changes: 5 additions & 48 deletions tests/fixtures/with_trusted_source/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,62 +1,19 @@
[tool.poetry]
name = "my-package"
version = "1.2.3"
description = "Some description."
authors = [
"Sébastien Eustace <sebastien@eustace.io>"
"Your Name <you@example.com>",
]
description = "Some description."
license = "MIT"

readme = "README.rst"

homepage = "https://python-poetry.org"
repository = "https://github.com/python-poetry/poetry"
documentation = "https://python-poetry.org/docs"

keywords = ["packaging", "dependency", "poetry"]

classifiers = [
"Topic :: Software Development :: Build Tools",
"Topic :: Software Development :: Libraries :: Python Modules"
]
name = "my-package"
version = "1.2.3"

# Requirements
[tool.poetry.dependencies]
python = "~2.7 || ^3.6"
cleo = "^0.6"
pendulum = { git = "https://github.com/sdispater/pendulum.git", branch = "2.0" }
requests = { version = "^2.18", optional = true, extras=[ "security" ] }
pathlib2 = { version = "^2.2", python = "~2.7" }

orator = { version = "^0.9", optional = true }

# File dependency
demo = { path = "../distributions/demo-0.1.0-py2.py3-none-any.whl" }

# Dir dependency with setup.py
my-package = { path = "../project_with_setup/" }

# Dir dependency with pyproject.toml
simple-project = { path = "../simple_project/" }


[tool.poetry.extras]
db = [ "orator" ]

[tool.poetry.dev-dependencies]
pytest = "~3.4"


[tool.poetry.scripts]
my-script = "my_package:main"


[tool.poetry.plugins."blogtool.parsers"]
".rst" = "some_module::SomeClass"


[[tool.poetry.source]]
name = "foo"
url = "https://foo.bar/simple/"
default = true
trusted = true
url = "https://foo.bar/simple/"
34 changes: 18 additions & 16 deletions tests/installation/test_pip_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,14 @@ def test_install_with_certs(mocker: MockerFixture, key: str, option: str):
assert cmd[cert_index + 1] == str(Path(client_path))


def test_requirement_git_develop_true(installer: PipInstaller, package_git: Package):
package_git.develop = True
result = installer.requirement(package_git)
expected = ["-e", "git+git@github.com:demo/demo.git@master#egg=demo"]

assert result == expected

def test_install_with_trusted_host(mocker: MockerFixture):
mocker.patch(
"poetry.utils.authenticator.Authenticator.get_certs_for_url",
return_value={"trusted": True},
)

def test_install_with_trusted_host():
default = LegacyRepository("default", "https://foo.bar")
pool = Pool()
host = "foo.bar"

default = LegacyRepository("default", f"https://{host}", trusted=True)

pool.add_repository(default, default=True)

null_env = NullEnv()
Expand All @@ -181,18 +175,26 @@ def test_install_with_trusted_host():
"foo",
"0.0.0",
source_type="legacy",
source_reference=default._name,
source_url=default._url,
source_reference=default.name,
source_url=default.url,
)

installer.install(foo)

assert len(null_env.executed) == 1
cmd = null_env.executed[0]
assert "--trusted-host" in cmd
trusted_host_index = cmd.index("--trusted-host")
cert_index = cmd.index("--trusted-host")
# Need to do the str(Path()) bit because Windows paths get modified by Path
assert cmd[cert_index + 1] == "foo.bar"


assert cmd[trusted_host_index + 1] == host
def test_requirement_git_develop_true(installer: PipInstaller, package_git: Package):
package_git.develop = True
result = installer.requirement(package_git)
expected = ["-e", "git+git@github.com:demo/demo.git@master#egg=demo"]

assert result == expected


def test_uninstall_git_package_nspkg_pth_cleanup(
Expand Down

0 comments on commit 986fb2b

Please sign in to comment.