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
64e87b1d
Commit
64e87b1d
authored
7 years ago
by
Jorran de Wit
Browse files
Options
Downloads
Patches
Plain Diff
Extend Submission Prefiller view tests
parent
4d66c627
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
submissions/templates/submissions/new_submission.html
+1
-1
1 addition, 1 deletion
submissions/templates/submissions/new_submission.html
submissions/test_views.py
+41
-16
41 additions, 16 deletions
submissions/test_views.py
with
42 additions
and
17 deletions
submissions/templates/submissions/new_submission.html
+
1
−
1
View file @
64e87b1d
...
...
@@ -54,7 +54,6 @@ $(document).ready(function(){
<div
class=
"row mb-5"
>
<div
class=
"col-12"
>
{% if perms.scipost.can_submit_manuscript %}
{% if form.arxiv_link.value %}
<form
id=
"full_submission_form"
action=
"{% url 'submissions:submit_manuscript' %}"
method=
"post"
>
{% csrf_token %}
...
...
@@ -64,6 +63,7 @@ $(document).ready(function(){
</p>
<input
type=
"submit"
class=
"btn btn-secondary"
/>
</form>
{% else %}
{% endif %}
{% else %}
...
...
This diff is collapsed.
Click to expand it.
submissions/test_views.py
+
41
−
16
View file @
64e87b1d
...
...
@@ -4,9 +4,12 @@ from django.test import Client
from
common.helpers.test
import
add_groups_and_permissions
from
scipost.factories
import
ContributorFactory
from
scipost.models
import
Contributor
#
from scipost.models import Contributor
from
.constants
import
STATUS_UNASSIGNED
from
.factories
import
EICassignedSubmissionFactory
from
.forms
import
SubmissionForm
,
SubmissionIdentifierForm
from
.models
import
Submission
class
BaseContributorTestCase
(
TestCase
):
...
...
@@ -20,44 +23,66 @@ class BaseContributorTestCase(TestCase):
class
PrefillUsingIdentifierTest
(
BaseContributorTestCase
):
def
test_retrieving_existing_arxiv_paper
(
self
):
def
setUp
(
self
):
super
().
setUp
()
self
.
client
=
Client
()
self
.
url
=
reverse
(
'
submissions:prefill_using_identifier
'
)
self
.
assertTrue
(
self
.
client
.
login
(
username
=
"
Test
"
,
password
=
"
testpw
"
))
def
test_basic_responses
(
self
):
# Test anonymous client is rejected
client
=
Client
()
client
.
login
(
username
=
"
Test
"
,
password
=
"
testpw
"
)
response
=
client
.
get
(
self
.
url
)
self
.
assertEqual
(
response
.
status_code
,
403
)
response
=
client
.
post
(
self
.
url
,
{
'
identifier
'
:
'
1512.00030v1
'
})
self
.
assertEqual
(
response
.
status_code
,
403
)
response
=
client
.
post
(
reverse
(
'
submissions:prefill_using_identifier
'
),
{
'
identifier
'
:
'
1512.00030v1
'
})
# Registered Contributor should get 200
response
=
self
.
client
.
get
(
self
.
url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_retrieving_existing_arxiv_paper
(
self
):
'''
Test view with a valid post request.
'''
response
=
self
.
client
.
post
(
self
.
url
,
{
'
identifier
'
:
'
1512.00030v1
'
})
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertIsInstance
(
response
.
context
[
'
form
'
],
SubmissionForm
)
self
.
assertIsInstance
(
response
.
context
[
'
identifierform
'
],
SubmissionIdentifierForm
)
self
.
assertTrue
(
response
.
context
[
'
identifierform
'
].
is_valid
())
def
test_still_200_ok_if_identifier_is_wrong
(
self
):
client
=
Client
()
client
.
login
(
username
=
"
Test
"
,
password
=
"
testpw
"
)
response
=
client
.
post
(
reverse
(
'
submissions:prefill_using_identifier
'
),
{
'
identifier
'
:
'
1512.00030
'
})
response
=
self
.
client
.
post
(
self
.
url
,
{
'
identifier
'
:
'
1512.00030
'
})
self
.
assertEqual
(
response
.
status_code
,
200
)
class
SubmitManuscriptTest
(
BaseContributorTestCase
):
def
test_submit_correct_manuscript
(
self
):
client
=
Client
()
client
.
login
(
username
=
"
Test
"
,
password
=
"
testpw
"
)
# Unauthorized request shouldn't be possible
response
=
client
.
post
(
reverse
(
'
submissions:prefill_using_identifier
'
),
{
'
identifier
'
:
'
1512.00030v1
'
})
self
.
assertEquals
(
response
.
status_code
,
403
)
params
=
response
.
context
[
'
form
'
].
initial
# Registered Contributor should get 200
self
.
assertTrue
(
client
.
login
(
username
=
"
Test
"
,
password
=
"
testpw
"
))
response
=
client
.
post
(
reverse
(
'
submissions:prefill_using_identifier
'
),
{
'
identifier
'
:
'
1512.00030v1
'
})
self
.
assertEqual
(
response
.
status_code
,
200
)
extras
=
{
# Fill form parameters
params
=
response
.
context
[
'
form
'
].
initial
params
.
update
({
'
discipline
'
:
'
physics
'
,
'
submitted_to_journal
'
:
'
SciPost Physics
'
,
'
submission_type
'
:
'
Article
'
,
'
domain
'
:
'
T
'
}
response
=
client
.
post
(
reverse
(
'
submissions:submit_manuscript
'
),
{
**
params
,
**
extras
}
)
}
)
response
=
client
.
post
(
reverse
(
'
submissions:submit_manuscript
'
),
**
params
)
self
.
assertEqual
(
response
.
status_code
,
200
)
# submission = Submission.objects.filter(status=STATUS_UNASSIGNED).last()
# raise Exception(response.content)
# self.assertIn(submission, response.context)
class
SubmissionDetailTest
(
BaseContributorTestCase
):
...
...
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