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:
@@ -43,7 +43,7 @@ def settings(**overrides):
|
||||
|
||||
|
||||
def node(uid="d1", user="u1", modes=("fetch",), **overrides):
|
||||
session = NodeSession(FakeSocket(), {"uid": uid, "user_uid": user, "kind": "native"})
|
||||
session = NodeSession(FakeSocket(), {"uid": uid, "user_uid": user, "kind": "native", "asn_class": "residential"})
|
||||
session.hello = {"modes": list(modes)}
|
||||
session.settings = settings(**overrides)
|
||||
session.roll_day()
|
||||
@@ -281,3 +281,48 @@ def test_choose_applies_the_owner_exclusion_to_a_shared_candidate_list(world):
|
||||
assert world.choose(found, "bob") is mine
|
||||
assert world.choose([mine], "alice") is None
|
||||
assert world.choose([], "") is None
|
||||
|
||||
|
||||
def test_a_datacenter_donor_is_not_scheduled(world):
|
||||
session = add(world)
|
||||
session.asn_class = "datacenter"
|
||||
assert world.pick(TARGET) is None
|
||||
|
||||
|
||||
def test_an_unknown_class_is_refused_unless_the_site_allows_it(world, local_db):
|
||||
from devplacepy.database import set_setting
|
||||
|
||||
session = add(world)
|
||||
session.asn_class = "unknown"
|
||||
assert world.pick(TARGET) is None
|
||||
set_setting("nodes_allow_unknown_class", "1")
|
||||
try:
|
||||
assert world.pick(TARGET) is session
|
||||
session.asn_class = "datacenter"
|
||||
assert world.pick(TARGET) is None
|
||||
finally:
|
||||
set_setting("nodes_allow_unknown_class", "0")
|
||||
|
||||
|
||||
def test_mobile_and_residential_are_eligible(world):
|
||||
for index, asn_class in enumerate(("mobile", "residential")):
|
||||
session = add(world, uid=f"c{index}", user=f"cu{index}")
|
||||
session.asn_class = asn_class
|
||||
assert len(world.candidates(TARGET)) == 2
|
||||
|
||||
|
||||
def test_an_admin_override_beats_the_class(world):
|
||||
session = add(world)
|
||||
session.asn_class = "datacenter"
|
||||
session.class_override = "allow"
|
||||
assert world.pick(TARGET) is session
|
||||
session.class_override = ""
|
||||
assert world.pick(TARGET) is None
|
||||
|
||||
|
||||
def test_class_refusals_are_counted(world):
|
||||
session = add(world)
|
||||
session.asn_class = "datacenter"
|
||||
before = world.class_refusals
|
||||
world.candidates(TARGET)
|
||||
assert world.class_refusals > before
|
||||
|
||||
Reference in New Issue
Block a user