def test_can_review_false_for_requesting_user(self): experiment = NimbusExperimentFactory.create_with_lifecycle( NimbusExperimentFactory.Lifecycles.CREATED, ) experiment.publish_status = NimbusExperiment.PublishStatus.REVIEW experiment.save() generate_nimbus_changelog(experiment, experiment.owner, "test message") self.assertFalse(experiment.can_review(experiment.owner))
def test_launch_to_live_is_not_considered_latest_rejection(self): experiment = NimbusExperimentFactory.create_with_lifecycle( NimbusExperimentFactory.Lifecycles.LAUNCH_APPROVE_APPROVE, ) experiment.status = NimbusExperiment.Status.LIVE experiment.publish_status = NimbusExperiment.PublishStatus.IDLE experiment.save() generate_nimbus_changelog(experiment, experiment.owner, "test message") self.assertIsNone(experiment.changes.latest_rejection())
def test_can_review_false_for_non_review_publish_status(self): experiment = NimbusExperimentFactory.create_with_lifecycle( NimbusExperimentFactory.Lifecycles.CREATED, ) experiment.apply_lifecycle_state( NimbusExperimentFactory.LifecycleStates.DRAFT_REVIEW) experiment.save() generate_nimbus_changelog(experiment, experiment.owner, "test message") experiment.publish_status = NimbusExperiment.PublishStatus.IDLE experiment.save() self.assertFalse(experiment.can_review(UserFactory.create()))
def test_can_review_for_requesting_user_if_dev_user_and_setting_enabled( self, email, is_allowed): user = UserFactory.create(email=email) experiment = NimbusExperimentFactory.create_with_lifecycle( NimbusExperimentFactory.Lifecycles.CREATED, owner=user, ) experiment.apply_lifecycle_state( NimbusExperimentFactory.LifecycleStates.DRAFT_REVIEW) experiment.save() generate_nimbus_changelog(experiment, experiment.owner, "test message") self.assertEqual(experiment.can_review(user), is_allowed)
def test_can_review_true_for_non_requesting_user(self, last_publish_status): experiment = NimbusExperimentFactory.create_with_lifecycle( NimbusExperimentFactory.Lifecycles.CREATED, ) for publish_status in ( NimbusExperiment.PublishStatus.REVIEW, NimbusExperiment.PublishStatus.APPROVED, NimbusExperiment.PublishStatus.WAITING, ): experiment.publish_status = publish_status experiment.save() generate_nimbus_changelog(experiment, experiment.owner, "test message") if publish_status == last_publish_status: break self.assertTrue(experiment.can_review(UserFactory.create()))
def test_stale_timeout_not_returned(self): experiment = NimbusExperimentFactory.create_with_lifecycle( NimbusExperimentFactory.Lifecycles.CREATED, ) for publish_status in ( NimbusExperiment.PublishStatus.REVIEW, NimbusExperiment.PublishStatus.APPROVED, NimbusExperiment.PublishStatus.WAITING, NimbusExperiment.PublishStatus.REVIEW, NimbusExperiment.PublishStatus.APPROVED, ): experiment.publish_status = publish_status experiment.save() generate_nimbus_changelog(experiment, experiment.owner, "test message") self.assertIsNone(experiment.changes.latest_timeout())
def test_latest_review_request_returns_change_for_idle_to_review(self): experiment = NimbusExperimentFactory.create_with_lifecycle( NimbusExperimentFactory.Lifecycles.CREATED, ) experiment.publish_status = NimbusExperiment.PublishStatus.REVIEW experiment.save() change = generate_nimbus_changelog(experiment, experiment.owner, "test message") self.assertEqual(experiment.changes.latest_review_request(), change)
def test_timeout_changelog_for_timedout_publish_flow( self, lifecycle_start, lifecycle_waiting, lifecycle_timeout): experiment = NimbusExperimentFactory.create_with_lifecycle( lifecycle_start) # Simulate waiting for approval in remote settings experiment.apply_lifecycle_state(lifecycle_waiting.value[-1]) experiment.save() generate_nimbus_changelog(experiment, experiment.owner, "test message") # No timeout at first. self.assertIsNone(experiment.changes.latest_timeout()) # Next, simulate a timeout. experiment.apply_lifecycle_state(lifecycle_timeout.value[-1]) experiment.save() generate_nimbus_changelog(experiment, experiment.owner, "test message") # Timeout should be the latest changelog entry. self.assertEqual(experiment.changes.latest_timeout(), experiment.changes.latest_change())
def test_latest_review_request_returns_most_recent_review_request(self): reviewer = UserFactory() experiment = NimbusExperimentFactory.create_with_lifecycle( NimbusExperimentFactory.Lifecycles.CREATED, ) experiment.publish_status = NimbusExperiment.PublishStatus.REVIEW experiment.save() generate_nimbus_changelog(experiment, experiment.owner, "test message") experiment.publish_status = NimbusExperiment.PublishStatus.IDLE experiment.save() generate_nimbus_changelog(experiment, reviewer, "test message") experiment.publish_status = NimbusExperiment.PublishStatus.REVIEW experiment.save() second_request = generate_nimbus_changelog( experiment, experiment.owner, "test message" ) self.assertEqual(experiment.changes.latest_review_request(), second_request)
def test_latest_rejection_returns_rejection_for_review_to_idle(self): experiment = NimbusExperimentFactory.create_with_lifecycle( NimbusExperimentFactory.Lifecycles.CREATED, ) changes = [] for publish_status in ( NimbusExperiment.PublishStatus.REVIEW, NimbusExperiment.PublishStatus.IDLE, ): experiment.publish_status = publish_status experiment.save() changes.append( generate_nimbus_changelog(experiment, experiment.owner, "test message") ) self.assertEqual(experiment.changes.latest_review_request(), changes[0]) self.assertEqual(experiment.changes.latest_rejection(), changes[1])