1
0
Fork 0
mirror of synced 2024-12-21 22:21:08 -05:00
yadm/test/test_unit_private_dirs.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

35 lines
853 B
Python

"""Unit tests: private_dirs"""
import pytest
@pytest.mark.parametrize(
"gnupghome",
[True, False],
ids=["gnupghome-set", "gnupghome-unset"],
)
@pytest.mark.parametrize("param", ["all", "gnupg"])
def test_relative_path(runner, paths, gnupghome, param):
"""Test translate_to_relative"""
alt_gnupghome = "alt/gnupghome"
env_gnupghome = paths.work.join(alt_gnupghome)
script = f"""
YADM_TEST=1 source {paths.pgm}
YADM_WORK={paths.work}
private_dirs {param}
"""
env = {}
if gnupghome:
env["GNUPGHOME"] = env_gnupghome
expected = alt_gnupghome if gnupghome else ".gnupg"
if param == "all":
expected = f".ssh {expected}"
run = runner(command=["bash"], inp=script, env=env)
assert run.success
assert run.err == ""
assert run.out.strip() == expected