def test_with_notification_types(self):
     token = generate_token(
         self.user,
         self.group,
         notification_type=GroupNotificationType.DAILY_PICKUP_NOTIFICATION)
     data = parse_token(token)
     self.assertEqual(data['notification_type'],
                      'daily_pickup_notification')
 def test_with_a_conversation(self):
     token = generate_token(self.user,
                            self.group,
                            conversation=self.group.conversation)
     data = parse_token(token)
     self.assertEqual(self.user, data['user'])
     self.assertEqual(self.group, data['group'])
     self.assertEqual(self.group.conversation, data['conversation'])
 def test_with_a_thread(self):
     thread = self.group.conversation.messages.create(author=self.user,
                                                      content='foo')
     self.group.conversation.messages.create(author=self.user,
                                             content='foo reply',
                                             thread=thread)
     token = generate_token(self.user, self.group, thread=thread)
     data = parse_token(token)
     self.assertEqual(self.user, data['user'])
     self.assertEqual(self.group, data['group'])
     self.assertEqual(thread, data['thread'])
Example #4
0
 def validate_token(token):
     try:
         return parse_token(token)  # will throw an exception if invalid
     except BadSignature:
         raise serializers.ValidationError()