ZJU-REAL/Easel / skills/builtin/skill-wechat-publisher
skill-wechat-publisher
Verified微信公众号文章自动创作与发布工具。给定参考文章、文字或文档,自动搜索整理全网相关信息、生成图文并茂的公众号文章,并发布到微信公众号草稿箱。特别强调反 AI 检测写作。 触发场景(沾边就用):用户提到"公众号 / 微信文章 / 推文 / 公号 / 发文 / mp / 草稿箱 / 群发",或要求把话题/文档/笔记写成公众号文章并发布到微信。
tests/test_draft_submission.py
View on GitHubimport json
import pytest
import requests
import api
@pytest.fixture(params=["news", "newspic"])
def submit(request, monkeypatch):
monkeypatch.setattr(api, "get_access_token", lambda: "private-token")
if request.param == "news":
return lambda: api.add_draft({"title": "fixture", "content": "body", "thumb_media_id": "cover"})
return lambda: api.add_newspic_draft("fixture", "body", ["image"])
def install(monkeypatch, *, status=200, body=None, error=None):
calls = []
def send(method, url, **kwargs):
calls.append((method, url, kwargs))
if error:
raise error
response = requests.Response()
response.status_code = status
response._content = json.dumps(body).encode()
return response
monkeypatch.setattr(api.requests, "request", send)
return calls
@pytest.mark.parametrize("error", [requests.Timeout("private-token"), requests.ConnectionError("private-token")])
def test_transport_failure_is_unknown_and_never_retried(submit, monkeypatch, error):
calls = install(monkeypatch, error=error)
with pytest.raises(api.DraftOutcomeUnknown) as caught:
submit()
assert len(calls) == 1
assert "private-token" not in str(caught.value)
assert caught.value.__suppress_context__
@pytest.mark.parametrize("status", [301, 302, 400, 401, 429, 500, 502, 503])
def test_http_failure_or_redirect_never_repeats_side_effect(submit, monkeypatch, status):
calls = install(monkeypatch, status=status, body={"errmsg": "private provider body"})
with pytest.raises(api.DraftOutcomeUnknown):
submit()
assert len(calls) == 1
assert calls[0][2]["allow_redirects"] is False
@pytest.mark.parametrize("body", [None, [], {}, {"media_id": ""}, {"media_id": 12},
{"media_id": "x" * 513}, {"media_id": "ok", "errcode": False}])
def test_malformed_success_remains_unknown(submit, monkeypatch, body):
calls = install(monkeypatch, body=body)
with pytest.raises(api.DraftOutcomeUnknown):
submit()
assert len(calls) == 1
def test_explicit_provider_rejection_is_not_reported_as_success(submit, monkeypatch):
calls = install(monkeypatch, body={"errcode": 40007, "errmsg": "private response"})
with pytest.raises(RuntimeError) as caught:
submit()
assert not isinstance(caught.value, api.DraftOutcomeUnknown)
assert "40007" in str(caught.value) and "private" not in str(caught.value)
assert len(calls) == 1
def test_valid_receipt_is_returned_and_request_shape_preserved(submit, monkeypatch):
calls = install(monkeypatch, body={"media_id": "fixture-receipt"})
assert submit() == "fixture-receipt"
method, url, kwargs = calls[0]
assert method == "POST" and "/draft/add?" in url
assert json.loads(kwargs["data"])["articles"][0]["title"] == "fixture"
assert kwargs["timeout"] == api.API_TIMEOUT_SEC
assert len(calls) == 1
def test_invalid_local_json_does_not_start_a_request(monkeypatch):
monkeypatch.setattr(api, "get_access_token", lambda: "fixture")
calls = install(monkeypatch)
with pytest.raises(ValueError):
api.add_draft({"content": float("nan")})
assert calls == []
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |