SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SciPost
SciPost
Commits
b19c8601
Commit
b19c8601
authored
7 years ago
by
Jorran de Wit
Browse files
Options
Downloads
Patches
Plain Diff
Add factory tests submission
parent
3978f25d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
submissions/test_utils.py
+62
-4
62 additions, 4 deletions
submissions/test_utils.py
with
62 additions
and
4 deletions
submissions/test_utils.py
+
62
−
4
View file @
b19c8601
import
datetime
from
django.test
import
TestCase
,
tag
from
common.helpers.test
import
add_groups_and_permissions
from
scipost.factories
import
ContributorFactory
from
scipost.models
import
Contributor
from
.constants
import
STATUS_UNASSIGNED
from
.factories
import
UnassignedSubmissionFactory
from
.constants
import
STATUS_UNASSIGNED
,
STATUS_RESUBMISSION_INCOMING
from
.exceptions
import
CycleUpdateDeadlineError
from
.factories
import
UnassignedSubmissionFactory
,
ResubmittedSubmissionFactory
from
.utils
import
GeneralSubmissionCycle
class
TestDefaultSubmissionCycle
(
TestCase
):
...
...
@@ -14,8 +19,13 @@ class TestDefaultSubmissionCycle(TestCase):
'''
def
setUp
(
self
):
"""
Basics for all tests
"""
self
.
submission_date
=
datetime
.
date
.
today
()
add_groups_and_permissions
()
self
.
new_submission
=
UnassignedSubmissionFactory
.
build
()
ContributorFactory
.
create_batch
(
5
)
self
.
new_submission
=
UnassignedSubmissionFactory
(
dates__submission
=
self
.
submission_date
)
@tag
(
'
cycle
'
,
'
core
'
)
def
test_init_submission_factory_is_valid
(
self
):
...
...
@@ -28,8 +38,56 @@ class TestDefaultSubmissionCycle(TestCase):
self
.
assertIsInstance
(
self
.
new_submission
.
submitted_by
,
Contributor
)
self
.
assertFalse
(
self
.
new_submission
.
open_for_commenting
)
self
.
assertFalse
(
self
.
new_submission
.
open_for_reporting
)
self
.
assertEqual
(
self
.
new_submission
.
submission_date
,
self
.
submission_date
)
@tag
(
'
cycle
'
,
'
core
'
)
def
test_initial_cycle_required_actions
(
self
):
def
test_initial_cycle_required_actions
_and_deadline
(
self
):
"""
Test valid required actions for default cycle.
"""
self
.
assertIsInstance
(
self
.
new_submission
.
cycle
,
GeneralSubmissionCycle
)
# Explicit: No actions required if no EIC is assigned yet
self
.
assertFalse
(
self
.
new_submission
.
cycle
.
get_required_actions
())
# Two weeks deadline check
self
.
new_submission
.
cycle
.
update_deadline
()
real_report_deadline
=
self
.
submission_date
+
datetime
.
timedelta
(
days
=
28
)
self
.
assertEqual
(
self
.
new_submission
.
reporting_deadline
.
day
,
real_report_deadline
.
day
)
self
.
assertEqual
(
self
.
new_submission
.
reporting_deadline
.
month
,
real_report_deadline
.
month
)
self
.
assertEqual
(
self
.
new_submission
.
reporting_deadline
.
year
,
real_report_deadline
.
year
)
self
.
assertIsInstance
(
self
.
new_submission
.
reporting_deadline
,
datetime
.
datetime
)
class
TestResubmissionSubmissionCycle
(
TestCase
):
'''
This TestCase should act as a master test to check all steps in the
submission
'
s cycle: resubmission.
'''
def
setUp
(
self
):
"""
Basics for all tests
"""
self
.
submission_date
=
datetime
.
date
.
today
()
add_groups_and_permissions
()
ContributorFactory
.
create_batch
(
5
)
self
.
new_submission
=
ResubmittedSubmissionFactory
(
dates__submission
=
self
.
submission_date
)
@tag
(
'
cycle
'
,
'
core
'
)
def
test_init_resubmission_factory_is_valid
(
self
):
"""
Ensure valid fields for the factory.
"""
return
self
.
assertEqual
(
self
.
new_submission
.
status
,
STATUS_RESUBMISSION_INCOMING
)
self
.
assertIsInstance
(
self
.
new_submission
.
editor_in_charge
,
Contributor
)
self
.
assertTrue
(
self
.
new_submission
.
is_current
)
self
.
assertTrue
(
self
.
new_submission
.
is_resubmission
)
self
.
assertIsNot
(
self
.
new_submission
.
title
,
''
)
self
.
assertIsInstance
(
self
.
new_submission
.
submitted_by
,
Contributor
)
self
.
assertTrue
(
self
.
new_submission
.
open_for_commenting
)
self
.
assertTrue
(
self
.
new_submission
.
open_for_reporting
)
self
.
assertEqual
(
self
.
new_submission
.
submission_date
,
self
.
submission_date
)
@tag
(
'
cycle
'
,
'
core
'
)
def
test_initial_cycle_required_actions_and_deadline
(
self
):
"""
Test valid required actions for default cycle.
"""
return
self
.
assertRaises
(
CycleUpdateDeadlineError
,
self
.
new_submission
.
update_deadline
())
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment