selfprivacy-rest-api/tests/test_jobs.py

51 lines
1.1 KiB
Python
Raw Normal View History

2022-08-15 21:31:24 +00:00
# pylint: disable=redefined-outer-name
# pylint: disable=unused-argument
import json
import pytest
from selfprivacy_api.utils import WriteUserData, ReadUserData
from selfprivacy_api.jobs import Jobs, JobStatus
2022-08-17 20:58:56 +00:00
2022-08-17 21:38:38 +00:00
def test_jobs(authorized_client, jobs_file, shared_datadir):
2022-08-15 21:31:24 +00:00
jobs = Jobs()
assert jobs.get_jobs() == []
test_job = jobs.add(
2022-08-17 20:58:56 +00:00
type_id="test",
2022-08-15 21:31:24 +00:00
name="Test job",
description="This is a test job.",
status=JobStatus.CREATED,
status_text="Status text",
progress=0,
)
assert jobs.get_jobs() == [test_job]
jobs.update(
job=test_job,
status=JobStatus.RUNNING,
status_text="Status text",
progress=50,
)
assert jobs.get_jobs() == [test_job]
2022-08-20 18:48:44 +00:00
@pytest.fixture
def mock_subprocess_run(mocker):
mock = mocker.patch("subprocess.run", autospec=True)
return mock
@pytest.fixture
def mock_shutil_move(mocker):
mock = mocker.patch("shutil.move", autospec=True)
return mock
@pytest.fixture
def mock_shutil_chown(mocker):
mock = mocker.patch("shutil.chown", autospec=True)
return mock