def test_create_bugzilla_ticket_creation_for_rapid_experiments(self): experiment = ExperimentFactory.create(type=Experiment.TYPE_RAPID, name="An Experiment") self.mock_bugzilla_requests_get.side_effect = [ self.buildMockSuccessUserResponse(), self.buildMockSuccessResponse(), ] response_data = create_experiment_bug(experiment) self.assertEqual(response_data, self.bugzilla_id) expected_call_data = { "product": "Shield", "component": "Shield Study", "version": "unspecified", "type": "task", "summary": "[Experiment]: {experiment}".format(experiment=experiment), "description": experiment.BUGZILLA_RAPID_EXPERIMENT_TEMPLATE, "assigned_to": experiment.owner.email, } self.mock_bugzilla_requests_post.assert_called_with( settings.BUGZILLA_CREATE_URL, expected_call_data)
def test_create_bugzilla_ticket_creation_with_blocks_bad_val(self): experiment = ExperimentFactory.create_with_status( Experiment.STATUS_DRAFT, name="An Experiment" ) self.mock_bugzilla_requests_get.side_effect = [ self.buildMockSuccessUserResponse(), self.buildMockFailureResponse(), self.buildMockSuccessResponse(), ] response_data = create_experiment_bug(experiment) self.assertEqual(response_data, self.bugzilla_id) expected_call_data = { "product": "Shield", "component": "Shield Study", "version": "unspecified", "summary": "[Experiment]: {experiment}".format(experiment=experiment), "description": experiment.BUGZILLA_OVERVIEW_TEMPLATE.format( experiment=experiment ), "assigned_to": experiment.owner.email, "cc": settings.BUGZILLA_CC_LIST, "type": "task", "priority": "P3", "url": experiment.experiment_url, "blocks": None, } self.mock_bugzilla_requests_post.assert_called_with( settings.BUGZILLA_CREATE_URL, expected_call_data )
def create_experiment_bug_task(user_id, experiment_id): metrics.incr("create_experiment_bug.started") experiment = Experiment.objects.get(id=experiment_id) logger.info("Creating Bugzilla ticket") try: bugzilla_id = bugzilla.create_experiment_bug(experiment) logger.info("Bugzilla ticket created") experiment.bugzilla_id = bugzilla_id experiment.save() Notification.objects.create( user_id=user_id, message=NOTIFICATION_MESSAGE_CREATE_BUG.format( bug_url=experiment.bugzilla_url), ) metrics.incr("create_experiment_bug.completed") logger.info("Bugzilla ticket notification sent") except bugzilla.BugzillaError as e: metrics.incr("create_experiment_bug.failed") logger.info("Bugzilla ticket creation failed") Notification.objects.create( user_id=user_id, message=NOTIFICATION_MESSAGE_CREATE_BUG_FAILED) logger.info("Bugzilla ticket notification sent") raise e
def test_creating_pref_bugzilla_ticket_returns_ticket_id(self): experiment = ExperimentFactory.create_with_status( Experiment.STATUS_DRAFT, name="An Experiment", firefox_min_version="56.0", firefox_max_version="57.0", ) response_data = create_experiment_bug(experiment) self.assertEqual(response_data, self.bugzilla_id) self.mock_bugzilla_requests_post.assert_called_with( settings.BUGZILLA_CREATE_URL, { "product": "Shield", "component": "Shield Study", "version": "unspecified", "summary": "[Experiment]: {experiment}".format(experiment=experiment), "description": experiment.BUGZILLA_OVERVIEW_TEMPLATE.format( experiment=experiment ), "cc": settings.BUGZILLA_CC_LIST, "type": "task", "priority": "P3", "assigned_to": experiment.owner.email, "blocks": [12345], "url": experiment.experiment_url, }, )