Skip to content

Commit

Permalink
Corrige les tests existants
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud-D committed May 8, 2024
1 parent af7998a commit c6339a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 33 deletions.
9 changes: 0 additions & 9 deletions zds/tutorialv2/tests/tests_views/tests_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,6 @@ def test_ensure_access(self):

def test_basic_tutorial_workflow(self):
"""General test on the basic workflow of a tutorial: creation, edition, deletion for the author"""

# login with author
self.client.force_login(self.user_author)

# create tutorial
Expand Down Expand Up @@ -262,13 +260,10 @@ def test_basic_tutorial_workflow(self):
reverse("content:create-content", kwargs={"created_content_type": "TUTORIAL"}),
{
"title": title,
"description": description,
"introduction": intro,
"conclusion": conclusion,
"type": "TUTORIAL",
"licence": self.licence.pk,
"subcategory": self.subcategory.pk,
"image": (settings.BASE_DIR / "fixtures" / "noir_black.png").open("rb"),
},
follow=False,
)
Expand All @@ -282,7 +277,6 @@ def test_basic_tutorial_workflow(self):

self.assertEqual(Gallery.objects.filter(pk=tuto.gallery.pk).count(), 1)
self.assertEqual(UserGallery.objects.filter(gallery__pk=tuto.gallery.pk).count(), tuto.authors.count())
self.assertEqual(Image.objects.filter(gallery__pk=tuto.gallery.pk).count(), 1) # icon is uploaded

# access to tutorial
result = self.client.get(reverse("content:edit", args=[pk, slug]), follow=False)
Expand All @@ -308,14 +302,11 @@ def test_basic_tutorial_workflow(self):
"type": "TUTORIAL",
"subcategory": self.subcategory.pk,
"last_hash": versioned.compute_hash(),
"image": (settings.BASE_DIR / "fixtures" / "logo.png").open("rb"),
},
follow=False,
)
self.assertEqual(result.status_code, 302)

self.assertEqual(Image.objects.filter(gallery__pk=tuto.gallery.pk).count(), 2) # new icon is uploaded

tuto = PublishableContent.objects.get(pk=pk)
self.assertEqual(tuto.licence, None)
versioned = tuto.load_version()
Expand Down
34 changes: 10 additions & 24 deletions zds/tutorialv2/tests/tests_views/tests_published.py
Original file line number Diff line number Diff line change
Expand Up @@ -2044,48 +2044,35 @@ def test_social_cards_without_image(self):
self.check_images_socials(result, "static/images/tutorial-illu", self.chapter1.title, self.tuto.description)

def test_social_cards_with_image(self):
"""
Check that all cards are produce for socials network
"""
# connect with author:
"""Check that all cards are produced for socials network"""
self.client.force_login(self.user_author)
# add image to public tutorial

# Add image to public tutorial
self.client.post(
reverse("content:edit", args=[self.tuto.pk, self.tuto.slug]),
{
"title": self.tuto.title,
"description": self.tuto.description,
"introduction": "",
"conclusion": "",
"type": "TUTORIAL",
"licence": self.tuto.licence.pk,
"subcategory": self.subcategory.pk,
"last_hash": self.tuto.load_version().compute_hash(),
"image": (settings.BASE_DIR / "fixtures" / "logo.png").open("rb"),
},
reverse("content:edit-thumbnail", args=[self.tuto.pk]),
{"image": (settings.BASE_DIR / "fixtures" / "logo.png").open("rb")},
follow=True,
)

# test access for guest user (bot of social network for example)
# Test as a guest (bot of social network for example)
self.client.logout()

# check tutorial cards
# Check tutorial cards
result = self.client.get(reverse("tutorial:view", kwargs={"pk": self.tuto.pk, "slug": self.tuto.slug}))
self.assertEqual(result.status_code, 200)

self.check_images_socials(result, "media/galleries/", self.tuto.title, self.tuto.description)
# check part cards

# Check part cards
result = self.client.get(
reverse(
"tutorial:view-container",
kwargs={"pk": self.tuto.pk, "slug": self.tuto.slug, "container_slug": self.part1.slug},
)
)
self.assertEqual(result.status_code, 200)

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

# check chapter cards
# Check chapter cards
result = self.client.get(
reverse(
"tutorial:view-container",
Expand All @@ -2098,7 +2085,6 @@ 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):
Expand Down

0 comments on commit c6339a3

Please sign in to comment.