Пример #1
0
    def test_adds_bugzilla_comment_and_normandy_slug_when_becomes_ship(self):
        experiment = ExperimentFactory.create_with_status(
            target_status=Experiment.STATUS_REVIEW,
            type=Experiment.TYPE_PREF,
            name="Experiment Name",
            slug="experiment-slug",
            firefox_min_version="57.0",
            firefox_max_version="",
            firefox_channel=Experiment.CHANNEL_NIGHTLY,
            bugzilla_id="12345",
        )
        self.assertEqual(experiment.normandy_slug, None)

        form = ExperimentStatusForm(
            request=self.request,
            data={"status": experiment.STATUS_SHIP},
            instance=experiment,
        )

        self.assertTrue(form.is_valid())
        experiment = form.save()

        self.assertEqual(experiment.normandy_slug,
                         "bug-12345-pref-experiment-name-nightly-57")
        self.mock_tasks_update_experiment_bug.delay.assert_called_with(
            self.user.id, experiment.id)
Пример #2
0
 def test_form_rejects_invalid_state_transitions(self):
     experiment = ExperimentFactory.create_with_status(Experiment.STATUS_DRAFT)
     form = ExperimentStatusForm(
         request=self.request,
         data={"status": experiment.STATUS_LIVE},
         instance=experiment,
     )
     self.assertFalse(form.is_valid())
Пример #3
0
 def form_valid(self, form):
     response = super().form_valid(form)
     status_form = ExperimentStatusForm(
         request=self.request,
         data={"status": Experiment.STATUS_ACCEPTED},
         instance=self.object,
     )
     status_form.save()
     return response
Пример #4
0
 def test_sets_bugzilla_id_when_draft_becomes_review(self):
     experiment = ExperimentFactory.create_with_status(
         Experiment.STATUS_DRAFT)
     form = ExperimentStatusForm(
         request=self.request,
         data={"status": experiment.STATUS_REVIEW},
         instance=experiment,
     )
     self.assertTrue(form.is_valid())
     experiment = form.save()
     self.assertEqual(experiment.bugzilla_id, self.bugzilla_id)
Пример #5
0
 def test_sends_review_mail_when_draft_becomes_review(self):
     experiment = ExperimentFactory.create_with_status(
         Experiment.STATUS_DRAFT)
     form = ExperimentStatusForm(
         request=self.request,
         data={"status": experiment.STATUS_REVIEW},
         instance=experiment,
     )
     self.assertTrue(form.is_valid())
     form.save()
     self.mock_send_mail.assert_called()
Пример #6
0
 def test_sets_bugzilla_id_when_draft_becomes_review(self):
     experiment = ExperimentFactory.create_with_status(
         Experiment.STATUS_DRAFT, bugzilla_id=None)
     form = ExperimentStatusForm(
         request=self.request,
         data={"status": experiment.STATUS_REVIEW},
         instance=experiment,
     )
     self.assertTrue(form.is_valid())
     experiment = form.save()
     self.mock_tasks_create_bug.delay.assert_called_with(
         self.user.id, experiment.id)
Пример #7
0
 def test_form_allows_valid_state_transition_and_creates_changelog(self):
     experiment = ExperimentFactory.create_with_status(Experiment.STATUS_DRAFT)
     form = ExperimentStatusForm(
         request=self.request,
         data={"status": experiment.STATUS_REVIEW},
         instance=experiment,
     )
     self.assertTrue(form.is_valid())
     experiment = form.save()
     self.assertEqual(experiment.status, experiment.STATUS_REVIEW)
     change = experiment.changes.latest()
     self.assertEqual(change.old_status, experiment.STATUS_DRAFT)
     self.assertEqual(change.new_status, experiment.STATUS_REVIEW)
Пример #8
0
 def test_adds_bugzilla_comment_when_review_becomes_ship(self):
     experiment = ExperimentFactory.create_with_status(
         Experiment.STATUS_REVIEW, bugzilla_id="12345"
     )
     form = ExperimentStatusForm(
         request=self.request,
         data={"status": experiment.STATUS_SHIP},
         instance=experiment,
     )
     self.assertTrue(form.is_valid())
     experiment = form.save()
     self.mock_tasks_add_comment.delay.assert_called_with(
         self.user.id, experiment.id
     )
Пример #9
0
 def test_adds_bugzilla_comment_when_review_becomes_ready_to_ship(self):
     experiment = ExperimentFactory.create_with_status(
         Experiment.STATUS_REVIEW, bugzilla_id="123")
     form = ExperimentStatusForm(
         request=self.request,
         data={"status": experiment.STATUS_SHIP},
         instance=experiment,
     )
     self.assertTrue(form.is_valid())
     experiment = form.save()
     self.mock_bugzilla_requests_post.assert_called_with(
         settings.BUGZILLA_COMMENT_URL.format(id=experiment.bugzilla_id),
         {"comment": format_bug_body(experiment)},
     )