def get_model(self, fqid: str) -> Dict[str, Any]: model = self.datastore.get( get_fqid(fqid), get_deleted_models=DeletedModelsBehaviour.ALL_MODELS) self.assertTrue(model) self.assertEqual(model.get("id"), get_id_from_fqid(fqid)) return model
def get_model(self, fqid: str) -> Dict[str, Any]: model = self.datastore.get( get_fqid(fqid), mapped_fields=[], get_deleted_models=DeletedModelsBehaviour.ALL_MODELS, lock_result=False, use_changed_models=False, ) self.assertTrue(model) self.assertEqual(model.get("id"), get_id_from_fqid(fqid)) return model
def create_model(self, fqid: str, data: Dict[str, Any], deleted: bool = False) -> None: data["id"] = get_id_from_fqid(fqid) request = WriteRequestElement( events=[Event(type="create", fqid=get_fqid(fqid), fields=data)], information={}, user_id=0, ) if deleted: request["events"].append(Event(type="delete", fqid=get_fqid(fqid))) self.datastore.write(request)
def get_create_request( self, fqid: str, data: Dict[str, Any] = {}, deleted: bool = False ) -> WriteRequest: data["id"] = get_id_from_fqid(fqid) self.validate_fields(fqid, data) request = WriteRequest( events=[Event(type=EventType.Create, fqid=get_fqid(fqid), fields=data)], information={}, user_id=0, locked_fields={}, ) if deleted: request.events.append(Event(type=EventType.Delete, fqid=get_fqid(fqid))) return request
def create_model_with_information( self, fqid: str, data: Dict[str, Any], information: Dict[FullQualifiedId, List[str]], user_id: int = 1, ) -> None: data["id"] = get_id_from_fqid(fqid) self.validate_fields(fqid, data) request = WriteRequest( events=[Event(type=EventType.Create, fqid=get_fqid(fqid), fields=data)], information=information, user_id=user_id, locked_fields={}, ) self.datastore.write(request)