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)
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)
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)
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)
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)