mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-29 15:31:28 +00:00
Make Huey run immediately when testing
This commit is contained in:
parent
cd5ae80931
commit
c92294350f
|
@ -1,8 +1,14 @@
|
|||
"""MiniHuey singleton."""
|
||||
import os
|
||||
from huey import SqliteHuey
|
||||
|
||||
HUEY_DATABASE = "/etc/nixos/userdata/tasks.db"
|
||||
|
||||
# Singleton instance containing the huey database.
|
||||
|
||||
huey = SqliteHuey(HUEY_DATABASE)
|
||||
test_mode = os.environ.get("TEST_MODE")
|
||||
|
||||
huey = SqliteHuey(
|
||||
HUEY_DATABASE,
|
||||
immediate=test_mode == "true",
|
||||
)
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
"""Tests configuration."""
|
||||
# pylint: disable=redefined-outer-name
|
||||
# pylint: disable=unused-argument
|
||||
import os
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
os.environ["TEST_MODE"] = "true"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def tokens_file(mocker, shared_datadir):
|
||||
"""Mock tokens file."""
|
||||
|
@ -17,10 +22,7 @@ def tokens_file(mocker, shared_datadir):
|
|||
@pytest.fixture
|
||||
def jobs_file(mocker, shared_datadir):
|
||||
"""Mock tokens file."""
|
||||
mock = mocker.patch(
|
||||
"selfprivacy_api.utils.JOBS_FILE",
|
||||
shared_datadir / "jobs.json"
|
||||
)
|
||||
mock = mocker.patch("selfprivacy_api.utils.JOBS_FILE", shared_datadir / "jobs.json")
|
||||
return mock
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# pylint: disable=redefined-outer-name
|
||||
# pylint: disable=unused-argument
|
||||
import json
|
||||
import os
|
||||
import pytest
|
||||
|
||||
from selfprivacy_api.utils import WriteUserData, ReadUserData
|
||||
|
@ -28,3 +29,12 @@ def test_write_invalid_user_data():
|
|||
with pytest.raises(ValueError):
|
||||
with WriteUserData("invalid") as user_data:
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def test_mode():
|
||||
return os.environ.get("TEST_MODE")
|
||||
|
||||
|
||||
def test_the_test_mode(test_mode):
|
||||
assert test_mode == "true"
|
||||
|
|
Loading…
Reference in a new issue