-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4329 from opsmill/lgu-clean-error-on-missing-sche…
…ma-menu-placement Raise 422 SchemaNotFoundError while uploading a schema referring an unexisting schemanode
- Loading branch information
Showing
4 changed files
with
39 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
backend/tests/integration/schema_lifecycle/test_schema_missing_menu_placement.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from infrahub_sdk import InfrahubClient | ||
|
||
from .shared import ( | ||
TestSchemaLifecycleBase, | ||
) | ||
|
||
|
||
class TestSchemaMissingMenuPlacement(TestSchemaLifecycleBase): | ||
async def test_schema_missing_menu_placement(self, client: InfrahubClient): | ||
schema = { | ||
"version": "1.0", | ||
"nodes": [ | ||
{ | ||
"name": "BNode", | ||
"namespace": "Infra", | ||
"menu_placement": "UnexistingNode", | ||
"label": "BNode", | ||
"display_labels": ["name__value"], | ||
"attributes": [{"name": "name", "kind": "Text", "unique": True}], | ||
} | ||
], | ||
} | ||
|
||
response = await client.schema.load(schemas=[schema], branch="main") | ||
assert response.schema_updated is False | ||
assert response.errors["errors"][0]["extensions"]["code"] == 422 | ||
assert ( | ||
response.errors["errors"][0]["message"] | ||
== "InfraBNode refers to an invalid menu placement node: UnexistingNode." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Loading a schema with a schemanode referencing an incorrect menu placement now returns a proper HTTP 422 error |