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
08f73246
Commit
08f73246
authored
8 years ago
by
Geert Kapteijns
Browse files
Options
Downloads
Patches
Plain Diff
Fix bug and clean up theses/test_views.py
parent
85c54374
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
theses/test_views.py
+21
-3
21 additions, 3 deletions
theses/test_views.py
with
21 additions
and
3 deletions
theses/test_views.py
+
21
−
3
View file @
08f73246
import
re
from
django.core.exceptions
import
PermissionDenied
from
django.test
import
TestCase
,
RequestFactory
from
django.test
import
TestCase
,
RequestFactory
from
django.test.client
import
Client
from
django.test.client
import
Client
from
django.contrib.auth.models
import
Group
from
django.contrib.auth.models
import
Group
...
@@ -25,14 +28,15 @@ class TestRequestThesisLink(TestCase):
...
@@ -25,14 +28,15 @@ class TestRequestThesisLink(TestCase):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
client
=
Client
()
self
.
client
=
Client
()
self
.
target
=
reverse
(
'
theses:request_thesislink
'
)
def
test_response_when_not_logged_in
(
self
):
def
test_response_when_not_logged_in
(
self
):
'''
A visitor that is not logged in cannot view this page.
'''
'''
A visitor that is not logged in cannot view this page.
'''
response
=
self
.
client
.
get
(
reverse
(
'
theses:request_thesislink
'
)
)
response
=
self
.
client
.
get
(
self
.
target
)
self
.
assertEqual
(
response
.
status_code
,
403
)
self
.
assertEqual
(
response
.
status_code
,
403
)
def
test_response_when_logged_in
(
self
):
def
test_response_when_logged_in
(
self
):
request
=
RequestFactory
().
get
(
reverse
(
'
theses:request_thesislink
'
)
)
request
=
RequestFactory
().
get
(
self
.
target
)
request
.
user
=
UserFactory
()
request
.
user
=
UserFactory
()
response
=
RequestThesisLink
.
as_view
()(
request
)
response
=
RequestThesisLink
.
as_view
()(
request
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
...
@@ -49,7 +53,21 @@ class TestVetThesisLinkRequests(TestCase):
...
@@ -49,7 +53,21 @@ class TestVetThesisLinkRequests(TestCase):
response
=
self
.
client
.
get
(
self
.
target
)
response
=
self
.
client
.
get
(
self
.
target
)
self
.
assertEqual
(
response
.
status_code
,
403
)
self
.
assertEqual
(
response
.
status_code
,
403
)
def
test_response_when_logged_in
(
self
):
def
test_response_regular_contributor
(
self
):
'''
A Contributor needs to be in the Vetting Editors group to be able to
vet submitted thesis links.
'''
# Create ThesisLink to vet.
ThesisLinkFactory
()
request
=
RequestFactory
().
get
(
self
.
target
)
user
=
UserFactory
()
request
.
user
=
user
self
.
assertRaises
(
PermissionDenied
,
vet_thesislink_requests
,
request
)
def
test_response_vetting_editor
(
self
):
# Create ThesisLink to vet.
ThesisLinkFactory
()
ThesisLinkFactory
()
request
=
RequestFactory
().
get
(
self
.
target
)
request
=
RequestFactory
().
get
(
self
.
target
)
user
=
UserFactory
()
user
=
UserFactory
()
...
...
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