Exemplo n.º 1
0
 def testModifyLinks(self):
     self._createDummies()
     avatar_links.init_links(self._avatar1, client=self._redis, assumeEvents=True)
     self.assertEqual(avatar_links.get_links(self._avatar1, client=self._redis),
                      OrderedDict([('2', set(['conference_participant'])),
                                   ('1', set(['conference_participant'])),
                                   ('4', set(['conference_manager', 'conference_participant'])),
                                   ('3', set(['conference_manager']))]))
     # Add a new role for an existing event
     avatar_links.add_link(self._avatar1, self._event1, 'conference_manager', client=self._redis)
     self.assertEqual(avatar_links.get_links(self._avatar1, client=self._redis),
                      OrderedDict([('2', set(['conference_participant'])),
                                   ('1', set(['conference_manager', 'conference_participant'])),
                                   ('4', set(['conference_manager', 'conference_participant'])),
                                   ('3', set(['conference_manager']))]))
     # Delete a role from an event with multiple roles
     avatar_links.del_link(self._avatar1, self._event1, 'conference_participant', client=self._redis)
     self.assertEqual(avatar_links.get_links(self._avatar1, client=self._redis),
                      OrderedDict([('2', set(['conference_participant'])),
                                   ('1', set(['conference_manager'])),
                                   ('4', set(['conference_manager', 'conference_participant'])),
                                   ('3', set(['conference_manager']))]))
     # Delete a role from an event with just one role
     avatar_links.del_link(self._avatar1, self._event1, 'conference_manager', client=self._redis)
     self.assertEqual(avatar_links.get_links(self._avatar1, client=self._redis),
                      OrderedDict([('2', set(['conference_participant'])),
                                   ('4', set(['conference_manager', 'conference_participant'])),
                                   ('3', set(['conference_manager']))]))
     # Add a role for a new event
     avatar_links.add_link(self._avatar1, self._event1, 'conference_manager', client=self._redis)
     self.assertEqual(avatar_links.get_links(self._avatar1, client=self._redis),
                      OrderedDict([('2', set(['conference_participant'])),
                                   ('1', set(['conference_manager'])),
                                   ('4', set(['conference_manager', 'conference_participant'])),
                                   ('3', set(['conference_manager']))]))
Exemplo n.º 2
0
 def testModifyLinks(self):
     self._createDummies()
     avatar_links.init_links(self._avatar1, client=self._redis, assumeEvents=True)
     self.assertEqual(avatar_links.get_links(self._avatar1, client=self._redis),
                      OrderedDict([('2', set(['conference_participant'])),
                                   ('1', set(['conference_participant'])),
                                   ('4', set(['conference_manager', 'conference_participant'])),
                                   ('3', set(['conference_manager']))]))
     # Add a new role for an existing event
     avatar_links.add_link(self._avatar1, self._event1, 'conference_manager', client=self._redis)
     self.assertEqual(avatar_links.get_links(self._avatar1, client=self._redis),
                      OrderedDict([('2', set(['conference_participant'])),
                                   ('1', set(['conference_manager', 'conference_participant'])),
                                   ('4', set(['conference_manager', 'conference_participant'])),
                                   ('3', set(['conference_manager']))]))
     # Delete a role from an event with multiple roles
     avatar_links.del_link(self._avatar1, self._event1, 'conference_participant', client=self._redis)
     self.assertEqual(avatar_links.get_links(self._avatar1, client=self._redis),
                      OrderedDict([('2', set(['conference_participant'])),
                                   ('1', set(['conference_manager'])),
                                   ('4', set(['conference_manager', 'conference_participant'])),
                                   ('3', set(['conference_manager']))]))
     # Delete a role from an event with just one role
     avatar_links.del_link(self._avatar1, self._event1, 'conference_manager', client=self._redis)
     self.assertEqual(avatar_links.get_links(self._avatar1, client=self._redis),
                      OrderedDict([('2', set(['conference_participant'])),
                                   ('4', set(['conference_manager', 'conference_participant'])),
                                   ('3', set(['conference_manager']))]))
     # Add a role for a new event
     avatar_links.add_link(self._avatar1, self._event1, 'conference_manager', client=self._redis)
     self.assertEqual(avatar_links.get_links(self._avatar1, client=self._redis),
                      OrderedDict([('2', set(['conference_participant'])),
                                   ('1', set(['conference_manager'])),
                                   ('4', set(['conference_manager', 'conference_participant'])),
                                   ('3', set(['conference_manager']))]))
