def test_end_event_reason_returns_experiment_complete(self):
     event = ReportLogConstants.Event.END
     end_log = NimbusChangeLogFactory.create(old_status="Live",
                                             new_status="Complete",
                                             message=None)
     reason = get_event_reason(end_log, event)
     self.assertEqual(str(reason), "Experiment Complete")
 def test_get_event_reason_returns_new(self):
     event = ReportLogConstants.Event.CREATE
     experiment = ExperimentFactory.create_with_status(
         target_status=Experiment.STATUS_DRAFT)
     create_log = experiment.changes.first()
     reason = get_event_reason(create_log, event)
     self.assertEqual(str(reason), "New")
 def test_get_update_event_reason_returns_status_change(self):
     event = ReportLogConstants.Event.UPDATE
     changelog = NimbusChangeLogFactory.create(old_status="Draft",
                                               new_status="Preview")
     event_reason = get_event_reason(changelog, event)
     self.assertEqual(event_reason,
                      ReportLogConstants.EventReason.STATUS_CHANGE)
 def test_get_update_event_reason_returns_launch(self):
     event = ReportLogConstants.Event.UPDATE
     changelog = ExperimentChangeLogFactory.create(
         old_status=Experiment.STATUS_ACCEPTED,
         new_status=Experiment.STATUS_LIVE)
     event_reason = get_event_reason(changelog, event)
     self.assertEqual(event_reason, ReportLogConstants.EventReason.LAUNCH)
 def test_get_end_event_reason_returns_message_as_reason(self):
     event = ReportLogConstants.Event.END
     message = "Enrollment Issue"
     end_log = ExperimentChangeLogFactory.create(old_status="Live",
                                                 new_status="Complete",
                                                 message=message)
     reason = get_event_reason(end_log, event)
     self.assertEqual(reason, message)
 def test_get_create_event_reason_returns_clone(self):
     parent = ExperimentFactory.create()
     experiment = ExperimentFactory.create(parent=parent)
     event = ReportLogConstants.Event.CREATE
     create_log = ExperimentChangeLogFactory.create(
         message="Cloned Experiment", experiment=experiment)
     reason = get_event_reason(create_log, event)
     self.assertEqual(str(reason), "Clone")
 def test_get_update_event_reason_returns_pause(self):
     event = ReportLogConstants.Event.UPDATE
     changelog = ExperimentChangeLogFactory.create(
         old_status=Experiment.STATUS_LIVE,
         new_status=Experiment.STATUS_LIVE,
         message="Enrollment Complete",
     )
     event_reason = get_event_reason(changelog, event)
     self.assertEqual(event_reason, ReportLogConstants.EventReason.PAUSE)
 def test_get_update_event_reason_returns_recipe_change(self):
     event = ReportLogConstants.Event.UPDATE
     changelog = ExperimentChangeLogFactory.create(
         old_status=Experiment.STATUS_LIVE,
         new_status=Experiment.STATUS_LIVE,
         message="Added Version(s)",
     )
     event_reason = get_event_reason(changelog, event)
     self.assertEqual(event_reason,
                      ReportLogConstants.EventReason.RECIPE_CHANGE)