def test_lazy_model_immutable_after_load(mock_plugin, model_data, model_type, mock_entity_create_id): from attr.exceptions import FrozenInstanceError from coalaip.models import Model, LazyLoadableModel mock_plugin.load.return_value = model_data model = LazyLoadableModel(ld_type=model_type) model.load(mock_entity_create_id, plugin=mock_plugin) with raises(FrozenInstanceError): model.loaded_model = Model(data={'other': 'other'}, ld_type='other_type')
def test_lazy_model_immutable(model_data, model_type): from attr import validators from attr.exceptions import FrozenInstanceError from coalaip.models import Model, LazyLoadableModel model = LazyLoadableModel(data=model_data, ld_type=model_type) with raises(FrozenInstanceError): model.loaded_model = Model(data={'other': 'other'}, ld_type='other_type') with raises(FrozenInstanceError): model.ld_type = 'other_type' with raises(FrozenInstanceError): model.ld_context = 'other_context' with raises(FrozenInstanceError): model.validator = validators.instance_of(str)