Files
devplacepy/tests/api/sync/poll_votes.py
T
retoorandClaude Sonnet 5.5 02ab747cd0 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>
2026-10-17 02:23:43 +02:00

42 lines
2.1 KiB
Python

# retoor <retoor@molodetz.nl>
from devplacepy.database import get_table
from tests.api.sync.conftest import poll_record, poll_vote_record, seed_world, sync_ok
def setup(client, admin, origin):
seed_world(client, admin, origin)
return sync_ok(client, admin, "polls", origin, [poll_record()])["results"][0]["local_uid"]
def test_a_ballot_changes_option_without_duplicating(client, admin, origin):
poll = setup(client, admin, origin)
first = sync_ok(client, admin, "poll_votes", origin, [poll_vote_record("pv1", option="a")])["results"][0]
assert first["status"] == "created"
sync_ok(client, admin, "poll_votes", origin, [poll_vote_record("pv1", option="b", updated_at="2025-02-01T00:00:00Z")])
rows = list(get_table("poll_votes").find(poll_uid=poll))
assert len(rows) == 1
option = get_table("poll_options").find_one(uid=rows[0]["option_uid"])
assert option["label"] == "Spaces"
def test_unknown_poll_waits_but_an_unknown_option_is_final(client, admin, origin):
setup(client, admin, origin)
body = sync_ok(client, admin, "poll_votes", origin, [poll_vote_record("pv1", poll="ghost"), poll_vote_record("pv2", option="zzz")])
assert (body["results"][0]["status"], body["results"][0]["reason"]) == ("deferred", "unknown_poll")
assert (body["results"][1]["status"], body["results"][1]["reason"]) == ("rejected", "unknown_option")
def test_one_ballot_per_voter_even_with_a_second_origin_id(client, admin, origin):
poll = setup(client, admin, origin)
sync_ok(client, admin, "poll_votes", origin, [poll_vote_record("pv1", option="a")])
sync_ok(client, admin, "poll_votes", origin, [poll_vote_record("pv7", option="b")])
assert get_table("poll_votes").count(poll_uid=poll) == 1
def test_clearing_a_ballot(client, admin, origin):
poll = setup(client, admin, origin)
sync_ok(client, admin, "poll_votes", origin, [poll_vote_record("pv1")])
sync_ok(client, admin, "poll_votes", origin, [poll_vote_record("pv1", updated_at="2025-02-01T00:00:00Z", deleted=True)])
assert get_table("poll_votes").find_one(poll_uid=poll)["deleted_by"] == "sync"