Example #1
0
    def test_integer(self, value):
        schema = Schema('integer')

        result = schema.validate(value)

        assert result == value
Example #2
0
    def test_null(self, schema_type):
        schema = Schema(schema_type)
        value = None

        with pytest.raises(InvalidSchemaValue):
            schema.validate(value)
Example #3
0
    def test_boolean_invalid(self, value):
        schema = Schema('boolean')

        with pytest.raises(InvalidSchemaValue):
            schema.validate(value)
Example #4
0
    def test_string_pattern(self, value):
        schema = Schema('string', pattern='bar')

        result = schema.validate(value)

        assert result == value
Example #5
0
    def test_object_default_property(self, value):
        schema = Schema('object', default='value1')

        result = schema.validate(value)

        assert result == value
Example #6
0
    def test_string_max_length_invalid_schema(self, value):
        schema = Schema('string', max_length=-1)

        with pytest.raises(OpenAPISchemaError):
            schema.validate(value)
Example #7
0
    def test_string_max_length(self, value):
        schema = Schema('string', max_length=1)

        result = schema.validate(value)

        assert result == value
Example #8
0
    def test_number_exclusive_maximum_invalid(self, value):
        schema = Schema('number', maximum=3, exclusive_maximum=True)

        with pytest.raises(InvalidSchemaValue):
            schema.validate(value)
Example #9
0
    def test_number_exclusive_maximum(self, value):
        schema = Schema('number', maximum=3, exclusive_maximum=True)

        result = schema.validate(value)

        assert result == value
Example #10
0
    def test_number_minimum_invalid(self, value):
        schema = Schema('number', minimum=3)

        with pytest.raises(InvalidSchemaValue):
            schema.validate(value)
Example #11
0
    def test_number_maximum(self, value):
        schema = Schema('number', maximum=3)

        result = schema.validate(value)

        assert result == value
Example #12
0
    def test_number(self, value):
        schema = Schema('number')

        result = schema.validate(value)

        assert result == value
Example #13
0
    def test_integer_maximum_invalid(self, value):
        schema = Schema('integer', maximum=3)

        with pytest.raises(InvalidSchemaValue):
            schema.validate(value)
Example #14
0
    def test_integer_minimum(self, value):
        schema = Schema('integer', minimum=3)

        result = schema.validate(value)

        assert result == value
Example #15
0
    def test_string_format_byte(self, value):
        schema = Schema('string', schema_format='byte')

        result = schema.validate(value)

        assert result == value
Example #16
0
    def test_number_multiple_of_invalid(self, value):
        schema = Schema('number', multiple_of=3)

        with pytest.raises(InvalidSchemaValue):
            schema.validate(value)
Example #17
0
    def test_string_format_unknown(self, value):
        unknown_format = 'unknown'
        schema = Schema('string', schema_format=unknown_format)

        with pytest.raises(OpenAPISchemaError):
            schema.validate(value)
Example #18
0
    def test_number_multiple_of(self, value):
        schema = Schema('number', multiple_of=3)

        result = schema.validate(value)

        assert result == value
Example #19
0
    def test_string_max_length_invalid(self, value):
        schema = Schema('string', max_length=1)

        with pytest.raises(InvalidSchemaValue):
            schema.validate(value)
Example #20
0
    def test_string(self, value):
        schema = Schema('string')

        result = schema.validate(value)

        assert result == value
Example #21
0
    def test_string_pattern_invalid(self, value):
        schema = Schema('string', pattern='baz')

        with pytest.raises(InvalidSchemaValue):
            schema.validate(value)
Example #22
0
    def test_string_invalid(self, value):
        schema = Schema('string')

        with pytest.raises(InvalidSchemaValue):
            schema.validate(value)
Example #23
0
    def test_object_not_an_object(self, value):
        schema = Schema('object')

        with pytest.raises(InvalidSchemaValue):
            schema.validate(value)
Example #24
0
    def test_string_format_datetime_invalid(self, value):
        schema = Schema('string', schema_format='date-time')

        with pytest.raises(InvalidSchemaValue):
            schema.validate(value)
Example #25
0
    def test_object_max_properties_invalid_schema(self, value):
        schema = Schema('object', max_properties=-1)

        with pytest.raises(OpenAPISchemaError):
            schema.validate(value)
Example #26
0
    def test_string_format_binary_invalid(self, value):
        schema = Schema('string', schema_format='binary')

        with pytest.raises(InvalidSchemaValue):
            schema.validate(value)
Example #27
0
    def test_boolean(self, value):
        schema = Schema('boolean')

        result = schema.validate(value)

        assert result == value
Example #28
0
    def test_string_format_byte_invalid(self, value):
        schema = Schema('string', schema_format='byte')

        with pytest.raises(OpenAPISchemaError):
            schema.validate(value)
Example #29
0
    def test_array_no_schema(self, value):
        schema = Schema('array')

        with pytest.raises(OpenAPISchemaError):
            schema.validate(value)
Example #30
0
    def test_array_invalid(self, value):
        schema = Schema('array')

        with pytest.raises(InvalidSchemaValue):
            schema.validate(value)