Skip to content

tests: update the tests for OP#12 (validate schema -> schema) and finalize the required openapi.json#56

Merged
Artifizer merged 2 commits intoGlobalTypeSystem:mainfrom
Artifizer:main
Feb 17, 2026
Merged

tests: update the tests for OP#12 (validate schema -> schema) and finalize the required openapi.json#56
Artifizer merged 2 commits intoGlobalTypeSystem:mainfrom
Artifizer:main

Conversation

@Artifizer
Copy link
Copy Markdown
Contributor

@Artifizer Artifizer commented Feb 17, 2026

Summary by CodeRabbit

New Features

  • Added /validate-schema POST endpoint to validate schemas with a required schema ID parameter
  • Added /validate-entity POST endpoint to validate entities with a required entity ID parameter

Tests

  • Added comprehensive test coverage for schema validation workflows including derived schemas and nested property scenarios
  • Added entity validation test cases covering valid/invalid instances, hierarchies, and edge cases

…alized the required openapi.json

Signed-off-by: Artifizer <artifizer@gmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 17, 2026

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

💤 Files selected but had no reviewable changes (1)
  • tests/test_op12_schema_vs_schema_validation.py

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Two new API endpoints are introduced for validation operations: /validate-schema and /validate-entity. These endpoints receive JSON payloads containing a schema ID or entity ID respectively and return validation results. Comprehensive test coverage is added to validate the behavior of these endpoints across multiple scenarios.

Changes

Cohort / File(s) Summary
OpenAPI Specification
tests/openapi.json
Added two POST endpoints (/validate-schema, /validate-entity) with request body schemas ValidateSchemaRequest and ValidateEntityRequest. Both endpoints support 200 (successful response) and 422 (validation error) status codes.
Test Suite
tests/test_op12_schema_vs_schema_validation.py
Added 10 new test classes covering schema validation scenarios (closed/open models, nested properties) and entity validation workflows (valid/invalid instances, schema hierarchies, not found cases). Each test class defines registration steps and validation assertions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~28 minutes

Possibly related PRs

Poem

🐰 Two endpoints hopping in the light,
Validating schemas, making things right,
From entity to schema, we test and we check,
With nine test cases piled up on the deck! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (2 files):

