コード例 #1
0
 def test_nudge_is_user_global_limit_blocked_respecting_global_limit(
         self, user, conversation: Conversation):
     """
     Should return False if user post many comments disrespecting the
     nudge global limits
     """
     conversation.comment_nudge_global_limit = 2
     create_valid_comment(conversation, user)
     assert not is_user_nudge_global_limit_blocked(conversation, user)
コード例 #2
0
    def test_nudge_status_should_return_global_blocked(
            self, user, conversation: Conversation):
        """
        Should return global blocked post the global limit of comments
        """
        conversation.comment_nudge_global_limit = 1
        create_valid_comment(conversation, user)
        nudge_status = conversation.get_status(user)

        assert nudge_status == Conversation.NUDGE.global_blocked
コード例 #3
0
 def test_nudge_status_should_return_eager(self, user,
                                           conversation: Conversation):
     """
     Should return eager if user is respecting nudge limits but post too
     many comments in a short time
     """
     conversation.comment_nudge_global_limit = 5
     conversation.comment_nudge = 4
     conversation.comment_nudge_interval = 2
     create_valid_comments(3, conversation, user)
     nudge_status = conversation.get_status(user)
     assert nudge_status == Conversation.NUDGE.eager
コード例 #4
0
 def test_nudge_status_should_return_normal(self, user,
                                            conversation: Conversation):
     """
     Should return normal if user is respecting nudge limits and post
     moderately
     """
     conversation.comment_nudge_global_limit = 5
     conversation.comment_nudge = 4
     conversation.comment_nudge_interval = 4
     create_valid_comment(conversation, user)
     nudge_status = conversation.get_status(user)
     assert nudge_status == Conversation.NUDGE.normal
コード例 #5
0
    def test_nudge_status_should_return_interval_blocked(
            self, user, conversation: Conversation):
        """
        Should return interval blocked if user isn't respecting nudge limits
        posting too many comments in a short time
        """
        conversation.comment_nudge_global_limit = 5
        conversation.comment_nudge = 2
        conversation.comment_nudge_interval = 10
        create_valid_comments(2, conversation, user)
        nudge_status = conversation.get_status(user)

        assert nudge_status == Conversation.NUDGE.interval_blocked