def update_bug_resolution_task(user_id, experiment_id): metrics.incr("update_bug_resolution.started") experiment = Experiment.objects.get(id=experiment_id) if experiment.status == experiment.STATUS_COMPLETE or experiment.bugzilla_id is None: logger.info( "Skipping update either experiment complete or no bugzilla ticket") return logger.info("Updating Bugzilla Resolution") try: bugzilla.update_bug_resolution(experiment) logger.info("Bugzilla resolution updated") Notification.objects.create( user_id=user_id, message=NOTIFICATION_MESSAGE_ARCHIVE_COMMENT.format( bug_url=experiment.bugzilla_url), ) metrics.incr("update_bug_resolution.completed") logger.info("Bugzilla resolution update sent") except bugzilla.BugzillaError as e: metrics.incr("update_bug_resolution.failed") logger.info("Failed to update resolution of bugzilla ticket") Notification.objects.create( user_id=user_id, message=NOTIFICATION_MESSAGE_ARCHIVE_ERROR_MESSAGE.format( bug_url=experiment.bugzilla_url), ) raise e
def test_bugzilla_resolution_with_completed_status(self): experiment = ExperimentFactory.create_with_status(Experiment.STATUS_COMPLETE) update_bug_resolution(experiment) self.mock_bugzilla_requests_put.assert_called_with( settings.BUGZILLA_UPDATE_URL.format(id=experiment.bugzilla_id), {"status": "RESOLVED", "resolution": "FIXED"}, )
def comp_experiment_update_res_task(experiment_id): experiment = Experiment.objects.get(id=experiment_id) metrics.incr("comp_experiment_update_res_task.started") logger.info("Updating Bugzilla Resolution") try: bugzilla.update_bug_resolution(experiment) logger.info("Bugzilla Resolution Updated") metrics.incr("comp_experiment_update_res_task.completed") except bugzilla.BugzillaError as e: metrics.incr("comp_experiment_update_res_task.failed") logger.info("update bug resolution failed") raise e
def test_bugzilla_resolution_with_archive_true(self): experiment = ExperimentFactory.create_with_status( Experiment.STATUS_DRAFT, name="An Experiment", bugzilla_id="123", type=Experiment.TYPE_PREF, archived=True, ) update_bug_resolution(experiment) self.mock_bugzilla_requests_put.assert_called_with( settings.BUGZILLA_UPDATE_URL.format(id=experiment.bugzilla_id), {"status": "RESOLVED", "resolution": "WONTFIX"}, )