def test_access_object_array_field(field): object_field = ObjectField({SECOND_NAME: field}) array_field = ArrayField(object_field) field_access = FieldAccess(FIRST_NAME, FIRST_NAME, array_field, ()).b assert field_access.get_field() is object_field.properties[SECOND_NAME] assert (field_access.get_path_as_name() == '.'.join( (FIRST_NAME, SECOND_NAME)))
def test_resolve_missing_property_without_default(): properties = {'a': Field(required=True)} assert ObjectField(properties).resolve({}) == {}
def test_fails_validate_object_additional_properties(): with pytest.raises(TypeError): ObjectField({}, additional_properties=False).validate({'a': None})
def test_fails_validate_object_property(): properties = {'a': Field(nullable=False)} with pytest.raises(TypeError): ObjectField(properties).validate({'a': None})
def test_fails_validate_object_required_property(value): properties = {'a': Field(required=True)} with pytest.raises(TypeError): ObjectField(properties).validate(value)
def test_fails_validate_object(value): with pytest.raises(TypeError): ObjectField(nullable=False).validate(value)
def test_validate_object(value): ObjectField(nullable=False).validate(value)
def test_resolve_property_without_default(): properties = {'a': Field(nullable=False, default=1)} assert ObjectField(properties).resolve({'a': None}) == {'a': 1}