P5-4418 validate Pwinty SKU code
This commit is contained in:
@@ -12,6 +12,7 @@ from api.validators import (
|
||||
validate_number,
|
||||
validate_territory,
|
||||
validate_jsonschema,
|
||||
validate_any_of,
|
||||
)
|
||||
|
||||
|
||||
@@ -138,3 +139,18 @@ class TestValidators(flask_testing.TestCase):
|
||||
content_type="application/json",
|
||||
).data,
|
||||
)
|
||||
|
||||
def test_validate_any_of(self):
|
||||
app = self.app
|
||||
|
||||
@app.route("/", methods=["GET"])
|
||||
@validate_any_of("color", ["red", "green", "blue"])
|
||||
def index():
|
||||
return "ok"
|
||||
|
||||
self.assertEqual(b"No color is specified", self.client.get("/").data)
|
||||
self.assertEqual(
|
||||
b"color contains an invalid value, must be one of: ['red', 'green', 'blue']",
|
||||
self.client.get("/?color=black").data,
|
||||
)
|
||||
self.assertEqual(b"ok", self.client.get("/?color=blue").data)
|
||||
|
||||
Reference in New Issue
Block a user