Skip to content

Commit

Permalink
Add test for lock check passing (and fix incorrect fail test)
Browse files Browse the repository at this point in the history
  • Loading branch information
cliebBS committed Mar 12, 2021
1 parent 5ff8c61 commit b6bd0bb
Show file tree
Hide file tree
Showing 3 changed files with 199 additions and 1 deletion.
33 changes: 32 additions & 1 deletion tests/console/commands/test_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,52 @@ def poetry_with_outdated_lockfile(project_factory, fixture_dir):
return _project_factory("outdated_lock", project_factory, fixture_dir)


@pytest.fixture
def poetry_with_up_to_date_lockfile(project_factory, fixture_dir):
return _project_factory("up_to_date_lock", project_factory, fixture_dir)


@pytest.fixture
def poetry_with_old_lockfile(project_factory, fixture_dir):
return _project_factory("old_lock", project_factory, fixture_dir)


def test_lock_check(command_tester_factory, poetry_with_outdated_lockfile, http):
def test_lock_check_outdated(
command_tester_factory, poetry_with_outdated_lockfile, http
):
http.disable()

locker = Locker(
lock=poetry_with_outdated_lockfile.pyproject.file.path.parent / "poetry.lock",
local_config=poetry_with_outdated_lockfile.locker._local_config,
)
poetry_with_outdated_lockfile.set_locker(locker)

tester = command_tester_factory("lock", poetry=poetry_with_outdated_lockfile)
status_code = tester.execute("--check")

# exit with an error
assert status_code == 1


def test_lock_check_up_to_date(
command_tester_factory, poetry_with_up_to_date_lockfile, http
):
http.disable()

locker = Locker(
lock=poetry_with_up_to_date_lockfile.pyproject.file.path.parent / "poetry.lock",
local_config=poetry_with_up_to_date_lockfile.locker._local_config,
)
poetry_with_up_to_date_lockfile.set_locker(locker)

tester = command_tester_factory("lock", poetry=poetry_with_up_to_date_lockfile)
status_code = tester.execute("--check")

# exit with an error
assert status_code == 0


def test_lock_no_update(command_tester_factory, poetry_with_old_lockfile, repo):
repo.add_package(get_package("sampleproject", "1.3.1"))
repo.add_package(get_package("sampleproject", "2.0.0"))
Expand Down
152 changes: 152 additions & 0 deletions tests/fixtures/up_to_date_lock/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions tests/fixtures/up_to_date_lock/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[tool.poetry]
name = "foobar"
version = "0.1.0"
description = ""
authors = ["Poetry Developer <developer@python-poetry.org>"]

[tool.poetry.dependencies]
python = "^3.8"
docker = "4.3.1"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

0 comments on commit b6bd0bb

Please sign in to comment.