Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
La Quadrature du Net
rpteam
Revue de Press
Commits
0bea96ad
Commit
0bea96ad
authored
Jul 17, 2019
by
Okhin
Browse files
Adding a test to check that you're not allowed to upvote a published article
parent
12884ba6
Pipeline
#2661
passed with stages
in 3 minutes and 44 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
apps/rp/tests/test_votes_views.py
View file @
0bea96ad
from
django.urls
import
reverse
from
django.test
import
TestCase
from
django.contrib.auth.models
import
Permission
,
User
from
django.contrib.auth.models
import
Permission
from
rest_framework.test
import
APIClient
from
rest_framework.test
import
APIRequestFactory
,
force_authenticate
...
...
@@ -75,3 +75,12 @@ class VoteViewTestCase(TestCase):
article_db
=
Article
.
objects
.
get
(
id
=
self
.
article
.
id
)
assert
article_db
.
status
==
"REJECTED"
def
test_votes_error_if_publish
(
self
):
article
=
ArticleFactory
(
status
=
"PUBLISHED"
)
url_upvote
=
reverse
(
"api:article-upvote"
,
kwargs
=
{
"pk"
:
article
.
id
})
response
=
self
.
client
.
post
(
url_upvote
)
assert
response
.
status_code
==
400
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment