-
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.
Raise a proper 422 error when uploading a schemanode refering an unex…
…isting schemanode
- Loading branch information
Showing
3 changed files
with
37 additions
and
4 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 an unexisting 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