Skip to content

Commit

Permalink
add test to test_preprint_detail.py
Browse files Browse the repository at this point in the history
  • Loading branch information
John Tordoff committed Jul 22, 2024
1 parent 4f5995a commit ede2e90
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion api_tests/preprints/views/test_preprint_detail.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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

0 comments on commit ede2e90

Please sign in to comment.