test(api): share one profile() fixture in conftest
Six test files each defined the same profile() fixture. It now lives once in conftest.py, with test_profiles.py's 201 check on create. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
16a3d3aa26
commit
24d3c1149d
7 files changed
+14
-55
No files matched your search
@@ -10,6 +10,8 @@ import os
|
||||
import pytest
|
||||
import requests
|
||||
|
||||
from helpers import new_id, unique
|
||||
|
||||
# Store collections (main/store.c NAMES), all reachable through GET/PUT /db/<name>
|
||||
COLLECTIONS = ["device", "zone", "preset", "profile", "palette", "pattern",
|
||||
"sequence", "scene", "group", "output", "settings"]
|
||||
@@ -55,6 +57,17 @@ def c(base_url):
|
||||
yield client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def profile(c):
|
||||
"""A new profile, made current for the test and deleted afterwards."""
|
||||
resp = c.post("/profiles", json={"name": unique("pytest-profile")})
|
||||
assert resp.status_code == 201
|
||||
pid = new_id(resp)
|
||||
assert c.post(f"/profiles/{pid}/apply").status_code == 200
|
||||
yield pid
|
||||
c.delete(f"/profiles/{pid}")
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def restore_db(request):
|
||||
"""Snapshot every collection before the run and write it back afterwards."""
|
||||
|
||||
Reference in new issue
Block a user