Compare commits

..
Author SHA1 Message Date
Typosaurus 38c2bab503 ticket #111 attempt 1
DevPlace CI / test (pull_request) Failing after 11s
2026-07-23 03:03:02 +00:00
9 changed files with 84 additions and 95 deletions
File diff suppressed because one or more lines are too long
-31
View File
@@ -360,37 +360,6 @@ def create_comment_record(
comment_url,
)
if target_type == "post":
posts_table = get_table("posts")
post_record = posts_table.find_one(uid=target_uid)
if not post_record:
post_record = posts_table.find_one(slug=target_uid)
commenter_uids = set()
for c in get_table("comments").find(
target_type="post", target_uid=target_uid, deleted_at=None
):
commenter_uids.add(c["user_uid"])
commenter_uids.discard(user["uid"])
if post_record:
commenter_uids.discard(post_record["user_uid"])
if parent_uid:
parent_comment = get_table("comments").find_one(
uid=parent_uid, deleted_at=None
)
if parent_comment and parent_comment["user_uid"] != user["uid"]:
commenter_uids.discard(parent_comment["user_uid"])
for commenter_uid in commenter_uids:
create_notification(
commenter_uid,
"thread_comment",
f"{user['username']} also commented on a post you commented on",
user["uid"],
comment_url,
)
create_mention_notifications(content, user["uid"], comment_url)
schedule_correction(user, "comments", comment_uid, request)
schedule_modification(user, "comments", comment_uid, request)
-1
View File
@@ -19,7 +19,6 @@ NOTIFICATION_TYPES = [
{"key": "harvest_stolen", "label": "Farm raids", "description": "Someone steals a ready build from your Code Farm"},
{"key": "award", "label": "Awards", "description": "Someone gives you an award on your profile"},
{"key": "system", "label": "System alerts", "description": "Platform infrastructure alerts (e.g. the AI gateway going down)"},
{"key": "thread_comment", "label": "Thread comments", "description": "Someone else comments on a post you commented on"},
]
+2
View File
@@ -38,6 +38,7 @@ def field(
example="",
description="",
options=None,
nullable=False,
):
spec = {
"name": name,
@@ -46,6 +47,7 @@ def field(
"required": required,
"example": example,
"description": description,
"nullable": nullable,
}
if options:
spec["options"] = list(options)
+11 -2
View File
@@ -39,7 +39,15 @@ def _unwrap_optional(annotation):
return annotation
def _value(name, annotation, stack):
def _is_optional(annotation):
if get_origin(annotation) is Union:
return type(None) in get_args(annotation)
return False
def _value(name, annotation, stack, is_nullable=False):
if is_nullable:
return None
annotation = _unwrap_optional(annotation)
origin = get_origin(annotation)
if origin in (list, set, tuple):
@@ -71,7 +79,8 @@ def _from_model(model, stack):
stack = stack | {model}
example = {}
for name, info in model.model_fields.items():
example[name] = _value(name, info.annotation, stack)
is_nullable = _is_optional(info.annotation)
example[name] = _value(name, info.annotation, stack, is_nullable)
return example
+10
View File
@@ -218,6 +218,16 @@
font-weight: 700;
}
.param-nullable {
font-size: 0.625rem;
text-transform: uppercase;
letter-spacing: 0.05em;
color: var(--text-muted);
border: 1px dashed var(--border);
border-radius: 999px;
padding: 0.05rem 0.4rem;
}
.param-loc {
font-size: 0.625rem;
text-transform: uppercase;
+1
View File
@@ -139,6 +139,7 @@ export class ApiTester {
const label = this.el("div", { class: "param-label" }, [
this.el("span", { class: "param-name", text: param.name }),
param.required ? this.el("span", { class: "param-required", text: "*" }) : null,
param.nullable ? this.el("span", { class: "param-nullable", text: "nullable" }) : null,
this.el("span", { class: "param-loc param-loc-" + param.location, text: param.location }),
]);
const allowed = param.type === "enum" && param.options && param.options.length
-60
View File
@@ -384,66 +384,6 @@ def test_comment_notification_on_post(app_server, browser, seeded_db):
ctx_b.close()
def test_thread_comment_notification(app_server, browser, seeded_db):
from tests.conftest import login_user
ctx_a = browser.new_context(viewport={"width": 1400, "height": 900})
ctx_b = browser.new_context(viewport={"width": 1400, "height": 900})
pa = ctx_a.new_page()
pb = ctx_b.new_page()
pa.set_default_timeout(15000)
pb.set_default_timeout(15000)
login_user(pa, seeded_db["alice"])
login_user(pb, seeded_db["bob"])
pa.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
pa.locator(".feed-fab").first.wait_for(state="visible", timeout=10000)
pa.locator(".feed-fab").first.click()
pa.fill("#post-content", "Post for thread comment notification test")
pa.locator("#create-post-modal button.btn-primary:has-text('Post')").click()
pa.wait_for_url("**/posts/*", timeout=10000, wait_until="domcontentloaded")
post_url = pa.url
pb.goto(post_url, wait_until="domcontentloaded")
pb.wait_for_timeout(1000)
comment_textarea = pb.locator("form.comment-form textarea[name='content']").first
comment_textarea.wait_for(state="visible", timeout=10000)
comment_textarea.fill("Bob's top-level comment")
pb.locator("button.comment-form-submit").first.click()
pb.wait_for_timeout(1500)
pb_body = pb.locator("body").text_content()
assert "Internal Server Error" not in pb_body, f"Bob got 500: {pb_body[:300]}"
pa.goto(post_url, wait_until="domcontentloaded")
pa.wait_for_timeout(1000)
comment_textarea = pa.locator("form.comment-form textarea[name='content']").first
comment_textarea.wait_for(state="visible", timeout=10000)
comment_textarea.fill("Alice also comments on her own post")
pa.locator("button.comment-form-submit").first.click()
pa.wait_for_timeout(1500)
pa_body = pa.locator("body").text_content()
assert "Internal Server Error" not in pa_body, f"Alice got 500: {pa_body[:300]}"
pb.goto(f"{BASE_URL}/notifications", wait_until="domcontentloaded")
pb.wait_for_timeout(2000)
body = pb.locator("body").text_content()
assert "Internal Server Error" not in body, (
f"Got 500 error on notifications: {body[:500]}"
)
assert "alice_test" in body, (
f"Expected 'alice_test' in notifications, got: {body[:500]}"
)
assert "also commented" in body, (
f"Expected 'also commented' in notifications, got: {body[:500]}"
)
ctx_a.close()
ctx_b.close()
def test_follow_notification(app_server, browser, seeded_db):
from tests.conftest import login_user
+59
View File
@@ -0,0 +1,59 @@
# retoor <retoor@molodetz.nl>
from typing import Optional
from pydantic import BaseModel
from devplacepy.docs_api._shared import field
from devplacepy.docs_examples import _is_optional, schema_example
def test_field_nullable_parameter():
f = field("bio", "query", "string", False, "", "User biography", nullable=True)
assert f["nullable"] is True
f2 = field("username", "path", "string", True, "alice", "Target username")
assert f2["nullable"] is False
def test_is_optional_optional_type():
assert _is_optional(Optional[str]) is True
assert _is_optional(Optional[int]) is True
assert _is_optional(Optional[list[str]]) is True
def test_is_optional_non_optional():
assert _is_optional(str) is False
assert _is_optional(int) is False
assert _is_optional(list[str]) is False
assert _is_optional(dict) is False
def test_schema_example_nullable_fields():
class NullableModel(BaseModel):
name: str
bio: Optional[str] = None
age: int
score: Optional[int] = None
tags: Optional[list[str]] = None
result = schema_example(NullableModel)
assert result["name"] == "string"
assert result["age"] == 0
assert result["bio"] is None
assert result["score"] is None
assert result["tags"] is None
def test_schema_example_non_nullable_fields_unaffected():
class StrictModel(BaseModel):
x: str
y: int
z: bool
result = schema_example(StrictModel)
assert result["x"] == "string"
assert result["y"] == 0
assert result["z"] is False