From 0bea96ad0931611ee33cef8390e75d1a763e5bbe Mon Sep 17 00:00:00 2001 From: Okhin Date: Wed, 17 Jul 2019 15:43:06 +0200 Subject: [PATCH] Adding a test to check that you're not allowed to upvote a published article --- apps/rp/tests/test_votes_views.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/rp/tests/test_votes_views.py b/apps/rp/tests/test_votes_views.py index dec14bb..bc1d81d 100644 --- a/apps/rp/tests/test_votes_views.py +++ b/apps/rp/tests/test_votes_views.py @@ -1,6 +1,6 @@ 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 -- GitLab