Skip to content

Commit

Permalink
add positive test cases for institutional access project curator vali…
Browse files Browse the repository at this point in the history
…dation
  • Loading branch information
John Tordoff committed Jan 10, 2025
1 parent d1a7412 commit 5c33833
Showing 1 changed file with 39 additions and 6 deletions.
45 changes: 39 additions & 6 deletions osf_tests/test_institutional_admin_contributors.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,48 @@ def institutional_admin(self, institution):
institution.get_group('institutional_admins').user_set.add(admin_user)
return admin_user

def test_contributor_with_visible_and_institutional_admin_raises_error(self, institutional_admin, project, institution):
contributor = Contributor(
@pytest.fixture()
def curator(self, institutional_admin, project):
return Contributor(
user=institutional_admin,
node=project,
visible=False,
is_curator=True
)
contributor.save()

contributor.visible = True

def test_contributor_with_visible_and_institutional_admin_raises_error(self, curator, project, institution):
curator.save()
curator.visible = True
with pytest.raises(IntegrityError, match='Curators cannot be made bibliographic contributors'):
contributor.save()
curator.save()

assert curator.visible
curator.refresh_from_db()
assert not curator.visible

# save completes when valid
curator.visible = False
curator.save()

def test_regular_visible_contributor_is_saved(self, user, project):
contributor = Contributor(
user=user,
node=project,
visible=True,
is_curator=False
)
contributor.save()
saved_contributor = Contributor.objects.get(pk=contributor.pk)
assert saved_contributor.user == user
assert saved_contributor.node == project
assert saved_contributor.visible is True
assert saved_contributor.is_curator is False

def test_invisible_curator_is_saved(self, institutional_admin, curator, project):
curator.save()
saved_curator = Contributor.objects.get(pk=curator.pk)
assert curator == saved_curator
assert saved_curator.user == institutional_admin
assert saved_curator.node == project
assert saved_curator.visible is False
assert saved_curator.is_curator is True

0 comments on commit 5c33833

Please sign in to comment.