def update_experiment_bug_task(user_id, experiment_id): metrics.incr("update_experiment_bug.started") experiment = Experiment.objects.get(id=experiment_id) if experiment.risk_internal_only: logger.info("Skipping Bugzilla update for internal only experiment") return logger.info("Updating Bugzilla Ticket") try: bugzilla.update_experiment_bug(experiment) logger.info("Bugzilla Ticket updated") Notification.objects.create( user_id=user_id, message=NOTIFICATION_MESSAGE_UPDATE_BUG.format( bug_url=experiment.bugzilla_url), ) metrics.incr("update_experiment_bug.completed") logger.info("Bugzilla Update notification sent") except bugzilla.BugzillaError as e: Notification.objects.create( user_id=user_id, message=NOTIFICATION_MESSAGE_UPDATE_BUG_FAILED) metrics.incr("update_experiment_bug.failed") logger.info("Failed bugzilla update") raise e
def test_update_bugzilla_addon_experiment(self): experiment = ExperimentFactory.create_with_status( Experiment.STATUS_DRAFT, name="An Experiment", bugzilla_id="123", type=Experiment.TYPE_ADDON, firefox_min_version="56.0", firefox_max_version="", firefox_channel="Nightly", ) update_experiment_bug(experiment) summary = "[Experiment] Add-On: An Experiment Fx 56.0 Nightly" self.mock_bugzilla_requests_put.assert_called_with( settings.BUGZILLA_UPDATE_URL.format(id=experiment.bugzilla_id), {"summary": summary, "cf_user_story": format_bug_body(experiment)}, )
def test_update_bugzilla_pref_experiment(self): experiment = ExperimentFactory.create_with_status( Experiment.STATUS_DRAFT, name="An Experiment", bugzilla_id="123", type=Experiment.TYPE_PREF, firefox_min_version="55.0", firefox_max_version="56.0", firefox_channel="Beta", ) update_experiment_bug(experiment) summary = "[Experiment] Pref-Flip: An Experiment Fx 55.0 to 56.0 Beta" self.mock_bugzilla_requests_put.assert_called_with( settings.BUGZILLA_UPDATE_URL.format(id=experiment.bugzilla_id), {"summary": summary, "cf_user_story": format_bug_body(experiment)}, )