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:
@@ -0,0 +1,55 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
import pytest
|
||||
|
||||
from devplacepy.services.nodes.registry import (
|
||||
COUNTER_NAMES,
|
||||
NodeCounters,
|
||||
outcome_name,
|
||||
)
|
||||
|
||||
|
||||
def test_inc_counts_both_the_live_view_and_the_pending_delta():
|
||||
counters = NodeCounters()
|
||||
counters.inc("kicked")
|
||||
counters.inc("kicked")
|
||||
assert counters.snapshot()["kicked"] == 2
|
||||
assert counters.take_pending() == {"kicked": 2}
|
||||
assert counters.take_pending() == {}
|
||||
assert counters.snapshot()["kicked"] == 2
|
||||
|
||||
|
||||
def test_unknown_names_are_rejected():
|
||||
counters = NodeCounters()
|
||||
with pytest.raises(KeyError):
|
||||
counters.inc("nope")
|
||||
|
||||
|
||||
def test_restore_pending_adds_back_what_a_failed_flush_took():
|
||||
counters = NodeCounters()
|
||||
counters.inc("jobs_done")
|
||||
taken = counters.take_pending()
|
||||
counters.inc("jobs_done")
|
||||
counters.restore_pending(taken)
|
||||
assert counters.take_pending() == {"jobs_done": 2}
|
||||
|
||||
|
||||
def test_outcomes_are_validated_and_bounded_in_shape():
|
||||
counters = NodeCounters()
|
||||
counters.observe("reddit", "residential", "ok")
|
||||
counters.observe("reddit", "residential", "ok")
|
||||
counters.observe("reddit", "", "blocked")
|
||||
assert counters.outcomes() == {
|
||||
"outcome:reddit:residential:ok": 2,
|
||||
"outcome:reddit:unknown:blocked": 1,
|
||||
}
|
||||
for adapter, asn_class, kind in (("Re:dit", "x", "ok"), ("reddit", "a b", "ok"), ("reddit", "x", "weird"), ("x" * 40, "x", "ok")):
|
||||
with pytest.raises(KeyError):
|
||||
outcome_name(adapter, asn_class, kind)
|
||||
|
||||
|
||||
def test_every_declared_counter_can_be_incremented():
|
||||
counters = NodeCounters()
|
||||
for name in COUNTER_NAMES:
|
||||
counters.inc(name)
|
||||
assert all(value == 1 for value in counters.snapshot().values())
|
||||
Reference in New Issue
Block a user