Skip to content

Commit

Permalink
test: adjust test after jsonschema update 1
Browse files Browse the repository at this point in the history
The action_params schema defines the "type" property as:

    anyOf: [{enum: [string, object, ...]}]

jsonschema v2.6.0 reported the anyOf error "matched none of the schemas"
jsonschema v3.2.0 is a bit more helpful by reporting the underlying enum
error.

I also looked at removing the anyOf (since there is only one entry), but
the anyOf makes it easier to compare our action_params schema with the
draft4 schema to make the differences very clear.
  • Loading branch information
cognifloyd committed Jan 29, 2024
1 parent be09e03 commit 591e0cd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion st2api/tests/unit/controllers/v1/test_packs.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,10 @@ def test_packs_register_endpoint(self, mock_get_packs):
self.assertEqual(resp.status_int, 400)
self.assertIn(expected_msg, resp.json["faultstring"])

expected_msg = "'stringa' is not valid under any of the given schemas"
# with jsonschema 2.6.0, the anyOf validator errors with:
# "'stringa' is not valid under any of the given schemas"
# with jsonschema 3.2.0, the underlying enum (anyOf->enum) gets reported instead:
expected_msg = "'stringa' is not one of ['array', 'boolean', 'integer', 'null', 'number', 'object', 'string']"
self.assertEqual(resp.status_int, 400)
self.assertIn(expected_msg, resp.json["faultstring"])

Expand Down

0 comments on commit 591e0cd

Please sign in to comment.