Ejemplo n.º 1
0
    def testOutlookRunTask(self):
        """ Tests outlook notification scheduler task.
            Using mock to avoid running real POST requests.
        """

        mockReturn = []

        def mock_sendEventRequest(self, key, eventType, avatar, conference):
            if avatar.getName() == 'fake-2' and conference.getId() == '0':
                mockReturn.append(200)
                return 200
            if avatar.getName() == 'fake-2' and conference.getId(
            ) == '1' and eventType == "added":
                mockReturn.append(200)
                return 200
            mockReturn.append(None)
            return None

        OutlookUpdateCalendarNotificationTask._sendEventRequest = mock_sendEventRequest
        outlookTask = OutlookUpdateCalendarNotificationTask(MINUTELY)

        storage = getAvatarConferenceStorage()

        addAvatarConference(self._avatar1, self._conf1, "added")
        addAvatarConference(self._avatar1, self._conf1, "removed")
        addAvatarConference(self._avatar2, self._conf2, "added")
        outlookTask.run()
        self.assertEqual(mockReturn, [None, 200])
        self.assertEqual(len(storage), 1)
        self.assertEqual(
            len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)
        mockReturn = []

        addAvatarConference(self._avatar1, self._conf2, "added")
        addAvatarConference(self._avatar1, self._conf2, "removed")
        outlookTask.run()
        self.assertEqual(mockReturn, [None])
        self.assertEqual(len(storage), 2)
        self.assertEqual(
            len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(
            len(storage[self._avatar1.getId() + '_' + self._conf2.getId()]), 2)
        mockReturn = []

        outlookTask._clearAvatarConferenceStorage(
            [self._avatar1.getId() + '_' + self._conf2.getId()])
        outlookTask._clearAvatarConferenceStorage(
            [self._avatar1.getId() + '_' + self._conf1.getId()])
        self.assertEqual(len(storage), 0)
Ejemplo n.º 2
0
    def testOutlookRunTask(self):
        """ Tests outlook notification scheduler task.
            Using mock to avoid running real POST requests.
        """

        mockReturn = []

        def mock_sendEventRequest(self, key, eventType, avatar, conference):
            if avatar.getName() == 'fake-2' and conference.getId() == '0':
                mockReturn.append(200)
                return 200
            if avatar.getName() == 'fake-2' and conference.getId() == '1' and eventType == "added":
                mockReturn.append(200)
                return 200
            mockReturn.append(None)
            return None

        OutlookUpdateCalendarNotificationTask._sendEventRequest = mock_sendEventRequest
        outlookTask = OutlookUpdateCalendarNotificationTask(MINUTELY)

        storage = getAvatarConferenceStorage()

        addAvatarConference(self._avatar1, self._conf1, "added")
        addAvatarConference(self._avatar1, self._conf1, "removed")
        addAvatarConference(self._avatar2, self._conf2, "added")
        outlookTask.run()
        self.assertEqual(mockReturn, [None, 200])
        self.assertEqual(len(storage), 1)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)
        mockReturn = []

        addAvatarConference(self._avatar1, self._conf2, "added")
        addAvatarConference(self._avatar1, self._conf2, "removed")
        outlookTask.run()
        self.assertEqual(mockReturn, [None])
        self.assertEqual(len(storage), 2)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf2.getId()]), 2)
        mockReturn = []

        outlookTask._clearAvatarConferenceStorage([self._avatar1.getId() + '_' + self._conf2.getId()])
        outlookTask._clearAvatarConferenceStorage([self._avatar1.getId() + '_' + self._conf1.getId()])
        self.assertEqual(len(storage), 0)
Ejemplo n.º 3
0
 def participantRemoved(self, obj, conference, avatar):
     addAvatarConference(avatar, conference, 'removed')
Ejemplo n.º 4
0
 def participantAdded(self, obj, conference, avatar):
     addAvatarConference(avatar, conference, 'added')
Ejemplo n.º 5
0
 def registrantRemoved(self, conference, avatar):
     addAvatarConference(avatar, conference, 'removed')
Ejemplo n.º 6
0
 def registrantAdded(self, conference, avatar):
     addAvatarConference(avatar, conference, 'added')
Ejemplo n.º 7
0
 def participantRemoved(self, obj, conference, avatar):
     addAvatarConference(avatar, conference, 'removed')
Ejemplo n.º 8
0
 def participantAdded(self, obj, conference, avatar):
     addAvatarConference(avatar, conference, 'added')
Ejemplo n.º 9
0
 def registrantRemoved(self, conference, avatar):
     addAvatarConference(avatar, conference, 'removed')
