def test_list_json_encode_type_error(): _error(s.list(items=s.str()).json_encode, "i_am_not_a_list")
def test_list_validate_unique_error(): _error(s.list(items=s.int(), unique=True).validate, [1, 2, 2, 3])
def test_list_json_encode_success(): _equal(s.list(items=s.str()).json_encode, ["a", "b", "c"])
def test_list_validate_max_error(): _error(s.list(items=s.int(), max_items=6).validate, [1, 2, 3, 4, 5, 6, 7])
def test_list_validate_unique_success(): s.list(items=s.int(), unique=True).validate([1, 2, 3, 4, 5])
def test_list_validate_min_error(): _error(s.list(items=s.int(), min_items=3).validate, [1, 2])
def test_list_validate_max_success(): s.list(items=s.int(), max_items=5).validate([1, 2, 3, 4])
def test_list_validate_type_error(): _error(s.list(items=s.bool()).validate, "this_is_not_a_list")
def test_list_validate_min_success(): s.list(items=s.int(), min_items=2).validate([1, 2, 3])
def test_list_validate_type_int_error(): _error(s.list(items=s.int()).validate, ["d", "e", "f"])
def test_list_validate_type_str_error(): _error(s.list(items=s.str()).validate, [4, 5, 6])
def test_list_validate_type_int_success(): s.list(items=s.int()).validate([1, 2, 3])
def test_list_validate_type_str_success(): s.list(items=s.str()).validate(["a", "b", "c"])
import roax.schema as s import unittest from roax.openapi import OpenAPIResource from roax.resource import Resource, operation from roax.wsgi import App params = { "a": s.list(s.str()), "b": s.set(s.str()), "c": s.int(), "d": s.float(), "e": s.bool(), "f": s.bytes(), "g": s.datetime(), "h": s.uuid(), } class TestResource(Resource): @operation(type="action", params=params, security=[]) def test(self, a, b, c, d, e, f, g, h): pass app = App("/", "Title", "1.0") app.register_resource("/test", TestResource()) class TestOpenAPI(unittest.TestCase): def test_openapi_no_errors(self):