Beispiel #1
0
 def setUp(self):
     mail.outbox = []
     self.user = UserFactory(email="*****@*****.**")
     decision = DecisionFactory(author=self.user)
     feedbackAuthor = UserFactory(email="*****@*****.**")
     self.feedback = FeedbackFactory(decision=decision,
                                     description="Not so fast",
                                     author=feedbackAuthor,
                                     editor=feedbackAuthor)
 def setUp(self):
     mail.outbox = []
     self.user = UserFactory(email="*****@*****.**")
     decision = DecisionFactory(author=self.user)
     feedbackAuthor = UserFactory(email="*****@*****.**")
     self.feedback = FeedbackFactory(decision=decision,
                                     description="Not so fast",
                                     author=feedbackAuthor,
                                     editor=feedbackAuthor)
     organization = decision.organization
     self.settings = NotificationSettingsFactory(
         user=self.user,
         organization=organization,
         notification_level=FEEDBACK_MAJOR_CHANGES)
     OrganizationUserFactory(user=self.user, organization=organization)
Beispiel #3
0
 def test_get_organization_returns_organization_for_feedback(self):
     expected_organization = OrganizationFactory.build(id=1)
     decision = DecisionFactory.build(id=2,
                                      organization=expected_organization)
     feedback = FeedbackFactory.build(decision=decision)
     settings_handler = ObservationManager()
     actual_organization = settings_handler._get_organization(feedback)
     self.assertEqual(expected_organization, actual_organization)
Beispiel #4
0
    def test_get_author_name(self):
        feedback = Feedback(author=None)
        self.assertEqual(feedback.get_author_name(),
                         "An Anonymous Contributor")

        user = UserFactory()
        feedback = FeedbackFactory(author=user)
        self.assertEqual(feedback.get_author_name(), user.username)
Beispiel #5
0
 def test_include_watchers_adds_watchers_for_feedback(self):
     decision = DecisionFactory.build(id=1)
     decision = add_watchers(decision)
     feedback = FeedbackFactory.build(decision=decision)
     settings_handler = ObservationManager()
     settings_handler.include_watchers(feedback)
     self.assertSetEqual(
         set([watcher.user for watcher in decision.watchers.all()]),
         settings_handler.recipient_list)
 def setUp(self):
     mail.outbox = []
     self.user = UserFactory(email="*****@*****.**")
     decision = DecisionFactory(author=self.user)
     feedbackAuthor = UserFactory(email="*****@*****.**")
     self.feedback = FeedbackFactory(decision=decision,
                                     description="Not so fast",
                                     author=feedbackAuthor,
                                     editor=feedbackAuthor)
 def test_include_watchers_adds_watchers_for_feedback(self):
     decision = DecisionFactory.build(id=1)
     decision = add_watchers(decision)
     feedback = FeedbackFactory.build(decision=decision)
     settings_handler = ObservationManager()
     settings_handler.include_watchers(feedback)
     self.assertSetEqual(
             set([watcher.user for watcher in decision.watchers.all()]),
             settings_handler.recipient_list
     )
 def test_get_organization_returns_organization_for_feedback(self):
     expected_organization = OrganizationFactory.build(id=1)
     decision = DecisionFactory.build(
         id=2,
         organization=expected_organization
     )
     feedback = FeedbackFactory.build(decision=decision)
     settings_handler = ObservationManager()
     actual_organization = settings_handler._get_organization(feedback)
     self.assertEqual(expected_organization, actual_organization)
Beispiel #9
0
 def test_get_organization_returns_organization_for_comment(self):
     expected_organization = OrganizationFactory.build(id=1)
     decision = DecisionFactory.build(id=2,
                                      organization=expected_organization)
     feedback = FeedbackFactory.build(id=2, decision=decision)
     comment = CommentFactory.build()
     comment.content_object = feedback
     settings_handler = ObservationManager()
     actual_organization = settings_handler._get_organization(comment)
     self.assertEqual(expected_organization, actual_organization)
Beispiel #10
0
 def test_include_watchers_adds_watchers_for_comments(self):
     decision = DecisionFactory.build(id=1)
     decision = add_watchers(decision)
     feedback = FeedbackFactory.build(id=2, decision=decision)
     comment = CommentFactory.build()
     comment.content_object = feedback
     settings_handler = ObservationManager()
     settings_handler.include_watchers(comment)
     self.assertSetEqual(
         set([watcher.user for watcher in decision.watchers.all()]),
         settings_handler.recipient_list)
 def test_get_organization_returns_organization_for_comment(self):
     expected_organization = OrganizationFactory.build(id=1)
     decision = DecisionFactory.build(
         id=2,
         organization=expected_organization
     )
     feedback = FeedbackFactory.build(id=2, decision=decision)
     comment = CommentFactory.build()
     comment.content_object = feedback
     settings_handler = ObservationManager()
     actual_organization = settings_handler._get_organization(comment)
     self.assertEqual(expected_organization, actual_organization)
 def test_include_watchers_adds_watchers_for_comments(self):
     decision = DecisionFactory.build(id=1)
     decision = add_watchers(decision)
     feedback = FeedbackFactory.build(id=2, decision=decision)
     comment = CommentFactory.build()
     comment.content_object = feedback
     settings_handler = ObservationManager()
     settings_handler.include_watchers(comment)
     self.assertSetEqual(
             set([watcher.user for watcher in decision.watchers.all()]),
             settings_handler.recipient_list
     )
