diff --git a/api_tests/preprints/views/test_preprint_detail.py b/api_tests/preprints/views/test_preprint_detail.py index 5645731da51..3d9e2557e60 100644 --- a/api_tests/preprints/views/test_preprint_detail.py +++ b/api_tests/preprints/views/test_preprint_detail.py @@ -1,6 +1,6 @@ import pytest from django.utils import timezone -from osf_tests.factories import PreprintFactory, AuthUserFactory, ProjectFactory +from osf_tests.factories import PreprintFactory, AuthUserFactory, ProjectFactory, InstitutionFactory from api.base.settings.defaults import API_BASE from website.settings import DOI_FORMAT @@ -45,6 +45,10 @@ def res(self, app, url): def data(self, res): return res.json['data'] + @pytest.fixture() + def institution(self, res): + return InstitutionFactory() + def test_preprint_detail(self, app, user, preprint, url, res, data): assert res.status_code == 200 assert res.content_type == 'application/vnd.api+json' @@ -139,3 +143,13 @@ def test_preprint_embed_identifiers(self, app, user, preprint, url): assert res.status_code == 200 link = res.json['data']['relationships']['identifiers']['links']['related']['href'] assert f'{url}identifiers/' in link + + def test_return_affiliated_institutions(self, app, user, preprint, institution, url): + """ + Confirmation test for the the new preprint affiliated institutions feature + """ + preprint.affiliated_institutions.add(institution) + res = app.get(url) + 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 \ No newline at end of file