forked from retoor/devplacepy
Code Farm: per-plot auto-replant pause and crop-lock check; community sync and node work
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>
This commit is contained in:
@@ -429,3 +429,62 @@ def test_grant_ineligible_when_rich_returns_400(app_server, seeded_db):
|
||||
)
|
||||
r = session.post(f"{BASE_URL}/game/grant", headers=JSON)
|
||||
assert r.status_code == 400
|
||||
|
||||
|
||||
def test_plot_stop_requires_auth(app_server, seeded_db):
|
||||
r = requests.post(
|
||||
f"{BASE_URL}/game/plot/stop", data={"slot": 0, "stop": "true"}, headers=JSON
|
||||
)
|
||||
assert r.status_code in (401, 303)
|
||||
|
||||
|
||||
def test_plot_stop_without_continuous_delivery_returns_400(app_server, seeded_db):
|
||||
session, name = _signup()
|
||||
_reset_farm(name)
|
||||
session.post(f"{BASE_URL}/game/plant", data={"slot": 0, "crop": "shell"}, headers=JSON)
|
||||
r = session.post(
|
||||
f"{BASE_URL}/game/plot/stop", data={"slot": 0, "stop": "true"}, headers=JSON
|
||||
)
|
||||
assert r.status_code == 400
|
||||
|
||||
|
||||
def test_plot_stop_empty_plot_returns_400(app_server, seeded_db):
|
||||
session, name = _signup()
|
||||
_reset_farm(name)
|
||||
_set_farm(name, mastery_autoreplant=1)
|
||||
r = session.post(
|
||||
f"{BASE_URL}/game/plot/stop", data={"slot": 0, "stop": "true"}, headers=JSON
|
||||
)
|
||||
assert r.status_code == 400
|
||||
|
||||
|
||||
def test_plot_stop_leaves_plot_empty_after_harvest(app_server, seeded_db):
|
||||
session, name = _signup()
|
||||
_reset_farm(name)
|
||||
_set_farm(name, mastery_autoreplant=1)
|
||||
assert session.post(
|
||||
f"{BASE_URL}/game/plant", data={"slot": 0, "crop": "shell"}, headers=JSON
|
||||
).status_code == 200
|
||||
r = session.post(
|
||||
f"{BASE_URL}/game/plot/stop", data={"slot": 0, "stop": "true"}, headers=JSON
|
||||
)
|
||||
assert r.status_code == 200, r.text[:200]
|
||||
plot = r.json()["farm"]["plots"][0]
|
||||
assert plot["can_stop_replant"] is True and plot["stop_after_harvest"] is True
|
||||
refresh_snapshot()
|
||||
user = get_table("users").find_one(username=name)
|
||||
farm = store.get_farm(user["uid"])
|
||||
row = get_table("game_plots").find_one(farm_uid=farm["uid"], slot_index=0)
|
||||
past = (datetime.now(timezone.utc) - timedelta(days=1)).isoformat()
|
||||
get_table("game_plots").update({"uid": row["uid"], "ready_at": past}, ["uid"])
|
||||
refresh_snapshot()
|
||||
harvested = session.post(
|
||||
f"{BASE_URL}/game/harvest", data={"slot": 0}, headers=JSON
|
||||
)
|
||||
assert harvested.status_code == 200, harvested.text[:200]
|
||||
assert harvested.json()["farm"]["plots"][0]["state"] == "empty"
|
||||
resumed = session.post(
|
||||
f"{BASE_URL}/game/plant", data={"slot": 0, "crop": "python"}, headers=JSON
|
||||
)
|
||||
assert resumed.status_code == 200
|
||||
assert resumed.json()["farm"]["plots"][0]["stop_after_harvest"] is False
|
||||
|
||||
Reference in New Issue
Block a user