Add comprehensive EmbedBuilder tests across 5+ IntentType cases #274

Closed
opened 2026-08-12 20:31:27 +00:00 by Mark · 0 comments
Owner

Comprehensive pytest coverage for EmbedBuilder over MeshIntentResult in runtime/discord_response.py, downstream of the embed schema delta in #271 (landed commits 90e47f9 feat + 3f9edd5 test, issue closed 2026-08-12).

Landed API surface (authoritative — tests must target THIS, not the original spec prose):

  • IntentType(str, Enum): 8 members — RESEARCH, WRITE, CHAT, STATUS, INFO, WARN, ERROR, SUCCESS. No UNKNOWN member; unknown legacy strings resolve to IntentType.CHAT (0x95A5A6 gray) via _intent_type_to_enum.
  • COLORS: dict[IntentType, int] — INFO=0x3498DB, WARN=0xF1C40F, ERROR=0xE74C3C, SUCCESS=0x2ECC71, RESEARCH=0x3498DB, WRITE=0x2ECC71, CHAT=0x95A5A6, STATUS=0x9B59B6.
  • MeshIntentResult is payload-wrapping: fields intent_type (IntentType|str), payload (dict), completed_at (datetime|None), metadata (dict|None). NOT flat title/description/fields/timestamp/footer per original spec — tests must drive fields via payload shapes.
  • EmbedBuilder.build(result) -> dict. RESEARCH/WRITE/STATUS/ERROR get dedicated shapes; INFO/WARN/SUCCESS/unknown go through _build_default (title/description/color/timestamp only, no fields/footer unless payload provides them).
  • _build_embed_dict enforces: title<=256, description<=4096, fields<=25, field name<=256, field value<=1024, footer<=2048, total<=6000 (title+description+field names/values+footer). Always emits ISO-8601 timestamp.

Deliverable: new test module tests/unit/test_embed_builder_intents.py.

Required tests:

  1. For each of 5+ distinct IntentType values (INFO, WARN, ERROR, SUCCESS, plus one domain-specific type from the mesh — RESEARCH or WRITE or STATUS): construct a MeshIntentResult fixture, call EmbedBuilder.build, and assert:
    • the returned embed dict has the correct color int per COLORS
    • title, description, timestamp are present and correctly typed (fields/footer asserted when the builder shape emits them)
    • no field value exceeds 1024 chars
    • total embed size (title + description + field names/values + footer) <= 6000
  2. (a) empty fields list — builds cleanly with no fields key (or empty).
  3. (b) 26 fields — SPEC DIVERGENCE: original spec required ValueError on >25 fields; landed implementation clamps silently via _clip_fields(fields[:25]) and never raises. Assert the landed behavior (embed contains exactly 25 fields, no exception) and note the divergence in a comment; do NOT assert ValueError against the clamped implementation unless the implementation is also changed (behavior change to closed #271 is out of scope here).
  4. (c) oversized field value (>1024 chars) — assert the value is truncated to 1024 chars.
  5. (d) unknown IntentType (e.g. a legacy string not in the enum) — resolves to the default CHAT gray 0x95A5A6.

Acceptance: full test suite green (existing 35 + new module); coverage report shows EmbedBuilder.build and the COLORS mapping fully exercised; ruff check clean.

Source: kanban decompose card t_f20fb154 (fixit board), child of the #271 embed-schema implementation card.

Comprehensive pytest coverage for EmbedBuilder over MeshIntentResult in runtime/discord_response.py, downstream of the embed schema delta in #271 (landed commits 90e47f9 feat + 3f9edd5 test, issue closed 2026-08-12). Landed API surface (authoritative — tests must target THIS, not the original spec prose): - IntentType(str, Enum): 8 members — RESEARCH, WRITE, CHAT, STATUS, INFO, WARN, ERROR, SUCCESS. No UNKNOWN member; unknown legacy strings resolve to IntentType.CHAT (0x95A5A6 gray) via _intent_type_to_enum. - COLORS: dict[IntentType, int] — INFO=0x3498DB, WARN=0xF1C40F, ERROR=0xE74C3C, SUCCESS=0x2ECC71, RESEARCH=0x3498DB, WRITE=0x2ECC71, CHAT=0x95A5A6, STATUS=0x9B59B6. - MeshIntentResult is payload-wrapping: fields intent_type (IntentType|str), payload (dict), completed_at (datetime|None), metadata (dict|None). NOT flat title/description/fields/timestamp/footer per original spec — tests must drive fields via payload shapes. - EmbedBuilder.build(result) -> dict. RESEARCH/WRITE/STATUS/ERROR get dedicated shapes; INFO/WARN/SUCCESS/unknown go through _build_default (title/description/color/timestamp only, no fields/footer unless payload provides them). - _build_embed_dict enforces: title<=256, description<=4096, fields<=25, field name<=256, field value<=1024, footer<=2048, total<=6000 (title+description+field names/values+footer). Always emits ISO-8601 timestamp. Deliverable: new test module tests/unit/test_embed_builder_intents.py. Required tests: 1. For each of 5+ distinct IntentType values (INFO, WARN, ERROR, SUCCESS, plus one domain-specific type from the mesh — RESEARCH or WRITE or STATUS): construct a MeshIntentResult fixture, call EmbedBuilder.build, and assert: - the returned embed dict has the correct color int per COLORS - title, description, timestamp are present and correctly typed (fields/footer asserted when the builder shape emits them) - no field value exceeds 1024 chars - total embed size (title + description + field names/values + footer) <= 6000 2. (a) empty fields list — builds cleanly with no fields key (or empty). 3. (b) 26 fields — SPEC DIVERGENCE: original spec required ValueError on >25 fields; landed implementation clamps silently via _clip_fields(fields[:25]) and never raises. Assert the landed behavior (embed contains exactly 25 fields, no exception) and note the divergence in a comment; do NOT assert ValueError against the clamped implementation unless the implementation is also changed (behavior change to closed #271 is out of scope here). 4. (c) oversized field value (>1024 chars) — assert the value is truncated to 1024 chars. 5. (d) unknown IntentType (e.g. a legacy string not in the enum) — resolves to the default CHAT gray 0x95A5A6. Acceptance: full test suite green (existing 35 + new module); coverage report shows EmbedBuilder.build and the COLORS mapping fully exercised; ruff check clean. Source: kanban decompose card t_f20fb154 (fixit board), child of the #271 embed-schema implementation card.
Mark closed this issue 2026-08-12 20:31:27 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Mark/mesh-seed#274
No description provided.