def test_form_saves_objectives(self): created_experiment = ExperimentFactory.create_with_status( Experiment.STATUS_DRAFT) self.assertEqual(created_experiment.changes.count(), 1) data = { "objectives": "The objective is to experiment!", "analysis": "Lets analyze the results!", "survey_required": RADIO_YES, "survey_urls": "example.com", "survey_instructions": "Here are the launch instructions.", "total_enrolled_clients": 10000, } form = ExperimentObjectivesForm(request=self.request, data=data, instance=created_experiment) self.assertTrue(form.is_valid()) experiment = form.save() self.assertEqual(experiment.objectives, data["objectives"]) self.assertEqual(experiment.analysis, data["analysis"]) self.assertTrue(experiment.survey_required) self.assertEqual(experiment.survey_urls, data["survey_urls"]) self.assertEqual(experiment.survey_instructions, data["survey_instructions"]) self.assertEqual(experiment.total_enrolled_clients, data["total_enrolled_clients"]) self.assertEqual(experiment.changes.count(), 2)
def test_form_saves_objectives(self): created_experiment = ExperimentFactory.create_with_status( Experiment.STATUS_DRAFT) data = { "objectives": "The objective is to experiment!", "analysis_owner": "Jim Bob The Data Scientist", "analysis": "Lets analyze the results!", } form = ExperimentObjectivesForm(request=self.request, data=data, instance=created_experiment) self.assertTrue(form.is_valid()) experiment = form.save() self.assertEqual(experiment.objectives, data["objectives"]) self.assertEqual(experiment.analysis, data["analysis"])
def test_no_fields_required(self): experiment = ExperimentFactory.create() form = ExperimentObjectivesForm(request=self.request, data={}, instance=experiment) self.assertTrue(form.is_valid())