1
0
Fork 0
mirror of synced 2024-12-22 06:31:07 -05:00
yadm/test/test_unit_issue_legacy_path_warning.py
Erik Flodin 30fa6f08a4
Update testbed docker image
* Update base image to Ubuntu 24.10. This uses a python version where j2cli no
  longer works when installed using pip so use the version from Ubuntu instead
  which has been patched to work.

* Update shellcheck, pylint, pytest, isort, flake8, black and yamllint to the
  latest versions. This closes #502.

* Use a longer expect timeout to fix tests failing when gpg is killed due to
  this timeout.

* Explicitly flush gpg-agent's cached passwords to fix failing tests with
  latest gnupg. Also clean up after tests to avoid having gpg-agents running
  after the test (e.g. when running tests directly without docker).
2024-11-11 22:30:41 +01:00

41 lines
1.2 KiB
Python

"""Unit tests: issue_legacy_path_warning"""
import pytest
@pytest.mark.parametrize(
"legacy_path",
[
None,
"repo.git",
"files.gpg",
],
)
@pytest.mark.parametrize("override", [True, False], ids=["override", "no-override"])
@pytest.mark.parametrize("upgrade", [True, False], ids=["upgrade", "no-upgrade"])
def test_legacy_warning(tmpdir, runner, yadm, upgrade, override, legacy_path):
"""Use issue_legacy_path_warning"""
home = tmpdir.mkdir("home")
if legacy_path:
home.ensure(f".config/yadm/{str(legacy_path)}")
override = "YADM_OVERRIDE_REPO=override" if override else ""
main_args = 'MAIN_ARGS=("upgrade")' if upgrade else ""
script = f"""
XDG_CONFIG_HOME=
XDG_DATA_HOME=
HOME={home}
YADM_TEST=1 source {yadm}
{main_args}
{override}
set_yadm_dirs
issue_legacy_path_warning
"""
run = runner(command=["bash"], inp=script)
assert run.success
assert run.out == ""
if legacy_path and (not upgrade) and (not override):
assert "Legacy paths have been detected" in run.err
else:
assert "Legacy paths have been detected" not in run.err