37 lines
890 B
Python
37 lines
890 B
Python
# retoor <retoor@molodetz.nl>
|
|
|
|
import pytest
|
|
from fastapi.testclient import TestClient
|
|
|
|
from devplacepy.database import get_setting, set_setting
|
|
from devplacepy.database.nodes import create_device
|
|
from devplacepy.main import app
|
|
from tests.api.nodes.conftest import make_member
|
|
|
|
JSON = {"Accept": "application/json"}
|
|
|
|
|
|
def admin_headers(who: dict) -> dict:
|
|
return {**who["headers"], **JSON}
|
|
|
|
|
|
def make_admin() -> dict:
|
|
return make_member(consent=False, enabled=False, role="Admin")
|
|
|
|
|
|
def make_device(owner_uid: str, label: str = "Home laptop") -> dict:
|
|
return create_device(owner_uid, label=label, kind="native")[0]
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def client():
|
|
previous = get_setting("nodes_enabled", "0")
|
|
with TestClient(app) as test_client:
|
|
yield test_client
|
|
set_setting("nodes_enabled", previous)
|
|
|
|
|
|
@pytest.fixture
|
|
def admin():
|
|
return make_admin()
|