Skip to content

Commit 3048525

Browse files
committed
fix: consistent shtrove record identifiers
when sending cedar records to shtrove as supplementary records about an item, use that item's osfid in the record_identifier instead of a database id, so the records are more clearly associated in shtrove admin
1 parent 8e29e38 commit 3048525

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

api/share/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def share_update_cedar_metadata_record(self, referent_id, cedar_record_pk):
118118
shtrove_ingest_url(),
119119
params={
120120
'focus_iri': referent.get_semantic_iri(),
121-
'record_identifier': _shtrove_cedar_record_identifier(cedar_record._id, cedar_record.template.cedar_id),
121+
'record_identifier': _shtrove_cedar_record_identifier(referent._id, cedar_record.template.cedar_id),
122122
'is_supplementary': True,
123123
},
124124
headers={
@@ -142,7 +142,7 @@ def share_delete_cedar_metadata_record(
142142
response = requests.delete(
143143
shtrove_ingest_url(),
144144
params={
145-
'record_identifier': _shtrove_cedar_record_identifier(cedar_record___id, cedar_template_cedar_id),
145+
'record_identifier': _shtrove_cedar_record_identifier(cedar_referent___id, cedar_template_cedar_id),
146146
},
147147
headers=_shtrove_auth_headers(referent),
148148
)
@@ -300,8 +300,8 @@ def _shtrove_record_identifier(osf_item, osfmap_partition: OsfmapPartition):
300300
)
301301

302302

303-
def _shtrove_cedar_record_identifier(cedar_record___id, template_cedar_id) -> str:
304-
return f'{cedar_record___id}/CedarMetadataRecord:{template_cedar_id}'
303+
def _shtrove_cedar_record_identifier(referent_osfid, template_cedar_id) -> str:
304+
return f'{referent_osfid}/CedarMetadataRecord:{template_cedar_id}'
305305

306306

307307
def _shtrove_auth_headers(osf_item):

osf_tests/test_collection_submission.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -874,12 +874,12 @@ def test_cedar_record_identifier_on_create(self, mock_delete, mock_pls, unmodera
874874
with mock.patch('api.share.utils._shtrove_cedar_record_identifier') as mock_identifier:
875875
unmoderated_collection_submission_public.save()
876876
mock_identifier.assert_called_with(
877-
to_create_record._id,
877+
to_create_record.guid._id,
878878
to_create_record.template.cedar_id
879879
)
880880
assert (
881-
_shtrove_cedar_record_identifier(to_create_record._id, to_create_record.template.cedar_id) ==
882-
f'{to_create_record._id}/CedarMetadataRecord:http26'
881+
_shtrove_cedar_record_identifier(to_create_record.guid._id, to_create_record.template.cedar_id) ==
882+
f'{to_create_record.guid._id}/CedarMetadataRecord:http26'
883883
)
884884

885885
@mock.patch('api.share.utils.pls_send_trove_record')
@@ -897,10 +897,10 @@ def test_cedar_record_identifier_on_delete(self, mock_update, mock_pls, unmodera
897897
with mock.patch('api.share.utils.requests.delete'):
898898
with mock.patch('api.share.utils._shtrove_cedar_record_identifier') as mock_identifier:
899899
unmoderated_collection_submission_public.save()
900-
mock_identifier.assert_called_with(to_delete_record._id, to_delete_record.template.cedar_id)
900+
mock_identifier.assert_called_with(to_delete_record.guid._id, to_delete_record.template.cedar_id)
901901
assert (
902-
_shtrove_cedar_record_identifier(to_delete_record._id, to_delete_record.template.cedar_id) ==
903-
f'{to_delete_record._id}/CedarMetadataRecord:http25'
902+
_shtrove_cedar_record_identifier(to_delete_record.guid._id, to_delete_record.template.cedar_id) ==
903+
f'{to_delete_record.guid._id}/CedarMetadataRecord:http25'
904904
)
905905

906906
@mock.patch('api.share.utils.share_update_cedar_metadata_record')

0 commit comments

Comments
 (0)