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:
jimmyandClaude Opus 5.5 committed 2026-11-04 01:35:56 +13:00
1 parent 16a3d3aa26
commit 24d3c1149d
7 files changed
+14 -55

No files matched your search

+13
View File
@@ -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."""
+1 -11
View File
@@ -1,16 +1,6 @@
"""Import/export bundles (main's tests/test_profile_bundle.py over HTTP)."""
import pytest
from helpers import new_id, unique
@pytest.fixture
def profile(c):
pid = new_id(c.post("/profiles", json={"name": unique("pytest-profile")}))
assert c.post(f"/profiles/{pid}/apply").status_code == 200
yield pid
c.delete(f"/profiles/{pid}")
from helpers import new_id
def test_profile_round_trip(c, profile):
-8
View File
@@ -7,14 +7,6 @@ from helpers import find_id_by_field, new_id, unique
MAC = "aabbccddee01" # made up: no driver answers it
@pytest.fixture
def profile(c):
pid = new_id(c.post("/profiles", json={"name": unique("pytest-profile")}))
assert c.post(f"/profiles/{pid}/apply").status_code == 200
yield pid
c.delete(f"/profiles/{pid}")
@pytest.fixture
def device(c):
c.delete(f"/devices/{MAC}")
-8
View File
@@ -3,14 +3,6 @@ import pytest
from helpers import new_id, unique
@pytest.fixture
def profile(c):
pid = new_id(c.post("/profiles", json={"name": unique("pytest-profile")}))
assert c.post(f"/profiles/{pid}/apply").status_code == 200
yield pid
c.delete(f"/profiles/{pid}")
@pytest.fixture
def preset(c, profile):
resp = c.post("/presets", json={"name": unique("pytest-preset"), "pattern": "on",
-12
View File
@@ -1,21 +1,9 @@
import pytest
from helpers import new_id, unique
# Presets every new profile is seeded with (main's controllers/profile.py)
SEEDED = {"on", "off", "rainbow", "Colour Cycle", "transition", "flicker", "flame", "twinkle"}
@pytest.fixture
def profile(c):
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}")
def test_list(c, profile):
resp = c.get("/profiles")
assert resp.status_code == 200
-8
View File
@@ -10,14 +10,6 @@ from helpers import find_id_by_field, new_id, unique
BEAT_S = 0.3
@pytest.fixture
def profile(c):
pid = new_id(c.post("/profiles", json={"name": unique("pytest-profile")}))
assert c.post(f"/profiles/{pid}/apply").status_code == 200
yield pid
c.delete(f"/profiles/{pid}")
@pytest.fixture
def clock(c):
"""Beats from the clock at 200 BPM; mic timing is restored afterwards."""
-8
View File
@@ -3,14 +3,6 @@ import pytest
from helpers import new_id, unique
@pytest.fixture
def profile(c):
pid = new_id(c.post("/profiles", json={"name": unique("pytest-profile")}))
assert c.post(f"/profiles/{pid}/apply").status_code == 200
yield pid
c.delete(f"/profiles/{pid}")
@pytest.fixture
def zone(c, profile):
name = unique("pytest-zone")