class FeedbackNotificationTest(TestCase):
    def setUp(self):
        mail.outbox = []
        self.user = UserFactory(email="*****@*****.**")
        decision = DecisionFactory(author=self.user)
        feedbackAuthor = UserFactory(email="*****@*****.**")
        self.feedback = FeedbackFactory(decision=decision,
                                        description="Not so fast",
                                        author=feedbackAuthor,
                                        editor=feedbackAuthor)

    def test_edit_triggers_email(self):
        mail.outbox = []
        self.feedback.description = "Not so slow"
        self.feedback.save()
        self.assertGreater(len(mail.outbox), 0)

    def test_minor_edit_triggers_no_email(self):
        mail.outbox = []
        self.feedback.description = "Not too fast"
        self.feedback.minor_edit = True
        self.feedback.save()
        self.assertEqual(len(mail.outbox), 0)

    # It is an arguable point whether this logic should be in the UI
    # or the back end. However, whilst it's in the latter, we'll have a
    # test for it here.
    def test_minor_edit_by_non_author_triggers_email(self):
        mail.outbox = []
        self.feedback.description = "Not so quick"
        self.feedback.minor_edit = True
        self.feedback.editor = UserFactory(email="*****@*****.**")
        self.feedback.save()
        self.assertGreater(len(mail.outbox), 0)
Beispiel #14
0
class FeedbackNotificationTest(TestCase):
    def setUp(self):
        mail.outbox = []
        self.user = UserFactory(email="*****@*****.**")
        decision = DecisionFactory(author=self.user)
        feedbackAuthor = UserFactory(email="*****@*****.**")
        self.feedback = FeedbackFactory(decision=decision,
                                        description="Not so fast",
                                        author=feedbackAuthor,
                                        editor=feedbackAuthor)

    def test_edit_triggers_email(self):
        mail.outbox = []
        self.feedback.description = "Not so slow"
        self.feedback.save()
        self.assertGreater(len(mail.outbox), 0)

    def test_minor_edit_triggers_no_email(self):
        mail.outbox = []
        self.feedback.description = "Not too fast"
        self.feedback.minor_edit = True
        self.feedback.save()
        self.assertEqual(len(mail.outbox), 0)

    # It is an arguable point whether this logic should be in the UI
    # or the back end. However, whilst it's in the latter, we'll have a
    # test for it here.
    def test_minor_edit_by_non_author_triggers_email(self):
        mail.outbox = []
        self.feedback.description = "Not so quick"
        self.feedback.minor_edit = True
        self.feedback.editor = UserFactory(email="*****@*****.**")
        self.feedback.save()
        self.assertGreater(len(mail.outbox), 0)
Beispiel #15
0
 def test_delete_stops_users_watching_feedback_for_the_organization(self):
     org_user_delete_view = CustomOrganizationUserDelete()
     feedback = FeedbackFactory()
     observed_item = ObservedItemFactory(observed_object=feedback)
     org = observed_item.observed_object.decision.organization
     user = feedback.author
     org_user = OrganizationUserFactory(organization=org, user=user)
     org_user_delete_view.get_object = lambda: org_user
     request = RequestFactory()
     request.user = user
     org_user_delete_view.delete(request)
     # Two observed items were created for different users
     # Only the second one should remain after the delete request
     self.assertSequenceEqual([observed_item], feedback.watchers.all())
Beispiel #16
0
 def setUp(self):
     mail.outbox = []
     self.user = UserFactory(email="*****@*****.**")
     decision = DecisionFactory(author=self.user)
     feedbackAuthor = UserFactory(email="*****@*****.**")
     self.feedback = FeedbackFactory(decision=decision,
                                     description="Not so fast",
                                     author=feedbackAuthor,
                                     editor=feedbackAuthor)
     organization = decision.organization
     self.settings = NotificationSettingsFactory(
         user=self.user,
         organization=organization,
         notification_level=FEEDBACK_MAJOR_CHANGES
     )
     OrganizationUserFactory(user=self.user, organization=organization)
Beispiel #17
0
 def test_add_comment_triggers_update(self):
     feedback = FeedbackFactory(decision=self.decision, author=self.user)
     orig_last_modified = self.last_modified()
     comment = CommentFactory(content_object=feedback, user=self.user)
     self.send_comment_posted_signal(comment)
     self.assertTrue(orig_last_modified < self.last_modified())
Beispiel #18
0
 def test_add_feedback_triggers_update(self):
     orig_last_modified = self.last_modified()
     FeedbackFactory(decision=self.decision, author=self.user)
     self.assertTrue(orig_last_modified < self.last_modified())