Skip to content

Commit

Permalink
Remets en place quelques tests injustement éliminés
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud-D committed Mar 6, 2022
1 parent f96d518 commit 2fa53c4
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 10 deletions.
12 changes: 3 additions & 9 deletions zds/tutorialv2/tests/tests_views/tests_content.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import datetime
from json import loads
import shutil
import tempfile
import zipfile
Expand All @@ -10,7 +9,6 @@
from django.conf import settings
from django.contrib import messages
from django.contrib.auth.models import Group
from django.core import mail
from django.urls import reverse
from django.test import TestCase
from django.utils.translation import gettext_lazy as _
Expand All @@ -21,7 +19,7 @@
from zds.gallery.models import GALLERY_WRITE, UserGallery, Gallery
from zds.gallery.models import Image
from zds.member.tests.factories import ProfileFactory, StaffProfileFactory, UserFactory
from zds.mp.models import PrivateTopic, is_privatetopic_unread, PrivatePost
from zds.mp.models import PrivateTopic, PrivatePost
from zds.notification.models import (
TopicAnswerSubscription,
ContentReactionAnswerSubscription,
Expand All @@ -40,20 +38,16 @@
PublishableContent,
Validation,
PublishedContent,
ContentReaction,
ContentRead,
)
from zds.tutorialv2.publication_utils import (
publish_content,
PublicatorRegistry,
Publicator,
ZMarkdownRebberLatexPublicator,
ZMarkdownEpubPublicator,
)
from zds.tutorialv2.tests import TutorialTestMixin, override_for_contents
from zds.utils.models import HelpWriting, Alert, Tag, Hat
from zds.utils.tests.factories import HelpWritingFactory, CategoryFactory, SubCategoryFactory, LicenceFactory
from zds.utils.header_notifications import get_header_notifications
from zds.utils.models import HelpWriting, Tag
from zds.utils.tests.factories import HelpWritingFactory, SubCategoryFactory, LicenceFactory
from zds import json_handler


Expand Down
45 changes: 44 additions & 1 deletion zds/tutorialv2/tests/tests_views/tests_published.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
from json import loads

from django.conf import settings
from django.contrib.auth.models import Group
Expand Down Expand Up @@ -29,7 +30,7 @@
from zds.tutorialv2.publication_utils import publish_content
from zds.tutorialv2.tests import TutorialTestMixin
from zds.utils.models import Alert, Tag, Hat
from zds.utils.tests.factories import CategoryFactory, SubCategoryFactory, LicenceFactory
from zds.utils.tests.factories import CategoryFactory, SubCategoryFactory, LicenceFactory, HelpWritingFactory
from zds.utils.header_notifications import get_header_notifications
from copy import deepcopy
from zds import json_handler
Expand Down Expand Up @@ -2040,3 +2041,45 @@ def test_social_cards_with_image(self):
self.assertEqual(result.status_code, 200)

self.check_images_socials(result, "media/galleries/", self.chapter1.title, self.tuto.description)

def test_add_help_tuto(self):
self.client.force_login(self.user_author)
tutorial = PublishableContentFactory(author_list=[self.user_author])
help_wanted = HelpWritingFactory()
resp = self.client.post(
reverse("content:helps-change", args=[tutorial.pk]), {"activated": True, "help_wanted": help_wanted.title}
)
self.assertEqual(302, resp.status_code)
self.assertEqual(1, PublishableContent.objects.filter(pk=tutorial.pk).first().helps.count())

def test_add_help_opinion(self):
self.client.force_login(self.user_author)
tutorial = PublishableContentFactory(author_list=[self.user_author], type="OPINION")
help_wanted = HelpWritingFactory()
resp = self.client.post(
reverse("content:helps-change", args=[tutorial.pk]), {"activated": True, "help_wanted": help_wanted.title}
)
self.assertEqual(400, resp.status_code)
self.assertEqual(0, PublishableContent.objects.filter(pk=tutorial.pk).first().helps.count())

def test_save_no_redirect(self):
self.client.force_login(self.user_author)
tutorial = PublishableContentFactory(author_list=[self.user_author])
extract = ExtractFactory(db_object=tutorial, container=tutorial.load_version())
tutorial = PublishableContent.objects.get(pk=tutorial.pk)
resp = self.client.post(
reverse("content:edit-extract", args=[tutorial.pk, tutorial.slug, extract.slug]),
{
"last_hash": extract.compute_hash(),
"text": "a brand new text",
"title": extract.title,
"msg_commit": "a commit message",
},
HTTP_X_REQUESTED_WITH="XMLHttpRequest",
follow=False,
)
# no redirect
self.assertEqual(200, resp.status_code)
result = loads(resp.content.decode("utf-8"))
self.assertEqual("ok", result.get("result", None))
self.assertEqual(extract.compute_hash(), result.get("last_hash", None))

0 comments on commit 2fa53c4

Please sign in to comment.