DevPlace CI / test (push) Failing after 44m45s
Continuous Delivery could never be turned off once a crop was planted. Add a one-shot per-plot "stop after harvest" flag (POST /game/plot/stop, Devii tool game_plot_stop, game_plots.stop_after_harvest), cleared by the next plant, autoreplant claim or Refactor. Autoreplant now also respects crop locks through the shared _crop_lock predicate. Plan and measurements in happyplanting.md. Also includes the pending community sync, node network and related work in the tree; the full suite passed (4999) with all of it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
54 lines
2.5 KiB
Python
54 lines
2.5 KiB
Python
# retoor <retoor@molodetz.nl>
|
|
|
|
from devplacepy.database.nodes import get_device
|
|
from tests.api.admin.nodes.conftest import admin_headers, make_admin, make_device
|
|
from tests.api.nodes.conftest import make_member
|
|
|
|
|
|
def test_member_cannot_override(client):
|
|
member = make_member()
|
|
device = make_device(member["uid"])
|
|
response = client.post(f"/admin/nodes/devices/{device['uid']}/class", json={"value": "allow"}, headers=admin_headers(member))
|
|
assert response.status_code == 403
|
|
|
|
|
|
def test_override_round_trip_is_visible_in_the_overview(client, admin):
|
|
owner = make_member()
|
|
device = make_device(owner["uid"])
|
|
url = f"/admin/nodes/devices/{device['uid']}/class"
|
|
response = client.post(url, json={"value": "allow"}, headers=admin_headers(admin))
|
|
assert response.status_code == 200 and response.json()["data"] == {"uid": device["uid"], "class_override": "allow"}
|
|
assert get_device(device["uid"])["class_override"] == "allow"
|
|
listed = {row["uid"]: row for row in client.get("/admin/nodes", headers=admin_headers(admin)).json()["devices"]}
|
|
assert listed[device["uid"]]["class_override"] == "allow"
|
|
client.post(url, json={"value": "clear"}, headers=admin_headers(admin))
|
|
assert not get_device(device["uid"])["class_override"]
|
|
|
|
|
|
def test_only_known_values_are_accepted(client, admin):
|
|
owner = make_member()
|
|
device = make_device(owner["uid"])
|
|
response = client.post(f"/admin/nodes/devices/{device['uid']}/class", json={"value": "deny"}, headers=admin_headers(admin))
|
|
assert response.status_code in (400, 422)
|
|
|
|
|
|
def test_unknown_device_is_404(client, admin):
|
|
assert client.post("/admin/nodes/devices/nope/class", json={"value": "allow"}, headers=admin_headers(admin)).status_code == 404
|
|
|
|
|
|
def test_junior_admin_cannot_override_a_senior_admins_device(client):
|
|
senior, junior = make_admin(), make_admin()
|
|
device = make_device(senior["uid"])
|
|
client.post(f"/admin/nodes/devices/{device['uid']}/class", json={"value": "allow"}, headers=admin_headers(junior))
|
|
assert not get_device(device["uid"]).get("class_override")
|
|
|
|
|
|
def test_the_change_is_audited(client, admin):
|
|
from devplacepy.database import get_table
|
|
|
|
owner = make_member()
|
|
device = make_device(owner["uid"])
|
|
client.post(f"/admin/nodes/devices/{device['uid']}/class", json={"value": "allow"}, headers=admin_headers(admin))
|
|
rows = list(get_table("audit_log").find(event_key="node.device.override", target_uid=device["uid"]))
|
|
assert rows and rows[0]["new_value"] == "allow"
|