Exemplo n.º 3
0
    def testLinkModificationsOnlyAffectCorrectAvatar(self):
        self._createDummies()
        avatar_links.init_links(self._avatar1,
                                client=self._redis,
                                assumeEvents=True)
        avatar_links.init_links(self._avatar2,
                                client=self._redis,
                                assumeEvents=True)

        # No change may touch other avatars
        links = avatar_links.get_links(self._avatar2, client=self._redis)
        avatar_links.add_link(self._avatar1,
                              self._event1,
                              'foo',
                              client=self._redis)
        self.assertEqual(
            links, avatar_links.get_links(self._avatar2, client=self._redis))
        avatar_links.del_link(self._avatar1,
                              self._event4,
                              'conference_manager',
                              client=self._redis)
        self.assertEqual(
            links, avatar_links.get_links(self._avatar2, client=self._redis))
        avatar_links.del_link(self._avatar1,
                              self._event4,
                              'conference_participant',
                              client=self._redis)
        self.assertEqual(
            links, avatar_links.get_links(self._avatar2, client=self._redis))
        avatar_links.delete_avatar(self._avatar1, client=self._redis)
        self.assertEqual(
            links, avatar_links.get_links(self._avatar2, client=self._redis))
Exemplo n.º 4
0
Arquivo: legacy.py Projeto: fph/indico
 def linkTo(self, obj, role):
     if not self.user or self.user.is_deleted:
         return
     link = self.user.link_to(obj, role)
     if link and redis_write_client:
         event = avatar_links.event_from_obj(obj)
         if event:
             avatar_links.add_link(self.user, event, '{}_{}'.format(link.type, link.role))
Exemplo n.º 5
0
 def linkTo(self, obj, role):
     if not self.user or self.user.is_deleted:
         return
     link = self.user.link_to(obj, role)
     if link and redis_write_client:
         event = avatar_links.event_from_obj(obj)
         if event:
             avatar_links.add_link(self.user, event, '{}_{}'.format(link.type, link.role))
Exemplo n.º 6
0
    def linkTo(self, obj, role):
        # deleted users shouldn't be able to be linked
        # TODO: log deleted users?

        if not self.user.is_deleted:
            link = self.user.link_to(obj, role)
            if link and redis_write_client:
                event = avatar_links.event_from_obj(obj)
                if event:
                    avatar_links.add_link(self, event, '{}_{}'.format(link.type, link.role))
Exemplo n.º 7
0
    def linkTo(self, obj, role):
        # deleted users shouldn't be able to be linked
        # TODO: log deleted users?

        if not self.user.is_deleted:
            link = self.user.link_to(obj, role)
            if link and redis_write_client:
                event = avatar_links.event_from_obj(obj)
                if event:
                    avatar_links.add_link(self, event,
                                          '{}_{}'.format(link.type, link.role))
Exemplo n.º 8
0
    def testLinkModificationsOnlyAffectCorrectAvatar(self):
        self._createDummies()
        avatar_links.init_links(self._avatar1, client=self._redis, assumeEvents=True)
        avatar_links.init_links(self._avatar2, client=self._redis, assumeEvents=True)

        # No change may touch other avatars
        links = avatar_links.get_links(self._avatar2, client=self._redis)
        avatar_links.add_link(self._avatar1, self._event1, 'foo', client=self._redis)
        self.assertEqual(links, avatar_links.get_links(self._avatar2, client=self._redis))
        avatar_links.del_link(self._avatar1, self._event4, 'conference_manager', client=self._redis)
        self.assertEqual(links, avatar_links.get_links(self._avatar2, client=self._redis))
        avatar_links.del_link(self._avatar1, self._event4, 'conference_participant', client=self._redis)
        self.assertEqual(links, avatar_links.get_links(self._avatar2, client=self._redis))
        avatar_links.delete_avatar(self._avatar1, client=self._redis)
        self.assertEqual(links, avatar_links.get_links(self._avatar2, client=self._redis))