def test_manager_returns_sections(self): experiment = ExperimentFactory.create_with_status( Experiment.STATUS_DRAFT ) risk_comment = ExperimentCommentFactory.create( experiment=experiment, section=Experiment.SECTION_RISKS ) testing_comment = ExperimentCommentFactory.create( experiment=experiment, section=Experiment.SECTION_TESTING ) self.assertIn( risk_comment, experiment.comments.sections[experiment.SECTION_RISKS], ) self.assertIn( testing_comment, experiment.comments.sections[experiment.SECTION_TESTING], ) self.assertNotIn( risk_comment, experiment.comments.sections[experiment.SECTION_TESTING], ) self.assertNotIn( testing_comment, experiment.comments.sections[experiment.SECTION_RISKS], )
def test_send_experiment_comment_email(self): experiment = ExperimentFactory.create( name="exp1", type=ExperimentConstants.TYPE_PREF) user = UserFactory.create(email="*****@*****.**") comment = ExperimentCommentFactory.create(experiment=experiment, created_by=user) send_experiment_comment_email(comment) sent_email = mail.outbox[-1] expected_subject = ( "[Experimenter]: [email protected] commented on Pref-Flip Experiment: exp1" ) self.assertEqual(sent_email.subject, expected_subject) self.assertEqual(sent_email.content_subtype, "html") self.assertTrue( experiment.emails.filter( type=ExperimentConstants.EXPERIMENT_COMMENT).exists())