diff --git a/zds/tutorialv2/forms.py b/zds/tutorialv2/forms.py
index 97baeab5b8..36e2c49638 100644
--- a/zds/tutorialv2/forms.py
+++ b/zds/tutorialv2/forms.py
@@ -108,7 +108,7 @@ def __init__(self, *args, **kwargs):
class ContentForm(ContainerForm):
- type = forms.ChoiceField(choices=TYPE_CHOICES, required=False)
+ type = forms.ChoiceField(choices=TYPE_CHOICES, required=True)
def _create_layout(self):
self.helper.layout = Layout(
diff --git a/zds/tutorialv2/tests/tests_views/tests_content.py b/zds/tutorialv2/tests/tests_views/tests_content.py
index 6dbdea6192..4a170b97d6 100644
--- a/zds/tutorialv2/tests/tests_views/tests_content.py
+++ b/zds/tutorialv2/tests/tests_views/tests_content.py
@@ -230,89 +230,38 @@ def test_ensure_access(self):
)
self.assertEqual(result.status_code, 200)
- def test_basic_tutorial_workflow(self):
- """General test on the basic workflow of a tutorial: creation, edition, deletion for the author"""
+ def test_create_tutorial(self):
+ """Test the creation of a new content."""
self.client.force_login(self.user_author)
- # create tutorial
- intro = "une intro"
- conclusion = "une conclusion"
- description = "une description"
title = "un titre"
- random = "un truc à la rien à voir"
- random_with_md = "un text contenant du **markdown** ."
-
- response = self.client.post(
- reverse("content:create-content", kwargs={"created_content_type": "TUTORIAL"}),
- {
- "text": random_with_md,
- "preview": "",
- },
- HTTP_X_REQUESTED_WITH="XMLHttpRequest",
- )
-
- self.assertEqual(200, response.status_code)
-
- result_string = "".join(str(a, "utf-8") for a in response.streaming_content)
- self.assertIn("markdown", result_string, "We need the text to be properly formatted")
-
result = self.client.post(
reverse("content:create-content", kwargs={"created_content_type": "TUTORIAL"}),
- {
- "title": title,
- "introduction": intro,
- "conclusion": conclusion,
- "type": "TUTORIAL",
- "licence": self.licence.pk,
- },
+ {"title": title, "type": "TUTORIAL"},
follow=False,
)
self.assertEqual(result.status_code, 302)
self.assertEqual(PublishableContent.objects.all().count(), 2)
tuto = PublishableContent.objects.last()
- pk = tuto.pk
- slug = tuto.slug
- versioned = tuto.load_version()
-
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())
- # access to tutorial
- result = self.client.get(reverse("content:edit", args=[pk, slug]), follow=False)
- self.assertEqual(result.status_code, 200)
-
- # preview tutorial
- result = self.client.post(
- reverse("content:edit", args=[pk, slug]),
- {"text": random_with_md, "last_hash": versioned.compute_hash(), "preview": ""},
- HTTP_X_REQUESTED_WITH="XMLHttpRequest",
- )
-
- self.assertEqual(result.status_code, 200)
-
- result_string = "".join(a.decode() for a in result.streaming_content)
- self.assertIn("markdown", result_string, "We need the text to be properly formatted")
+ def test_basic_tutorial_workflow(self):
+ """General test on the basic workflow of a tutorial: edition, deletion for the author"""
+ self.client.force_login(self.user_author)
- result = self.client.post(
- reverse("content:edit", args=[pk, slug]),
- {
- "introduction": random,
- "conclusion": random,
- "type": "TUTORIAL",
- "subcategory": self.subcategory.pk,
- "last_hash": versioned.compute_hash(),
- },
- follow=False,
- )
- self.assertEqual(result.status_code, 302)
+ # create tutorial
+ intro = "une intro"
+ conclusion = "une conclusion"
+ description = "une description"
+ title = "un titre"
+ random = "un truc à la rien à voir"
+ random_with_md = "un text contenant du **markdown** ."
- tuto = PublishableContent.objects.get(pk=pk)
- self.assertEqual(tuto.licence, None)
- versioned = tuto.load_version()
- self.assertEqual(versioned.get_introduction(), random)
- self.assertEqual(versioned.get_conclusion(), random)
- self.assertEqual(versioned.licence, None)
+ tuto = PublishableContent.objects.last()
+ pk = tuto.pk
+ slug = tuto.slug
# preview container
result = self.client.post(