Ejemplo n.º 10
0
 def registrantAdded(self, conference, avatar):
     addAvatarConference(avatar, conference, 'added')
Ejemplo n.º 11
0
    def testAddStorageElements(self):
        """ Tests adding elements to the storage
        """
        storage = getAvatarConferenceStorage()
        self.assertEqual(len(storage), 0)

        addAvatarConference(self._avatar1, self._conf1, "added")
        self.assertEqual(len(storage), 1)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 1)
        self.assertEqual(storage[self._avatar1.getId() + '_' + self._conf1.getId()][0]["eventType"], "added")

        addAvatarConference(self._avatar1, self._conf1, "removed")
        self.assertEqual(len(storage), 1)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(storage[self._avatar1.getId() + '_' + self._conf1.getId()][1]["eventType"], "removed")

        addAvatarConference(self._avatar1, self._conf2, "added")
        self.assertEqual(len(storage), 2)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf2.getId()]), 1)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(storage[self._avatar1.getId() + '_' + self._conf2.getId()][0]["eventType"], "added")

        addAvatarConference(self._avatar2, self._conf1, "added")
        self.assertEqual(len(storage), 3)
        self.assertEqual(len(storage[self._avatar2.getId() + '_' + self._conf1.getId()]), 1)
        self.assertEqual(storage[self._avatar2.getId() + '_' + self._conf1.getId()][0]["eventType"], "added")

        addAvatarConference(self._avatar2, self._conf2, "added")
        self.assertEqual(len(storage), 4)
        self.assertEqual(len(storage[self._avatar2.getId() + '_' + self._conf2.getId()]), 1)
        self.assertEqual(storage[self._avatar2.getId() + '_' + self._conf2.getId()][0]["eventType"], "added")

        addAvatarConference(self._avatar2, self._conf2, "removed")
        self.assertEqual(len(storage), 4)
        self.assertEqual(len(storage[self._avatar2.getId() + '_' + self._conf2.getId()]), 2)
        self.assertEqual(storage[self._avatar2.getId() + '_' + self._conf2.getId()][1]["eventType"], "removed")

        addAvatarConference(self._avatar1, self._conf1, "added")
        addAvatarConference(self._avatar1, self._conf1, "removed")

        self.assertEqual(len(storage), 4)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)
Ejemplo n.º 12
0
    def testAddStorageElements(self):
        """ Tests adding elements to the storage
        """
        storage = getAvatarConferenceStorage()
        self.assertEqual(len(storage), 0)

        addAvatarConference(self._avatar1, self._conf1, "added")
        self.assertEqual(len(storage), 1)
        self.assertEqual(
            len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 1)
        self.assertEqual(
            storage[self._avatar1.getId() + '_' +
                    self._conf1.getId()][0]["eventType"], "added")

        addAvatarConference(self._avatar1, self._conf1, "removed")
        self.assertEqual(len(storage), 1)
        self.assertEqual(
            len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(
            storage[self._avatar1.getId() + '_' +
                    self._conf1.getId()][1]["eventType"], "removed")

        addAvatarConference(self._avatar1, self._conf2, "added")
        self.assertEqual(len(storage), 2)
        self.assertEqual(
            len(storage[self._avatar1.getId() + '_' + self._conf2.getId()]), 1)
        self.assertEqual(
            len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(
            storage[self._avatar1.getId() + '_' +
                    self._conf2.getId()][0]["eventType"], "added")

        addAvatarConference(self._avatar2, self._conf1, "added")
        self.assertEqual(len(storage), 3)
        self.assertEqual(
            len(storage[self._avatar2.getId() + '_' + self._conf1.getId()]), 1)
        self.assertEqual(
            storage[self._avatar2.getId() + '_' +
                    self._conf1.getId()][0]["eventType"], "added")

        addAvatarConference(self._avatar2, self._conf2, "added")
        self.assertEqual(len(storage), 4)
        self.assertEqual(
            len(storage[self._avatar2.getId() + '_' + self._conf2.getId()]), 1)
        self.assertEqual(
            storage[self._avatar2.getId() + '_' +
                    self._conf2.getId()][0]["eventType"], "added")

        addAvatarConference(self._avatar2, self._conf2, "removed")
        self.assertEqual(len(storage), 4)
        self.assertEqual(
            len(storage[self._avatar2.getId() + '_' + self._conf2.getId()]), 2)
        self.assertEqual(
            storage[self._avatar2.getId() + '_' +
                    self._conf2.getId()][1]["eventType"], "removed")

        addAvatarConference(self._avatar1, self._conf1, "added")
        addAvatarConference(self._avatar1, self._conf1, "removed")

        self.assertEqual(len(storage), 4)
        self.assertEqual(
            len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)