...
 
Commits (2)
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