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
dfbe1fec
Commit
dfbe1fec
authored
8 years ago
by
Geert Kapteijns
Browse files
Options
Downloads
Patches
Plain Diff
Use reverse instead of hardcoding urls in theses/test_views.py
parent
e06a8e8e
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
theses/test_views.py
+30
-4
30 additions, 4 deletions
theses/test_views.py
with
30 additions
and
4 deletions
theses/test_views.py
+
30
−
4
View file @
dfbe1fec
from
django.test
import
TestCase
from
django.test
import
TestCase
,
RequestFactory
from
django.test.client
import
Client
from
django.test.client
import
Client
from
django.contrib.auth.models
import
AnonymousUser
from
django.urls
import
reverse
from
.views
import
request_thesislink
,
RequestThesisLink
from
scipost.factories
import
UserFactory
from
.factories
import
ThesisLinkFactory
from
.models
import
ThesisLink
class
TestThesisDetail
(
TestCase
):
class
TestThesisDetail
(
TestCase
):
fixtures
=
[
'
groups
'
,
'
permissions
'
]
def
test_visits_valid_thesis_detail
(
self
):
thesis_link
=
ThesisLinkFactory
()
client
=
Client
()
target
=
reverse
(
'
theses:thesis
'
,
kwargs
=
{
'
thesislink_id
'
:
thesis_link
.
id
})
response
=
client
.
post
(
target
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_acknowledges_after_submitting_comment
(
self
):
class
TestRequestThesisLink
(
TestCase
):
fixtures
=
[
'
groups
'
,
'
permissions
'
]
def
test_response_when_not_logged_in
(
self
):
'''
A visitor that is not logged in cannot view this page.
'''
client
=
Client
()
client
=
Client
()
response
=
client
.
post
(
'
/theses/1
'
)
response
=
client
.
get
(
'
/theses/request_thesislink
'
)
self
.
assertEqual
(
response
.
get
(
'
location
'
),
'
bladiebla
'
)
self
.
assertEqual
(
response
.
status_code
,
403
)
def
test_response_when_logged_in
(
self
):
request
=
RequestFactory
().
get
(
'
/theses/request_thesislink
'
)
request
.
user
=
UserFactory
()
response
=
request_thesislink
(
request
)
self
.
assertEqual
(
response
.
status_code
,
200
)
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