Notifications: a new "thread" type notifies every other commenter on a
post whenever anyone comments on it, disregarding reply hierarchy -
excluding the actor and whoever already got a comment/reply
notification for that same event, so no one is double-notified.
Implemented via a background-deferred fan-out mirroring the existing
mention-notification pattern.
SEO: discussion_forum_posting() now embeds up to 20 of a post's
comments as nested schema.org Comment entities (not just an aggregate
count), and a new /topics hub plus /topics/{topic} pages give the
feed's topic filter real, independently crawlable/indexable URLs -
/feed?topic=X was never indexable since its canonical strips the
query string back to bare /feed. Both are wired end to end (schemas,
Devii actions, docs API, sitemap, locustfile load-test coverage).
Quiz player: the auto-advance to the next question used to hide the
just-answered slide in the same tick as rendering the grade, so on
any multi-question quiz the Correct/Not correct feedback was never
actually visible before the view moved on. Delayed via setTimeout,
with the pending timer cleared on manual navigation and on
disconnect so it can't race or fire on a removed component.
Also includes other local changes already in progress in this
working tree before this session (messaging, push delivery,
deepsearch jobs, game economy, quiz builder) - verified by the full
suite passing (3467 tests) but not authored or individually reviewed
in this session.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VL9Xn57W5UR3HZbbuuzxdK
91 lines
2.6 KiB
Python
91 lines
2.6 KiB
Python
# retoor <retoor@molodetz.nl>
|
|
|
|
import json
|
|
|
|
from tests.conftest import run_async
|
|
|
|
from devplacepy.services.jobs.deepsearch import enhance as enhance_module
|
|
from devplacepy.services.jobs.deepsearch.enhance import plan_followup_queries
|
|
|
|
|
|
class _FakeResponse:
|
|
def __init__(self, status_code, payload):
|
|
self.status_code = status_code
|
|
self._payload = payload
|
|
|
|
def json(self):
|
|
return self._payload
|
|
|
|
|
|
class _FakeClient:
|
|
def __init__(self, response):
|
|
self._response = response
|
|
|
|
async def __aenter__(self):
|
|
return self
|
|
|
|
async def __aexit__(self, *exc):
|
|
return False
|
|
|
|
async def post(self, *args, **kwargs):
|
|
return self._response
|
|
|
|
|
|
def _client_returning(response):
|
|
def factory(**kwargs):
|
|
return _FakeClient(response)
|
|
|
|
return factory
|
|
|
|
|
|
def test_plan_followup_queries_empty_without_covered_titles():
|
|
result = run_async(plan_followup_queries("q", [], "k"))
|
|
assert result == []
|
|
|
|
|
|
def test_plan_followup_queries_parses_gateway_response(monkeypatch):
|
|
payload = {"choices": [{"message": {"content": json.dumps({"queries": ["a", "b"]})}}]}
|
|
monkeypatch.setattr(
|
|
enhance_module.stealth,
|
|
"stealth_async_client",
|
|
_client_returning(_FakeResponse(200, payload)),
|
|
)
|
|
result = run_async(plan_followup_queries("q", ["Existing source"], "k"))
|
|
assert result == ["a", "b"]
|
|
|
|
|
|
def test_plan_followup_queries_empty_when_sources_already_cover_question(monkeypatch):
|
|
payload = {"choices": [{"message": {"content": json.dumps({"queries": []})}}]}
|
|
monkeypatch.setattr(
|
|
enhance_module.stealth,
|
|
"stealth_async_client",
|
|
_client_returning(_FakeResponse(200, payload)),
|
|
)
|
|
result = run_async(plan_followup_queries("q", ["Existing source"], "k"))
|
|
assert result == []
|
|
|
|
|
|
def test_plan_followup_queries_fails_soft_on_gateway_error(monkeypatch):
|
|
monkeypatch.setattr(
|
|
enhance_module.stealth,
|
|
"stealth_async_client",
|
|
_client_returning(_FakeResponse(500, {})),
|
|
)
|
|
result = run_async(plan_followup_queries("q", ["Existing source"], "k"))
|
|
assert result == []
|
|
|
|
|
|
def test_plan_followup_queries_caps_at_max(monkeypatch):
|
|
payload = {
|
|
"choices": [
|
|
{"message": {"content": json.dumps({"queries": ["a", "b", "c", "d", "e"]})}}
|
|
]
|
|
}
|
|
monkeypatch.setattr(
|
|
enhance_module.stealth,
|
|
"stealth_async_client",
|
|
_client_returning(_FakeResponse(200, payload)),
|
|
)
|
|
result = run_async(plan_followup_queries("q", ["Existing source"], "k"))
|
|
assert len(result) == enhance_module.MAX_FOLLOWUP_QUERIES
|