Skip to content

Commit 069c497

Browse files
committed
Clean up submission test data
1 parent 7fac40a commit 069c497

File tree

1 file changed

+21
-26
lines changed

1 file changed

+21
-26
lines changed

src/submission/tests.py

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ def test_new_journals_has_submission_configuration(self):
5151
if not self.journal_one.submissionconfiguration:
5252
self.fail('Journal does not have a submissionconfiguration object.')
5353

54-
@staticmethod
55-
def create_journal():
54+
@classmethod
55+
def create_journal(cls):
5656
"""
5757
Creates a dummy journal for testing
5858
:return: a journal
@@ -95,32 +95,31 @@ def create_authors(cls):
9595

9696
return author_1, author_2
9797

98-
def create_sections(self):
99-
self.section_1 = models.Section.objects.create(
98+
@classmethod
99+
def create_sections(cls):
100+
cls.section_1 = models.Section.objects.create(
100101
name='Test Public Section',
101-
journal=self.journal_one,
102+
journal=cls.journal_one,
102103
)
103-
self.section_2 = models.Section.objects.create(
104+
cls.section_2 = models.Section.objects.create(
104105
name='Test Private Section',
105106
public_submissions=False,
106-
journal=self.journal_one
107+
journal=cls.journal_one
107108
)
108-
self.section_3 = models.Section.objects.create(
109-
journal=self.journal_one,
109+
cls.section_3 = models.Section.objects.create(
110+
journal=cls.journal_one,
110111
)
111112

112113
@classmethod
113114
def setUpTestData(cls):
114-
cls.journal_one = cls.create_journal()
115-
116-
def setUp(self):
117115
"""
118116
Setup the test environment.
119117
:return: None
120118
"""
121-
self.editor = helpers.create_editor(self.journal_one)
122-
self.press = helpers.create_press()
123-
self.create_sections()
119+
cls.journal_one = cls.create_journal()
120+
cls.editor = helpers.create_editor(cls.journal_one)
121+
cls.press = helpers.create_press()
122+
cls.create_sections()
124123

125124
def test_article_image_galley(self):
126125
article = models.Article.objects.create(
@@ -280,9 +279,9 @@ def test_snapshot_author_metadata_override(self):
280279

281280
article.snapshot_authors()
282281
new_department = "New department"
283-
for frozen in article.frozen_authors():
284-
frozen.department = new_department
285-
frozen.save()
282+
for frozen_author in article.frozen_authors():
283+
frozen_author.department = new_department
284+
frozen_author.save()
286285
article.snapshot_authors(force_update=True)
287286
frozen = article.frozen_authors().all()[0]
288287

@@ -789,8 +788,7 @@ def create_journal():
789788

790789
return journal_one
791790

792-
@classmethod
793-
def create_authors(cls):
791+
def create_authors(self):
794792
author_1_data = {
795793
'email': '[email protected]',
796794
'is_active': True,
@@ -813,20 +811,17 @@ def create_authors(cls):
813811
'department': 'English & Humanities',
814812
'institution': 'Birkbeck, University of London',
815813
}
816-
author_1 = helpers.create_author(cls.journal_one, **author_1_data)
817-
author_2 = helpers.create_author(cls.journal_one, **author_2_data)
814+
author_1 = helpers.create_author(self.journal_one, **author_1_data)
815+
author_2 = helpers.create_author(self.journal_one, **author_2_data)
818816

819817
return author_1, author_2
820818

821-
@classmethod
822-
def setUpTestData(cls):
823-
cls.journal_one = cls.create_journal()
824-
825819
def setUp(self):
826820
"""
827821
Setup the test environment.
828822
:return: None
829823
"""
824+
self.journal_one = self.create_journal()
830825
self.editor = helpers.create_editor(self.journal_one)
831826
self.press = helpers.create_press()
832827

0 commit comments

Comments
 (0)