MCPcopy Create free account
hub / github.com/hashintel/hash / properties_replace

Function properties_replace

tests/graph/integration/postgres/partial_updates.rs:276–366  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

274
275#[tokio::test]
276async fn properties_replace() {
277 let mut database = DatabaseTestWrapper::new().await;
278 let mut api = seed(&mut database).await;
279
280 let entity = api
281 .create_entity(
282 api.account_id,
283 CreateEntityParams {
284 web_id: WebId::new(api.account_id),
285 entity_uuid: None,
286 decision_time: None,
287 entity_type_ids: HashSet::from([person_entity_type_id()]),
288 properties: PropertyObjectWithMetadata::from_parts(alice(), None)
289 .expect("could not create property with metadata object"),
290 confidence: None,
291 link_data: None,
292 draft: false,
293 policies: Vec::new(),
294 provenance: ProvidedEntityEditionProvenance {
295 actor_type: ActorType::User,
296 origin: OriginProvenance::from_empty_type(OriginType::Api),
297 sources: Vec::new(),
298 },
299 read_only: false,
300 },
301 )
302 .await
303 .expect("could not create entity");
304 let entity_id = entity.metadata.record_id.entity_id;
305
306 api.patch_entity(
307 api.account_id,
308 PatchEntityParams {
309 entity_id,
310 decision_time: None,
311 entity_type_ids: HashSet::new(),
312 properties: vec![PropertyPatchOperation::Replace {
313 path: once(PropertyPathElement::from(name_property_type_id())).collect(),
314 property: PropertyWithMetadata::Value(PropertyValueWithMetadata {
315 value: PropertyValue::String("Bob".to_owned()),
316 metadata: ValueMetadata {
317 confidence: None,
318 data_type_id: None,
319 original_data_type_id: None,
320 provenance: ValueProvenance::default(),
321 canonical: HashMap::default(),
322 },
323 }),
324 }],
325 draft: None,
326 archived: None,
327 confidence: None,
328 provenance: ProvidedEntityEditionProvenance {
329 actor_type: ActorType::User,
330 origin: OriginProvenance::from_empty_type(OriginType::Api),
331 sources: Vec::new(),
332 },
333 },

Callers

nothing calls this directly

Calls 13

create_entityMethod · 0.80
unwrapMethod · 0.80
seedFunction · 0.70
person_entity_type_idFunction · 0.70
aliceFunction · 0.70
fromFunction · 0.50
for_entity_by_entity_idFunction · 0.50
expectMethod · 0.45
patch_entityMethod · 0.45
query_entitiesMethod · 0.45
nextMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected