-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,34 @@ def test_install_github_vcs(pipenv_instance_pypi): | |
c = p.pipenv("install git+https://github.com/reagento/[email protected]") | ||
assert not c.returncode | ||
assert "dataclass-factory" in p.pipfile["packages"] | ||
|
||
|
||
@pytest.mark.basic | ||
@pytest.mark.install | ||
@pytest.mark.parametrize("use_credentials", [True, False]) | ||
def test_install_github_vcs_with_credentials(pipenv_instance_pypi, use_credentials): | ||
with pipenv_instance_pypi() as p: | ||
# Set environment variables | ||
os.environ['GIT_REPO'] = 'github.com/reagento/adaptix.git' | ||
if use_credentials: | ||
os.environ['GIT_USERNAME'] = 'git' # Use 'git' as a dummy username | ||
os.environ['GIT_PASSWORD'] = '' # Empty password for public repos | ||
url = f"git+https://${{GIT_USERNAME}}:${{GIT_PASSWORD}}@${{GIT_REPO}}@2.16" | ||
else: | ||
url = f"git+https://${{GIT_REPO}}@2.16" | ||
|
||
c = p.pipenv(f"install {url}") | ||
assert not c.returncode | ||
assert "adaptix" in p.pipfile["packages"] | ||
|
||
# Check if the URL in the lockfile still contains the environment variables | ||
lockfile_content = p.lockfile | ||
assert "${GIT_REPO}" in lockfile_content['default']['adaptix']['git'] | ||
if use_credentials: | ||
assert "${GIT_USERNAME}" in lockfile_content['default']['adaptix']['git'] | ||
assert "${GIT_PASSWORD}" in lockfile_content['default']['adaptix']['git'] | ||
|
||
# Verify that the package is installed and usable | ||
c = p.pipenv("run python -c 'import adaptix; print(adaptix.__version__)'") | ||
assert not c.returncode | ||
assert "2.16" in c.stdout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import pytest | ||
from pipenv.utils.dependencies import clean_resolved_dep | ||
|
||
def test_clean_resolved_dep_with_vcs_url(): | ||
project = {} # Mock project object, adjust as needed | ||
dep = { | ||
"name": "example-package", | ||
"git": "git+https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/username/repo.git", | ||
"ref": "main" | ||
} | ||
|
||
result = clean_resolved_dep(project, dep) | ||
|
||
assert "example-package" in result | ||
assert result["example-package"]["git"] == "git+https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/username/repo.git" | ||
assert result["example-package"]["ref"] == "main" | ||
|
||
def test_clean_resolved_dep_with_vcs_url_and_extras(): | ||
project = {} # Mock project object, adjust as needed | ||
dep = { | ||
"name": "example-package", | ||
"git": "git+https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/username/repo.git[extra1,extra2]", | ||
"ref": "main" | ||
} | ||
|
||
result = clean_resolved_dep(project, dep) | ||
|
||
assert "example-package" in result | ||
assert result["example-package"]["git"] == "git+https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/username/repo.git[extra1,extra2]" | ||
assert result["example-package"]["ref"] == "main" | ||
assert result["example-package"]["extras"] == ["extra1", "extra2"] |