(
api: &mut DatabaseApi<'_>,
entity_id: EntityId,
actor: ActorEntityUuid,
actor_type: ActorType,
modification: Modification<'_>,
)
| 41 | } |
| 42 | |
| 43 | async fn modify( |
| 44 | api: &mut DatabaseApi<'_>, |
| 45 | entity_id: EntityId, |
| 46 | actor: ActorEntityUuid, |
| 47 | actor_type: ActorType, |
| 48 | modification: Modification<'_>, |
| 49 | ) -> Result<Entity, Report<UpdateError>> { |
| 50 | let (properties, archived) = match modification { |
| 51 | Modification::SetName { property, value } => ( |
| 52 | vec![PropertyPatchOperation::Replace { |
| 53 | path: once(PropertyPathElement::from(property.clone())).collect(), |
| 54 | property: PropertyWithMetadata::Value(PropertyValueWithMetadata { |
| 55 | value: PropertyValue::String(value.to_owned()), |
| 56 | metadata: ValueMetadata { |
| 57 | confidence: None, |
| 58 | data_type_id: None, |
| 59 | original_data_type_id: None, |
| 60 | provenance: ValueProvenance::default(), |
| 61 | canonical: HashMap::default(), |
| 62 | }, |
| 63 | }), |
| 64 | }], |
| 65 | None, |
| 66 | ), |
| 67 | Modification::Archive => (Vec::new(), Some(true)), |
| 68 | }; |
| 69 | |
| 70 | api.patch_entity( |
| 71 | actor, |
| 72 | PatchEntityParams { |
| 73 | entity_id, |
| 74 | decision_time: None, |
| 75 | entity_type_ids: HashSet::new(), |
| 76 | properties, |
| 77 | draft: None, |
| 78 | archived, |
| 79 | confidence: None, |
| 80 | provenance: ProvidedEntityEditionProvenance { |
| 81 | actor_type, |
| 82 | origin: OriginProvenance::from_empty_type(OriginType::Api), |
| 83 | sources: Vec::new(), |
| 84 | }, |
| 85 | }, |
| 86 | ) |
| 87 | .await |
| 88 | } |
| 89 | |
| 90 | /// Asserts that a read-only modification was denied with a `PermissionDenied` (403) status. |
| 91 | fn assert_denied(result: Result<Entity, Report<UpdateError>>, label: &str, action: &str) { |
no test coverage detected