예제 #1
0
 def test_section_must_be_valid(self):
     text = "hello"
     section = "invalid section"
     experiment = ExperimentFactory.create_with_status(Experiment.STATUS_DRAFT)
     form = ExperimentCommentForm(
         request=self.request,
         data={"experiment": experiment.id, "section": section, "text": text},
     )
     self.assertFalse(form.is_valid())
     self.assertIn("section", form.errors)
예제 #2
0
 def test_text_is_required(self):
     text = ""
     section = Experiment.SECTION_OVERVIEW
     experiment = ExperimentFactory.create_with_status(Experiment.STATUS_DRAFT)
     form = ExperimentCommentForm(
         request=self.request,
         data={"experiment": experiment.id, "section": section, "text": text},
     )
     self.assertFalse(form.is_valid())
     self.assertIn("text", form.errors)
예제 #3
0
 def test_form_creates_comment(self):
     text = "hello"
     section = Experiment.SECTION_OVERVIEW
     experiment = ExperimentFactory.create_with_status(Experiment.STATUS_DRAFT)
     form = ExperimentCommentForm(
         request=self.request,
         data={"experiment": experiment.id, "section": section, "text": text},
     )
     self.assertTrue(form.is_valid())
     comment = form.save()
     self.assertEqual(comment.experiment, experiment)
     self.assertEqual(comment.section, section)
     self.assertEqual(comment.created_by, self.user)
     self.assertEqual(comment.text, text)