Skip to content

Commit

Permalink
Add test case for transferring submitting author.
Browse files Browse the repository at this point in the history
  • Loading branch information
tompollard committed Nov 15, 2023
1 parent 34e25d5 commit f38d11c
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions physionet-django/project/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,45 @@ def test_content(self):
self.assertFalse(project.is_submittable())


class TestProjectTransfer(TestCase):
"""
Tests that submitting author status can be transferred to a co-author
"""
AUTHOR_EMAIL = '[email protected]'
COAUTHOR_EMAIL = '[email protected]'
PASSWORD = 'Tester11!'
PROJECT_SLUG = 'T108xFtYkRAxiRiuOLEJ'

def setUp(self):
self.client.login(username=self.AUTHOR_EMAIL, password=self.PASSWORD)
self.project = ActiveProject.objects.get(slug=self.PROJECT_SLUG)
self.submitting_author = self.project.authors.filter(is_submitting=True).first()
self.coauthor = self.project.authors.filter(is_submitting=False).first()

def test_transfer_author(self):
"""
Test that an activate project can be transferred to a co-author.
"""
self.assertTrue(self.submitting_author.user.email, self.AUTHOR_EMAIL)
self.assertTrue(self.coauthor.user.email, self.COAUTHOR_EMAIL)

response = self.client.post(
reverse('project_authors', args=(self.project.slug,)),
data={
'transfer_author': self.coauthor.user.id,
})

# Check if redirect happens, implying successful transfer
self.assertEqual(response.status_code, 302)

# Fetch the updated project data
updated_project = ActiveProject.objects.get(slug=self.PROJECT_SLUG)

# Verify that the author has been transferred
self.assertFalse(updated_project.authors.get(user=self.submitting_author.user).is_submitting)
self.assertTrue(updated_project.authors.get(user=self.coauthor.user).is_submitting)


class TestAccessPublished(TestMixin):
"""
Test that certain views or content in their various states can only
Expand Down

0 comments on commit f38d11c

Please sign in to comment.