Skip to content

Commit

Permalink
Corrige 'tests_display.py'
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud-D committed Sep 15, 2024
1 parent 438fe19 commit c6427cc
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions zds/tutorialv2/tests/tests_views/tests_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from django.test import TestCase
from django.test.utils import override_settings
from django.urls import reverse
from django.utils.translation import gettext_lazy as _

from zds.member.tests.factories import ProfileFactory
from zds.tutorialv2.tests import TutorialTestMixin
Expand Down Expand Up @@ -34,23 +33,14 @@ def setUp(self):
self.user_author = ProfileFactory().user
self.client.force_login(self.user_author)

# Publish an article:
# Publish an article
self.article = PublishedContentFactory(author_list=[self.user_author], type="ARTICLE")

def _new_draft_version(self, text):
# Create a new draft version:
versioned = self.article.load_version()
"""Create a new draft version."""
result = self.client.post(
reverse("content:edit", args=[self.article.pk, self.article.slug]),
{
"title": self.article.title,
"description": self.article.description,
"introduction": text,
"conclusion": "Modified conclusion",
"type": self.article.type,
"subcategory": self.article.subcategory.first().pk,
"last_hash": versioned.compute_hash(),
},
reverse("content:edit-introduction", args=[self.article.pk]),
{"introduction": text},
follow=False,
)
self.assertEqual(result.status_code, 302)
Expand Down Expand Up @@ -84,7 +74,7 @@ def common_tests():
self.assertNotContains(public_page, PublicActionsState.messages["draft_is_same"])
self.assertContains(public_page, PublicActionsState.messages["draft_is_more_recent"])

# Now a new draft version, to have different version from validation:
# Now a new draft version, to have different version from validation
self._new_draft_version(self.TEXT_SECOND_MODIFICATION)

public_page = common_tests()
Expand Down Expand Up @@ -123,7 +113,7 @@ def common_tests():
self.assertNotContains(draft_page, PublicActionsState.messages["public_is_same"])
self.assertContains(draft_page, ValidationActions.messages["validation_is_same"])

# Now a new draft version, to have different version from validation:
# Now a new draft version, to have different version from validation
self._new_draft_version(self.TEXT_SECOND_MODIFICATION)

draft_page = common_tests()
Expand All @@ -150,9 +140,7 @@ def common_tests():
self._new_draft_version(self.TEXT_FIRST_MODIFICATION)
request_validation(self.article)

validation_page = common_tests()

# Now a new draft version, to have different version from validation:
# Now a new draft version, to have different version from validation
self._new_draft_version(self.TEXT_SECOND_MODIFICATION)

validation_page = common_tests()
Expand Down

0 comments on commit c6427cc

Please sign in to comment.