Esempio n. 1
0
    def test_number(self, value):
        schema = Schema('number')

        result = schema.validate(value)

        assert result == value
Esempio n. 2
0
    def test_object_additional_propetries_false(self, value):
        schema = Schema('object', additional_properties=False)

        with pytest.raises(UndefinedSchemaProperty):
            schema.validate(value)
Esempio n. 3
0
    def test_integer(self, value, validator_factory):
        schema = Schema('integer')

        result = validator_factory(schema).validate(value)

        assert result is None
Esempio n. 4
0
    def test_string_none(self):
        schema = Schema('string')
        value = None

        with pytest.raises(InvalidSchemaValue):
            schema.unmarshal(value)
Esempio n. 5
0
    def test_object_max_properties_invalid_schema(self, value):
        schema = Schema('object', max_properties=-1)

        with pytest.raises(OpenAPISchemaError):
            schema.validate(value)
Esempio n. 6
0
    def test_string_pattern_invalid(self, value):
        schema = Schema('string', pattern='baz')

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

        result = schema.validate(value)

        assert result == value
Esempio n. 8
0
    def test_number_multiple_of(self, value):
        schema = Schema('number', multiple_of=3)

        result = schema.validate(value)

        assert result == value
Esempio n. 9
0
    def test_string(self, value):
        schema = Schema('string')

        result = schema.validate(value)

        assert result == value
Esempio n. 10
0
    def test_number_exclusive_maximum(self, value):
        schema = Schema('number', maximum=3, exclusive_maximum=True)

        result = schema.validate(value)

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

        with pytest.raises(InvalidSchemaValue):
            schema.validate(value)
Esempio n. 12
0
    def test_number_exclusive_maximum_invalid(self, value):
        schema = Schema('number', maximum=3, exclusive_maximum=True)

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

        result = schema.validate(value)

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

        with pytest.raises(InvalidSchemaValue):
            schema.validate(value)
Esempio n. 15
0
    def test_string_max_length_invalid(self, value):
        schema = Schema('string', max_length=1)

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

        with pytest.raises(InvalidSchemaValue):
            schema.validate(value)
Esempio n. 17
0
    def test_string_max_length(self, value):
        schema = Schema('string', max_length=1)

        result = schema.validate(value)

        assert result == value
Esempio n. 18
0
    def test_string_format_datetime_invalid(self, value):
        schema = Schema('string', schema_format='date-time')

        with pytest.raises(InvalidSchemaValue):
            schema.validate(value)
Esempio n. 19
0
    def test_string_float_invalid(self):
        schema = Schema('string')
        value = 1.23

        with pytest.raises(InvalidSchemaValue):
            schema.unmarshal(value)
Esempio n. 20
0
    def test_string_format_binary_invalid(self, value):
        schema = Schema('string', schema_format='binary')

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

        with pytest.raises(InvalidSchemaValue):
            schema.validate(value)
Esempio n. 22
0
    def test_string_format_byte_invalid(self, value):
        schema = Schema('string', schema_format='byte')

        with pytest.raises(OpenAPISchemaError):
            schema.validate(value)
Esempio n. 23
0
    def test_object_default_property(self, value):
        schema = Schema('object', default='value1')

        result = schema.validate(value)

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

        result = schema.validate(value)

        assert result == value
Esempio n. 25
0
    def test_object_additional_propetries(self, value):
        schema = Schema('object')

        schema.validate(value)
Esempio n. 26
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)
Esempio n. 27
0
    def test_object_additional_propetries_object(self, value):
        additional_properties = Schema('integer')
        schema = Schema('object', additional_properties=additional_properties)

        schema.validate(value)
Esempio n. 28
0
    def test_string_max_length_invalid_schema(self, value):
        schema = Schema('string', max_length=-1)

        with pytest.raises(OpenAPISchemaError):
            schema.validate(value)
Esempio n. 29
0
    def test_integer_invalid(self, value, validator_factory):
        schema = Schema('integer')

        with pytest.raises(InvalidSchemaValue):
            validator_factory(schema).validate(value)
Esempio n. 30
0
    def test_integer_maximum_invalid(self, value):
        schema = Schema('integer', maximum=3)

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