Commit 0bea96ad authored by okhin's avatar okhin 🚴

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
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment