Skip to content

Commit

Permalink
Corrige 'test_publication_and_attributes_consistency()'
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud-D committed Sep 18, 2024
1 parent 45be765 commit a874d97
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions zds/tutorialv2/tests/models/tests_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,26 +449,34 @@ def test_publication_and_attributes_consistency(self):
old_description = article.public_version.description()
article.licence = LicenceFactory()
article.save()

self.client.force_login(self.user_author)
self.client.post(
reverse("content:edit", args=[article.pk, article.slug]),
{
"title": old_title + "bla",
"description": old_description + "bla",
"type": "ARTICLE",
"licence": article.licence.pk,
"subcategory": SubCategoryFactory().pk,
"last_hash": article.sha_draft,
},

new_title = old_title + "bla"
result = self.client.post(
reverse("content:edit-title", args=[article.pk]),
{"title": new_title},
follow=True,
)
self.assertEqual(result.status_code, 200)

new_description = old_description + "bla"
result = self.client.post(
reverse("content:edit-subtitle", args=[article.pk]),
{"subtitle": new_description},
follow=True,
)
self.assertEqual(result.status_code, 200)

article = PublishableContent.objects.prefetch_related("public_version").get(pk=article.pk)
article.public_version.load_public_version()
self.assertEqual(old_title, article.public_version.title())
self.assertEqual(old_description, article.public_version.description())
self.assertEqual(old_date, article.public_version.publication_date)

publish_content(article, article.load_version(), False)
article = PublishableContent.objects.get(pk=article.pk)
article.public_version.load_public_version()

article = PublishableContent.objects.prefetch_related("public_version").get(pk=article.pk)
self.assertEqual(old_date, article.public_version.publication_date)
self.assertNotEqual(old_date, article.public_version.update_date)

Expand Down

0 comments on commit a874d97

Please sign in to comment.