def create_eitem(document_pid, open_access=True): """Create eitem record.""" obj = { "document_pid": document_pid, "open_access": open_access, "created_by": { "type": "script", "value": "migration" }, } record_uuid = uuid.uuid4() provider = EItemIdProvider.create( object_type="rec", object_uuid=record_uuid, ) obj["pid"] = provider.pid.pid_value eitem = EItem.create(obj, record_uuid) eitems_logger.info( "CREATED", extra=dict( document_pid=document_pid, new_pid=eitem["pid"], status="SUCCESS", ), ) return eitem
def create_eitem(document_pid, open_access=True): """Create eitem record.""" obj = {"document_pid": document_pid, "open_access": open_access} record_uuid = uuid.uuid4() provider = EItemIdProvider.create( object_type="rec", object_uuid=record_uuid, ) obj["pid"] = provider.pid.pid_value eitem = EItem.create(obj, record_uuid) return eitem
def test_eitem_refs(app, testdata): """Test creation of an eitem.""" eitem = EItem.create( dict( pid="eitemid-99", document_pid="docid-1", created_by=dict(type="script", value="demo"), )) assert "$schema" in eitem assert "document" in eitem and "$ref" in eitem["document"] eitem = EItem.get_record_by_pid("eitemid-4") eitem = eitem.replace_refs() assert "document" in eitem and eitem["document"]["title"]
def create_eitem(document_pid, open_access=True): """Create eitem record.""" obj = { "document_pid": document_pid, "open_access": open_access, "created_by": { "type": "script", "value": "migration" }, } record_uuid = uuid.uuid4() provider = EItemIdProvider.create( object_type="rec", object_uuid=record_uuid, ) obj["pid"] = provider.pid.pid_value eitem = EItem.create(obj, record_uuid) return eitem