⚔️ tests/openapi.json (content)
⚔️ tests/test_op12_schema_vs_schema_validation.py (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: updates to OP#12 validation tests and finalization of the OpenAPI specification with new endpoints.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/test_op12_schema_vs_schema_validation.py (1)

1572-1582: ⚠️ Potential issue | 🟠 Major

/validate-entity payload uses gts_id instead of entity_id.

This request likely won’t match the new ValidateEntityRequest contract (and is inconsistent with other tests). It should send entity_id.

✅ Fix request field name
-            .with_json({
-                "gts_id": (
+            .with_json({
+                "entity_id": (
                     "gts.x.test12.badcascade.field.v1~"
                     "x.test12._.medium.v1~x.test12._.bad_large.v1~"
                 )
             })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/test_op12_schema_vs_schema_validation.py` around lines 1572 - 1582,
Test payload for the "/validate-entity" request is using "gts_id" instead of the
expected "entity_id"; update the RunRequest call in the test "validate level 3
schema should fail" so the JSON body uses "entity_id" key (matching the
ValidateEntityRequest contract and other tests), i.e., replace the "gts_id"
field with "entity_id" in the .with_json({...}) for the RunRequest to ensure the
request matches the validator.
🧹 Nitpick comments (2)
tests/openapi.json (1)

492-545: Define response schemas for /validate-schema and /validate-entity.

Tests assert body.ok and body.entity_type, but the OpenAPI responses are generic objects. Consider adding explicit response schemas so the spec matches observed behavior.

📘 Suggested schema additions
   "/validate-schema": {
     "post": {
       ...
       "responses": {
         "200": {
           "description": "Successful Response",
           "content": {
             "application/json": {
               "schema": {
-                "type": "object",
-                "title": "Response Validate Schema Validate Schema Post"
+                "$ref": "#/components/schemas/ValidateSchemaResponse"
               }
             }
           }
         },
...
   "/validate-entity": {
     "post": {
       ...
       "responses": {
         "200": {
           "description": "Successful Response",
           "content": {
             "application/json": {
               "schema": {
-                "type": "object",
-                "title": "Response Validate Entity Validate Entity Post"
+                "$ref": "#/components/schemas/ValidateEntityResponse"
               }
             }
           }
         },
...
   "components": {
     "schemas": {
+      "ValidateSchemaResponse": {
+        "type": "object",
+        "required": ["ok"],
+        "properties": {
+          "ok": { "type": "boolean" }
+        },
+        "title": "ValidateSchemaResponse"
+      },
+      "ValidateEntityResponse": {
+        "type": "object",
+        "required": ["ok", "entity_type"],
+        "properties": {
+          "ok": { "type": "boolean" },
+          "entity_type": {
+            "type": "string",
+            "enum": ["schema", "instance"]
+          }
+        },
+        "title": "ValidateEntityResponse"
+      },
       "ValidateSchemaRequest": { ... },
       "ValidateEntityRequest": { ... }

Also applies to: 536-545, 850-875

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/openapi.json` around lines 492 - 545, The OpenAPI responses for the
POST endpoints "/validate-schema" (operationId:
validate_schema_validate_schema_post) and "/validate-entity" (operationId:
validate_entity_validate_entity_post) use generic object schemas but tests
expect fields like body.ok and body.entity_type; update the spec by adding
explicit response schemas under components/schemas (e.g., ValidateSchemaResponse
and ValidateEntityResponse) and reference them in the "200" response for each
operation so the response schema includes the required properties (ok: boolean,
entity_type: string, plus any other fields the handlers return). Ensure the new
schema names are referenced from the "responses" -> "200" -> "content" ->
"application/json" -> "schema" for both endpoints and adjust titles if needed.
tests/test_op12_schema_vs_schema_validation.py (1)

229-290: Annotate class-level teststeps as ClassVar to satisfy RUF012.

Ruff flags mutable class attributes; consider annotating teststeps as ClassVar (or moving to instance scope). This pattern repeats across the new test classes.

♻️ Example adjustment
+from typing import ClassVar
+
 class TestCaseTestOp12SchemaValidation_CloseOpenModel(HttpRunner):
     ...
-    teststeps = [
+    teststeps: ClassVar[list[Step]] = [
         Step(
             RunRequest("register open base schema")
             ...
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/test_op12_schema_vs_schema_validation.py` around lines 229 - 290, The
class-level mutable variable teststeps should be annotated as typing.ClassVar to
satisfy RUF012; update the test classes that define teststeps (the variable
named teststeps in the shown test class and the other new test classes) to
import ClassVar from typing and change the definition to something like:
teststeps: ClassVar[list[Step]] = [...] (or use typing.List[Step] if needed for
your Python version), or alternatively move the teststeps definition into
instance scope (e.g., setUp) if you prefer not to use ClassVar.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@tests/test_op12_schema_vs_schema_validation.py`:
- Around line 1572-1582: Test payload for the "/validate-entity" request is
using "gts_id" instead of the expected "entity_id"; update the RunRequest call
in the test "validate level 3 schema should fail" so the JSON body uses
"entity_id" key (matching the ValidateEntityRequest contract and other tests),
i.e., replace the "gts_id" field with "entity_id" in the .with_json({...}) for
the RunRequest to ensure the request matches the validator.

---

Nitpick comments:
In `@tests/openapi.json`:
- Around line 492-545: The OpenAPI responses for the POST endpoints
"/validate-schema" (operationId: validate_schema_validate_schema_post) and
"/validate-entity" (operationId: validate_entity_validate_entity_post) use
generic object schemas but tests expect fields like body.ok and
body.entity_type; update the spec by adding explicit response schemas under
components/schemas (e.g., ValidateSchemaResponse and ValidateEntityResponse) and
reference them in the "200" response for each operation so the response schema
includes the required properties (ok: boolean, entity_type: string, plus any
other fields the handlers return). Ensure the new schema names are referenced
from the "responses" -> "200" -> "content" -> "application/json" -> "schema" for
both endpoints and adjust titles if needed.

In `@tests/test_op12_schema_vs_schema_validation.py`:
- Around line 229-290: The class-level mutable variable teststeps should be
annotated as typing.ClassVar to satisfy RUF012; update the test classes that
define teststeps (the variable named teststeps in the shown test class and the
other new test classes) to import ClassVar from typing and change the definition
to something like: teststeps: ClassVar[list[Step]] = [...] (or use
typing.List[Step] if needed for your Python version), or alternatively move the
teststeps definition into instance scope (e.g., setUp) if you prefer not to use
ClassVar.

Signed-off-by: Artifizer <artifizer@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant