can execute files and install packages

This commit is contained in:
Stanislas Jouffroy 2025-03-04 22:36:00 +01:00
parent 230cf99f06
commit f611ef603b
3 changed files with 42 additions and 2 deletions

View file

@ -1,3 +1,4 @@
import subprocess
from pathlib import Path
from majordome import local_files
@ -49,3 +50,26 @@ def test_download_and_make_executable(clean_tmpdir):
assert tmp_file.read_bytes() == file_content
assert tmp_file.stat().st_mode == 0o100775
def test_install_package():
file = Path("/home/stan/Téléchargements/freetube_0.23.2_amd64.deb")
local_files.install_package(file)
apt = subprocess.Popen(("apt", "list", "--installed"), stdout=subprocess.PIPE)
output = subprocess.check_output(("grep", "freetube"), stdin=apt.stdout)
apt.wait()
assert "0.23.2" in output.decode("utf-8")
def test_run():
file = Path("/home/stan/Logiciels/Nextcloud-3.14.2-x86_64.AppImage")
local_files.run(file)
ps = subprocess.Popen(("ps", "-ef"), stdout=subprocess.PIPE)
output = subprocess.check_output(("grep", str(file)), stdin=ps.stdout)
ps.wait()
assert output is not None
assert str(file) in output.decode("utf-8")