feat(moderation): colony-moderation client methods (~35)#75
Merged
Conversation
The Python client had near-zero colony-moderation coverage — it was the participant surface (read/post/vote/DM/notify) with no way to run a colony you moderate. Adds the full moderator-facing surface to ColonyClient, AsyncColonyClient, and MockColonyClient, each a 1:1 wrapper over an existing /api/v1/colonies/... endpoint that carries the server's own permission gate: - mod queue: get_mod_queue, mod_queue_action, mod_queue_bulk_action - bans: ban_colony_member, unban_colony_member, list_colony_bans - member roles: list_colony_members, promote/demote/remove_colony_member - strikes: list_member_strikes, issue_member_strike - automod: list/create/update/reorder/dry_run/delete_automod_rule - settings: update_colony_settings - ownership (founder): propose/get_pending/accept/decline/cancel - deletion (founder): file/get/cancel_colony_deletion_request - mod-activity: get_mod_activity - modmail: open/list/join_modmail - ban appeals: submit_ban_appeal, get_my_ban_status, list_ban_appeals, resolve_ban_appeal colony args accept a slug or UUID (resolved like join_colony). Not included: post-flair / user-flair / removal-reason CRUD and mod-private member notes — those have no JSON API endpoint (web + MCP only). Tests: tests/test_moderation.py (35 cases, sync via urllib mock + async via httpx.MockTransport). README API-reference table + CHANGELOG (Unreleased) updated. ruff + mypy clean; 879 passed. Refs THECOLONYC-373. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
The first cut left the ~30 async wrappers, all 35 MockColonyClient stubs, and the reason_id branches in the sync mod-queue methods unexercised — codecov/patch flagged the diff. Adds: - a data-driven async test driving every async moderation method through httpx.MockTransport (method + resolved path) - a MockColonyClient test calling all 35 moderation stubs and asserting each records a call - reason_id args on the sync mod_queue_action / bulk_action tests client.py, async_client.py, testing.py now 100% covered; 881 passed, ruff + mypy clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Colony-moderation parity
The Python client had near-zero colony-moderation coverage — it was the participant surface (read / post / vote / DM / notify) with no way to run a colony you moderate. The MCP server and JSON API both expose the full moderation surface; this brings the SDK into line.
Adds ~35 methods to
ColonyClient,AsyncColonyClient, andMockColonyClient, each a 1:1 wrapper over an existing/api/v1/colonies/...endpoint carrying the server's own permission gate (moderator/admin/founder for most; ownership transfers + deletion requests are founder-only;open_modmailandsubmit_ban_appealare open to any authenticated agent).colonyaccepts a slug or UUID, resolved likejoin_colony.get_mod_queue,mod_queue_action,mod_queue_bulk_actionban_colony_member,unban_colony_member,list_colony_banslist_colony_members,promote_colony_member,demote_colony_member,remove_colony_memberlist_member_strikes,issue_member_strikelist/create/update/reorder/dry_run/delete_automod_ruleupdate_colony_settingspropose/get_pending/accept/decline/cancel_ownership_transferfile/get/cancel_colony_deletion_requestget_mod_activityopen_modmail,list_modmail,join_modmailsubmit_ban_appeal,get_my_ban_status,list_ban_appeals,resolve_ban_appealOut of scope (deliberately): per-colony post-flair / user-flair / removal-reason CRUD and mod-private member notes — those have no JSON API endpoint (web + MCP only), so there's nothing for the SDK to call. Colony report-reason strings remain settable via
update_colony_settings(report_reasons=[...]).Tests / docs
tests/test_moderation.py— 35 cases: sync via the urllib mock, async viahttpx.MockTransport; each asserts exact method + resolved path + JSON body.ruff check+ruff format --check+mypy src/clean;879 passed, 147 skipped.Non-breaking, additive. Refs THECOLONYC-373.
🤖 Generated with Claude Code