Пример #1
0
    def test_downvote_send_stream(self):
        """
        Assert that 'downvote' stream signal is sent
        """
        handler = MagicMock()
        stream.connect(handler)
        vote, created = Vote.objects.punch_ballot(self.question, self.user, -1)

        # Ensure that the signal was sent once with required arguments
        handler.assert_called_once_with(verb='downvote', sender=Vote,
            actor=self.user, target=self.question, signal=stream)
Пример #2
0
    def test_downvote_send_stream(self):
        """
        Assert that 'downvote' stream signal is sent
        """
        handler = MagicMock()
        stream.connect(handler)
        vote, created = Vote.objects.punch_ballot(self.question, self.user, -1)

        # Ensure that the signal was sent once with required arguments
        handler.assert_called_once_with(verb='downvote', sender=Vote,
            actor=self.user, target=self.question, signal=stream)
Пример #3
0
    def test_question_ask_send_stream(self):
        """
        Assert that when a question is created it sends the "ask" stream signal
        """
        handler = MagicMock()
        stream.connect(handler)
        question = Question.objects.create(**fixtures['question'])

        # Ensure that the signal was sent once with required arguments
        handler.assert_called_once_with(verb='ask', sender=Question,
                    timestamp=question.created, actor=self.user,
                    target=question, signal=stream)
Пример #4
0
    def test_question_answer_send_stream(self):
        """
        Assert that when an Answer is created it sends the "answer" stream signal
        """
        handler = MagicMock()
        stream.connect(handler)
        answer  = Answer.objects.create(**fixtures['answer'])

        # Ensure that the signal was sent once with required arguments
        handler.assert_called_once_with(verb='answer', sender=Answer,
                    timestamp=answer.created, actor=self.user, target=answer,
                    signal=stream)
Пример #5
0
    def test_topic_annotation_send_stream(self):
        """
        Assert that when a TopicAnnotation is created it sends a stream signal
        """

        handler = MagicMock()
        stream.connect(handler)
        annotation = TopicAnnotation.objects.create(**fixtures['annotation'])

        # Ensure that the signal was sent once with required arguments
        handler.assert_called_once_with(verb='annotate', sender=TopicAnnotation,
                    timestamp=annotation.modified, actor=self.user,
                    target=self.question, signal=stream, theme=self.topic)
Пример #6
0
    def test_user_create_send_stream(self):
        """
        Assert that when a user is created it sends the "join" stream signal
        """
        handler = MagicMock()
        stream.connect(handler)
        user = User.objects.create_user(username='******',
                                        email='*****@*****.**',
                                        password='******')

        # Ensure that the signal was sent once with required arguments
        handler.assert_called_once_with(verb='join', sender=User, actor=user,
                                        timestamp=user.date_joined,
                                        signal=stream)
Пример #7
0
    def test_question_ask_send_stream(self):
        """
        Assert that when a question is created it sends the "ask" stream signal
        """
        handler = MagicMock()
        stream.connect(handler)
        question = Question.objects.create(**fixtures['question'])

        # Ensure that the signal was sent once with required arguments
        handler.assert_called_once_with(verb='ask',
                                        sender=Question,
                                        timestamp=question.created,
                                        actor=self.user,
                                        target=question,
                                        signal=stream)
Пример #8
0
    def test_question_answer_send_stream(self):
        """
        Assert that when an Answer is created it sends the "answer" stream signal
        """
        handler = MagicMock()
        stream.connect(handler)
        answer = Answer.objects.create(**fixtures['answer'])

        # Ensure that the signal was sent once with required arguments
        handler.assert_called_once_with(verb='answer',
                                        sender=Answer,
                                        timestamp=answer.created,
                                        actor=self.user,
                                        target=answer,
                                        signal=stream)
Пример #9
0
    def test_user_create_send_stream(self):
        """
        Assert that when a user is created it sends the "join" stream signal
        """
        handler = MagicMock()
        stream.connect(handler)
        user = User.objects.create_user(username='******',
                                        email='*****@*****.**',
                                        password='******')

        # Ensure that the signal was sent once with required arguments
        handler.assert_called_once_with(verb='join',
                                        sender=User,
                                        actor=user,
                                        timestamp=user.date_joined,
                                        signal=stream)