From 9b916bd602b9badff76a21248f89054e3088521b Mon Sep 17 00:00:00 2001 From: John Tordoff <> Date: Thu, 8 Aug 2024 11:05:24 -0700 Subject: [PATCH 1/3] fix self link --- api/preprints/serializers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/preprints/serializers.py b/api/preprints/serializers.py index 5c6d7258883..3531184a33e 100644 --- a/api/preprints/serializers.py +++ b/api/preprints/serializers.py @@ -209,7 +209,7 @@ class PreprintSerializer(TaxonomizableSerializerMixin, MetricsSerializerMixin, J affiliated_institutions = RelationshipField( related_view='preprints:preprints-institutions', related_view_kwargs={'preprint_id': '<_id>'}, - self_view='preprints:preprints-institutions', + self_view='preprints:preprint-relationships-institutions', self_view_kwargs={'preprint_id': '<_id>'}, read_only=False, required=False, From 2e4e47d79de8d52e6fd71e8149059e919641e47a Mon Sep 17 00:00:00 2001 From: John Tordoff <> Date: Thu, 8 Aug 2024 11:24:28 -0700 Subject: [PATCH 2/3] add tests for self link --- api_tests/preprints/views/test_preprint_detail.py | 2 ++ api_tests/preprints/views/test_preprint_list.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/api_tests/preprints/views/test_preprint_detail.py b/api_tests/preprints/views/test_preprint_detail.py index 66f65b72a4f..916274d88f7 100644 --- a/api_tests/preprints/views/test_preprint_detail.py +++ b/api_tests/preprints/views/test_preprint_detail.py @@ -229,6 +229,8 @@ def test_return_affiliated_institutions(self, app, user, preprint, institution, assert res.status_code == 200 relationship_link = res.json['data']['relationships']['affiliated_institutions']['links']['related']['href'] assert f'/v2/preprints/{preprint._id}/institutions/' in relationship_link + relationship_link = res.json['data']['relationships']['affiliated_institutions']['links']['self']['href'] + assert f'/v2/preprints/{preprint._id}/relationships/institutions/' in relationship_link @pytest.mark.django_db diff --git a/api_tests/preprints/views/test_preprint_list.py b/api_tests/preprints/views/test_preprint_list.py index 305dca450d5..5fd8f224a01 100644 --- a/api_tests/preprints/views/test_preprint_list.py +++ b/api_tests/preprints/views/test_preprint_list.py @@ -197,7 +197,8 @@ def test_return_affiliated_institutions(self): assert res.content_type == 'application/vnd.api+json' relationship_link = res.json['data'][0]['relationships']['affiliated_institutions']['links']['related']['href'] assert f'/v2/preprints/{self.preprint._id}/institutions/' in relationship_link - + relationship_link = res.json['data'][0]['relationships']['affiliated_institutions']['links']['self']['href'] + assert f'/v2/preprints/{self.preprint._id}/relationships/institutions/' in relationship_link class TestPreprintsListFiltering(PreprintsListFilteringMixin): From 55d4b74cbbc8a5f6355beb5be992d79bf27b5f1d Mon Sep 17 00:00:00 2001 From: John Tordoff <> Date: Fri, 9 Aug 2024 06:54:59 -0700 Subject: [PATCH 3/3] add test confirming preprint affiliated institution data is sent to SHARE --- osf_tests/metadata/test_osf_gathering.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/osf_tests/metadata/test_osf_gathering.py b/osf_tests/metadata/test_osf_gathering.py index 52289367ccc..7bd72770aba 100644 --- a/osf_tests/metadata/test_osf_gathering.py +++ b/osf_tests/metadata/test_osf_gathering.py @@ -538,6 +538,7 @@ def test_gather_affiliated_institutions(self): institution_iri = URIRef(institution.ror_uri) self.user__admin.add_or_update_affiliated_institution(institution) self.project.add_affiliated_institution(institution, self.user__admin) + self.preprint.add_affiliated_institution(institution, self.user__admin) assert_triples(osf_gathering.gather_affiliated_institutions(self.projectfocus), { (self.projectfocus.iri, OSF.affiliation, institution_iri), (institution_iri, RDF.type, DCTERMS.Agent), @@ -559,6 +560,15 @@ def test_gather_affiliated_institutions(self): assert_triples(osf_gathering.gather_affiliated_institutions(self.registrationfocus), set()) # focus: file assert_triples(osf_gathering.gather_affiliated_institutions(self.filefocus), set()) + # focus: preprint + assert_triples(osf_gathering.gather_affiliated_institutions(self.preprintfocus), { + (self.preprintfocus.iri, OSF.affiliation, institution_iri), + (institution_iri, RDF.type, DCTERMS.Agent), + (institution_iri, RDF.type, FOAF.Organization), + (institution_iri, FOAF.name, Literal(institution.name)), + (institution_iri, DCTERMS.identifier, Literal(institution.identifier_domain)), + (institution_iri, DCTERMS.identifier, Literal(institution.ror_uri)), + }) def test_gather_funding(self): # focus: project