Ejemplo n.º 1
0
 def test_jsonfield(self):
     action.send(self.user, verb='said', text='foobar', tags=['sayings'],
                 more_data={'pk': self.user.pk})
     newaction = Action.objects.filter(verb_id=get_verb_id('said'))[0]
     self.assertEqual(newaction.data['text'], 'foobar')
     self.assertEqual(newaction.data['tags'], ['sayings'])
     self.assertEqual(newaction.data['more_data'], {'pk': self.user.pk})
Ejemplo n.º 2
0
 def test_user_stream_with_kwargs(self):
     """
     Testing the user method of the ActionManager by passing additional
     filters in kwargs
     """
     self.assertEqual(map(unicode, Action.objects.user(self.user1, verb_id=get_verb_id('joined'))), 
             [u'Two joined CoolGroup 0 minutes ago']
             )
Ejemplo n.º 3
0
 def test_model_actions_with_kwargs(self):
     """
     Testing the model_actions method of the ActionManager
     by passing kwargs
     """
     self.assertEqual(map(unicode, model_stream(self.user1, verb_id=get_verb_id('commented on'))), [
             u'admin commented on CoolGroup 0 minutes ago',
             ])
Ejemplo n.º 4
0
    def test_action_object(self):
        action.send(self.user1, verb='created comment',
            action_object=self.comment, target=self.group)
        created_action = Action.objects.get(verb_id=get_verb_id('created comment'))

        self.assertEqual(created_action.actor, self.user1)
        self.assertEqual(created_action.action_object, self.comment)
        self.assertEqual(created_action.target, self.group)
        self.assertEqual(unicode(created_action),
            u'admin created comment admin: Sweet Group!... on CoolGroup 0 '
                'minutes ago')
Ejemplo n.º 5
0
 def setUp(self):
     self.user_ct = ContentType.objects.get_for_model(User)
     self.group_ct = ContentType.objects.get_for_model(Group)
     self.group, _ = Group.objects.get_or_create(name='CoolGroup')
     self.user1, _ = User.objects.get_or_create(username='******')
     self.user2, _ = User.objects.get_or_create(username='******')
     self.user3, _ = User.objects.get_or_create(username='******')
     self.user4, _ = User.objects.get_or_create(username='******')
     Action.objects.get_or_create(
         actor_content_type=self.user_ct,
         actor_object_id=self.user1.id,
         verb_id=get_verb_id('followed'),
         target_content_type=self.user_ct,
         target_object_id=self.user2.id
     )
     Action.objects.get_or_create(
         actor_content_type=self.user_ct,
         actor_object_id=self.user1.id,
         verb_id=get_verb_id('followed'),
         target_content_type=self.user_ct,
         target_object_id=self.user3.id
     )
     Action.objects.get_or_create(
         actor_content_type=self.user_ct,
         actor_object_id=self.user1.id,
         verb_id=get_verb_id('followed'),
         target_content_type=self.user_ct,
         target_object_id=self.user4.id
     )
     Action.objects.get_or_create(
         actor_content_type=self.user_ct,
         actor_object_id=self.user1.id,
         verb_id=get_verb_id('followed'),
         target_content_type=self.group_ct,
         target_object_id=self.group.id
     )
Ejemplo n.º 6
0
 def testbar(self, verb):
     return self.filter(verb_id=get_verb_id(verb))
Ejemplo n.º 7
0
 def fset(self, value):
     verb_id = get_verb_id(value)