Exemplo n.º 1
0
    def test_integer(self, value):
        schema = Schema('integer')

        result = schema.validate(value)

        assert result == value
Exemplo n.º 2
0
    def test_null(self, schema_type):
        schema = Schema(schema_type)
        value = None

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

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

        result = schema.validate(value)

        assert result == value
Exemplo n.º 5
0
    def test_object_default_property(self, value):
        schema = Schema('object', default='value1')

        result = schema.validate(value)

        assert result == value
Exemplo n.º 6
0
    def test_string_max_length_invalid_schema(self, value):
        schema = Schema('string', max_length=-1)

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

        result = schema.validate(value)

        assert result == value
Exemplo n.º 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)
Exemplo n.º 9
0
    def test_number_exclusive_maximum(self, value):
        schema = Schema('number', maximum=3, exclusive_maximum=True)

        result = schema.validate(value)

        assert result == value
Exemplo n.º 10
0
    def test_number_minimum_invalid(self, value):
        schema = Schema('number', minimum=3)

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

        result = schema.validate(value)

        assert result == value
Exemplo n.º 12
0
    def test_number(self, value):
        schema = Schema('number')

        result = schema.validate(value)

        assert result == value
Exemplo n.º 13
0
    def test_integer_maximum_invalid(self, value):
        schema = Schema('integer', maximum=3)

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

        result = schema.validate(value)

        assert result == value
Exemplo n.º 15
0
    def test_string_format_byte(self, value):
        schema = Schema('string', schema_format='byte')

        result = schema.validate(value)

        assert result == value
Exemplo n.º 16
0
    def test_number_multiple_of_invalid(self, value):
        schema = Schema('number', multiple_of=3)

        with pytest.raises(InvalidSchemaValue):
            schema.validate(value)
Exemplo n.º 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)
Exemplo n.º 18
0
    def test_number_multiple_of(self, value):
        schema = Schema('number', multiple_of=3)

        result = schema.validate(value)

        assert result == value
Exemplo n.º 19
0
    def test_string_max_length_invalid(self, value):
        schema = Schema('string', max_length=1)

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

        result = schema.validate(value)

        assert result == value
Exemplo n.º 21
0
    def test_string_pattern_invalid(self, value):
        schema = Schema('string', pattern='baz')

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

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

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

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

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

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

        result = schema.validate(value)

        assert result == value
Exemplo n.º 28
0
    def test_string_format_byte_invalid(self, value):
        schema = Schema('string', schema_format='byte')

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

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

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