Skip to content

Commit

Permalink
add new tests for these cases
Browse files Browse the repository at this point in the history
  • Loading branch information
matteius committed Oct 30, 2024
1 parent 452c5ba commit 293886f
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions tests/integration/test_update.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest

from pipenv.project import Project
from pipenv.routines.update import get_modified_pipfile_entries


Expand All @@ -18,8 +19,8 @@ def test_update_outdated_with_outdated_package(pipenv_instance_private_pypi, cmd
assert f"Package '{package_name}' out-of-date:" in c.stdout


def test_get_modified_pipfile_entries_new_package(pipenv_instance_private_pypi):
with pipenv_instance_private_pypi() as p:
def test_get_modified_pipfile_entries_new_package(pipenv_instance_pypi):
with pipenv_instance_pypi() as p:
# Add package to Pipfile but don't lock
p.pipenv("install requests==2.31.0")
p.remove_lockfile()
Expand All @@ -32,13 +33,13 @@ def test_get_modified_pipfile_entries_new_package(pipenv_instance_private_pypi):
'[packages]\nurllib3 = "==2.0.0"'
)
pipfile.write_text(content)

modified = get_modified_pipfile_entries(p.project, ["packages"])
project = Project()
modified = get_modified_pipfile_entries(project, ["packages"])
assert "urllib3" in modified["default"]


def test_get_modified_pipfile_entries_changed_version(pipenv_instance_private_pypi):
with pipenv_instance_private_pypi() as p:
def test_get_modified_pipfile_entries_changed_version(pipenv_instance_pypi):
with pipenv_instance_pypi() as p:
# Install and lock initial version
p.pipenv("install requests==2.31.0")

Expand All @@ -50,13 +51,13 @@ def test_get_modified_pipfile_entries_changed_version(pipenv_instance_private_py
'requests = "==2.32.0"'
)
pipfile.write_text(content)

modified = get_modified_pipfile_entries(p.project, ["packages"])
project = Project()
modified = get_modified_pipfile_entries(project, ["packages"])
assert "requests" in modified["default"]


def test_get_modified_pipfile_entries_vcs_changes(pipenv_instance_private_pypi):
with pipenv_instance_private_pypi() as p:
def test_get_modified_pipfile_entries_vcs_changes(pipenv_instance_pypi):
with pipenv_instance_pypi() as p:
# Install VCS package
p.pipenv("install git+https://github.com/requests/requests.git@main#egg=requests")

Expand All @@ -68,13 +69,13 @@ def test_get_modified_pipfile_entries_vcs_changes(pipenv_instance_private_pypi):
'ref = "master"'
)
pipfile.write_text(content)

modified = get_modified_pipfile_entries(p.project, ["packages"])
project = Project()
modified = get_modified_pipfile_entries(project, ["packages"])
assert "requests" in modified["default"]


def test_update_without_lockfile(pipenv_instance_private_pypi):
with pipenv_instance_private_pypi() as p:
def test_update_without_lockfile(pipenv_instance_pypi):
with pipenv_instance_pypi() as p:
# Install without creating lockfile
p.pipenv("install --skip-lock requests==2.31.0")
p.remove_lockfile()
Expand Down Expand Up @@ -104,15 +105,15 @@ def test_update_without_lockfile(pipenv_instance_private_pypi):
)
]
)
def test_update_modified_packages(pipenv_instance_private_pypi, pipfile_content, expected_updates):
with pipenv_instance_private_pypi() as p:
def test_update_modified_packages(pipenv_instance_pypi, pipfile_content, expected_updates):
with pipenv_instance_pypi() as p:
# Setup initial state
p.pipenv("install requests==2.31.0")

# Modify Pipfile
pipfile = p.path / "Pipfile"
pipfile.write_text(pipfile_content)

project = Project()
# Verify correct packages identified for update
modified = get_modified_pipfile_entries(p.project, ["packages", "dev-packages"])
modified = get_modified_pipfile_entries(project, ["packages", "dev-packages"])
assert set(modified["default"]).union(set(modified["develop"])) == expected_updates

0 comments on commit 293886f

Please sign in to comment.