test(root): test making socket

This commit is contained in:
Houkime 2024-11-19 22:43:27 +00:00
parent c8c7aed5a3
commit 644f0783ee

View file

@ -1,8 +1,14 @@
import pytest import pytest
from selfprivacy_api.root_daemon import get_available_commands, init, main, service_commands, services from selfprivacy_api.root_daemon import (
get_available_commands,
init,
main,
service_commands,
services,
)
import selfprivacy_api.root_daemon import selfprivacy_api.root_daemon
from os.path import join from os.path import join, exists
from typing import List from typing import List
@ -14,22 +20,27 @@ def test_socket(mocker, tmpdir):
"selfprivacy_api.root_daemon.SOCKET_PATH", "selfprivacy_api.root_daemon.SOCKET_PATH",
new=socket_path, new=socket_path,
) )
return socket_path
def is_in_strings(list: List[str], piece: str): def is_in_strings(list: List[str], piece: str):
return any([piece in x for x in list]) return any([piece in x for x in list])
def test_available_commands(): def test_available_commands():
commands = get_available_commands() commands = get_available_commands()
assert commands != [] assert commands != []
assert len(commands) >= len(services) * len(service_commands) assert len(commands) >= len(services) * len(service_commands)
for service in services: for service in services:
assert is_in_strings(commands, service) assert is_in_strings(commands, service)
def test_init():
init() def test_init(test_socket):
sock = init()
assert exists(test_socket)
assert sock is not None
def test_main(): def test_main():
# main() # main()
pass pass