예제 #1
0
파일: admin.py 프로젝트: sylvestre/indico
    def _run(self, args):
        avatar = Avatar()

        name = raw_input("New administrator name: ").strip()
        surname = raw_input("New administrator surname: ").strip()
        organization = raw_input("New administrator organization: ").strip()
        email = raw_input("New administrator email: ").strip()
        login = raw_input("New administrator login: "******"New administrator password: "******"Retype administrator password: "******"Sorry, passwords do not match")

        avatar.setName(name)
        avatar.setSurName(surname)
        avatar.setOrganisation(organization)
        avatar.setLang("en_GB")
        avatar.setEmail(email)

        self.printUserInfo(avatar)

        if console.yesno(
                "Are you sure to create and grant administrator privileges to this user?"
        ):
            avatar.activateAccount()
            loginInfo = LoginInfo(login, password)
            authMgr = AuthenticatorMgr()
            userid = authMgr.createIdentity(loginInfo, avatar, "Local")
            authMgr.add(userid)
            adminList = info.HelperMaKaCInfo.getMaKaCInfoInstance(
            ).getAdminList()
            AvatarHolder().add(avatar)
            adminList.grant(avatar)
            print "New administrator created successfully with id: %s" % avatar.getId(
            )
예제 #2
0
파일: admin.py 프로젝트: ferhatelmas/indico
    def _run(self, args):
        avatar = Avatar()

        name = raw_input("New administrator name: ").strip()
        surname = raw_input("New administrator surname: ").strip()
        organization = raw_input("New administrator organization: ").strip()
        email = raw_input("New administrator email: ").strip()
        login = raw_input("New administrator login: "******"New administrator password: "******"Retype administrator password: "******"Sorry, passwords do not match")

        avatar.setName(name)
        avatar.setSurName(surname)
        avatar.setOrganisation(organization)
        avatar.setLang("en_GB")
        avatar.setEmail(email)

        self.printUserInfo(avatar)

        if console.yesno("Are you sure to create and grant administrator privileges to this user?"):
            avatar.activateAccount()
            loginInfo = LoginInfo(login, password)
            authMgr = AuthenticatorMgr()
            userid = authMgr.createIdentity(loginInfo, avatar, "Local")
            authMgr.add(userid)
            adminList = info.HelperMaKaCInfo.getMaKaCInfoInstance().getAdminList()
            AvatarHolder().add(avatar)
            adminList.grant(avatar)
            print "New administrator created successfully with id: %s" % avatar.getId()
예제 #3
0
def user_create(grant_admin):
    """Creates new user"""
    avatar = Avatar()
    user_type = 'user' if not grant_admin else 'admin'

    print()
    name = prompt("First name")
    surname = prompt("Last name")
    organization = prompt("Affiliation")
    print()
    login = prompt("Enter username")
    email = prompt_email().encode('utf-8')
    if email is None:
        return
    password = prompt_pass().encode('utf-8')
    if password is None:
        return

    avatar.setName(name)
    avatar.setSurName(surname)
    avatar.setOrganisation(organization)
    avatar.setLang("en_GB")
    avatar.setEmail(email)
    print_user_info(avatar)

    if prompt_bool(cformat("%{yellow}Create the new {}?").format(user_type), default=True):
        from MaKaC.authentication import AuthenticatorMgr
        avatar.activateAccount()
        login_info = LoginInfo(login, password)
        auth_mgr = AuthenticatorMgr()
        try:
            user_id = auth_mgr.createIdentity(login_info, avatar, "Local")
            auth_mgr.add(user_id)
            AvatarHolder().add(avatar)
            if grant_admin:
                admin_list = HelperMaKaCInfo.getMaKaCInfoInstance().getAdminList()
                admin_list.grant(avatar)
            success("New {} created successfully with ID: {}".format(user_type, avatar.getId()))
        except UserError as e:
            error("Error: {}".format(str(e)))
예제 #4
0
class TestTasks(IndicoTestCase):
    """ Tests outlook plugin tasks operations
    """

    _requires = ['db.Database', 'db.DummyUser']

    def setUp(self):
        super(TestTasks, self).setUp()
        self._startDBReq()

        PluginsHolder().updateAllPluginInfo()
        PluginsHolder().getPluginType('calendaring').setActive(True)
        PluginsHolder().getPluginType('calendaring').getPlugin('outlook').setActive(True)

        # Create two dummy users
        ah = AvatarHolder()
        self._avatar1 = Avatar()
        self._avatar1.setName("fake-1")
        self._avatar1.setSurName("fake1")
        self._avatar1.setOrganisation("fake1")
        self._avatar1.setEmail("*****@*****.**")
        ah.add(self._avatar1)
        self._avatar2 = Avatar()
        self._avatar2.setName("fake-2")
        self._avatar2.setSurName("fake2")
        self._avatar2.setOrganisation("fake2")
        self._avatar2.setEmail("*****@*****.**")
        ah.add(self._avatar2)

        # Create two dummy conferences
        category = conf.CategoryManager().getById('0')
        ch = ConferenceHolder()

        self._conf1 = category.newConference(self._avatar1)
        self._conf1.setTimezone('UTC')
        sd1 = datetime(2012, 12, 1, 10, 0, tzinfo=timezone('UTC'))
        ed1 = datetime(2012, 12, 1, 18, 0, tzinfo=timezone('UTC'))
        self._conf1.setDates(sd1, ed1)
        ch.add(self._conf1)

        self._conf2 = category.newConference(self._avatar2)
        self._conf2.setTimezone('UTC')
        sd2 = datetime(2012, 12, 10, 11, 0, tzinfo=timezone('UTC'))
        ed2 = datetime(2012, 12, 11, 13, 0, tzinfo=timezone('UTC'))
        self._conf2.setDates(sd2, ed2)
        ch.add(self._conf2)

        self._stopDBReq()

    def tearDown( self ):
        super(TestTasks, self).tearDown()
        ContextManager.destroy()

    @with_context('database')
    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)
예제 #5
0
class TestStorage(IndicoTestCase):
    """ Tests plugin storage management
    """

    _requires = ['db.Database', 'db.DummyUser']

    def setUp(self):
        super(TestStorage, self).setUp()
        self._startDBReq()

        PluginsHolder().updateAllPluginInfo()
        PluginsHolder().getPluginType('calendaring').setActive(True)
        PluginsHolder().getPluginType('calendaring').getPlugin('outlook').setActive(True)

        # Create two dummy users
        ah = AvatarHolder()
        self._avatar1 = Avatar()
        self._avatar1.setName("fake-3")
        self._avatar1.setSurName("fake3")
        self._avatar1.setOrganisation("fake3")
        self._avatar1.setEmail("*****@*****.**")
        ah.add(self._avatar1)
        self._avatar2 = Avatar()
        self._avatar2.setName("fake-4")
        self._avatar2.setSurName("fake4")
        self._avatar2.setOrganisation("fake4")
        self._avatar2.setEmail("*****@*****.**")
        ah.add(self._avatar2)

        # Create two dummy conferences
        category = conf.CategoryManager().getById('0')
        ch = ConferenceHolder()

        self._conf1 = category.newConference(self._avatar1)
        self._conf1.setTimezone('UTC')
        sd1 = datetime(2020, 12, 1, 10, 0, tzinfo=timezone('UTC'))
        ed1 = datetime(2020, 12, 1, 18, 0, tzinfo=timezone('UTC'))
        self._conf1.setDates(sd1, ed1)
        ch.add(self._conf1)

        self._conf2 = category.newConference(self._avatar2)
        self._conf2.setTimezone('UTC')
        sd2 = datetime(2020, 12, 10, 11, 0, tzinfo=timezone('UTC'))
        ed2 = datetime(2020, 12, 11, 13, 0, tzinfo=timezone('UTC'))
        self._conf2.setDates(sd2, ed2)
        ch.add(self._conf2)

        self._stopDBReq()

    @with_context('database')
    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)

    @with_context('database')
    def testUpdateConference(self):
        """ Tests if update works properly after making changes in the conference
        """
        storage = getAvatarConferenceStorage()

        participant1 = Participant(self._conf1, self._avatar1)
        participant2 = Participant(self._conf1, self._avatar2)
        participant3 = Participant(self._conf2, self._avatar2)

        self._conf1.getParticipation().addParticipant(participant1)
        self._conf1.getParticipation().addParticipant(participant2)
        self._conf2.getParticipation().addParticipant(participant3)

        self._conf1.setTitle('title')
        self.assertEqual(len(storage), 3)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(len(storage[self._avatar2.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(len(storage[self._avatar2.getId() + '_' + self._conf2.getId()]), 1)

        self._conf1.setDescription('description')
        self.assertEqual(len(storage), 3)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(len(storage[self._avatar2.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(len(storage[self._avatar2.getId() + '_' + self._conf2.getId()]), 1)

        self._conf2.setTitle('title')
        self.assertEqual(len(storage), 3)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(len(storage[self._avatar2.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(len(storage[self._avatar2.getId() + '_' + self._conf2.getId()]), 2)

    @with_context('database')
    def testUpdateParticipantStatus(self):
        """ Tests if update of participant status works properly
        """
        storage = getAvatarConferenceStorage()

        participant1 = Participant(self._conf1, self._avatar1)
        self._conf1.getParticipation().addParticipant(participant1)
        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")

        participant1.setStatusAdded()
        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")

        participant1.setStatusRefused()
        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")

        participant2 = Participant(self._conf1, self._avatar2)
        participant2.setStatusInvited()
        self.assertEqual(len(storage), 1)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)

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

        participant3 = Participant(self._conf2, self._avatar1)
        participant3.setStatusInvited()
        self.assertEqual(len(storage), 2)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(len(storage[self._avatar2.getId() + '_' + self._conf1.getId()]), 1)

        participant3.setStatusRejected()
        self.assertEqual(len(storage), 3)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(len(storage[self._avatar2.getId() + '_' + self._conf1.getId()]), 1)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf2.getId()]), 1)
        self.assertEqual(storage[self._avatar1.getId() + '_' + self._conf2.getId()][0]["eventType"], "removed")

    @with_context('database')
    def testUpdateRegistrantStatus(self):
        """ Tests if update of registrant status works properly
        """
        storage = getAvatarConferenceStorage()

        registrant1 = Registrant()
        registrant1.setAvatar(self._avatar1)
        registrant1.setEmail("*****@*****.**")
        self._conf1.addRegistrant(registrant1, self._avatar1)
        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")

        registrant2 = Registrant()
        registrant2.setAvatar(self._avatar2)
        registrant2.setEmail("*****@*****.**")
        self._conf1.addRegistrant(registrant2, self._avatar2)
        self.assertEqual(len(storage), 2)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 1)
        self.assertEqual(len(storage[self._avatar2.getId() + '_' + self._conf1.getId()]), 1)
        self.assertEqual(storage[self._avatar2.getId() + '_' + self._conf1.getId()][0]["eventType"], "added")

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

        self._conf1.removeRegistrant(registrant1.getId())
        self.assertEqual(len(storage), 2)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(len(storage[self._avatar2.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(storage[self._avatar1.getId() + '_' + self._conf1.getId()][1]["eventType"], "removed")
예제 #6
0
class TestTasks(IndicoTestCase):
    """ Tests outlook plugin tasks operations
    """

    _requires = ['db.Database', 'db.DummyUser']

    def setUp(self):
        super(TestTasks, self).setUp()
        self._startDBReq()

        PluginsHolder().updateAllPluginInfo()
        PluginsHolder().getPluginType('calendaring').setActive(True)
        PluginsHolder().getPluginType('calendaring').getPlugin(
            'outlook').setActive(True)

        # Create two dummy users
        ah = AvatarHolder()
        self._avatar1 = Avatar()
        self._avatar1.setName("fake-1")
        self._avatar1.setSurName("fake1")
        self._avatar1.setOrganisation("fake1")
        self._avatar1.setEmail("*****@*****.**")
        ah.add(self._avatar1)
        self._avatar2 = Avatar()
        self._avatar2.setName("fake-2")
        self._avatar2.setSurName("fake2")
        self._avatar2.setOrganisation("fake2")
        self._avatar2.setEmail("*****@*****.**")
        ah.add(self._avatar2)

        # Create two dummy conferences
        category = conf.CategoryManager().getById('0')
        ch = ConferenceHolder()

        self._conf1 = category.newConference(self._avatar1)
        self._conf1.setTimezone('UTC')
        sd1 = datetime(2012, 12, 1, 10, 0, tzinfo=timezone('UTC'))
        ed1 = datetime(2012, 12, 1, 18, 0, tzinfo=timezone('UTC'))
        self._conf1.setDates(sd1, ed1)
        ch.add(self._conf1)

        self._conf2 = category.newConference(self._avatar2)
        self._conf2.setTimezone('UTC')
        sd2 = datetime(2012, 12, 10, 11, 0, tzinfo=timezone('UTC'))
        ed2 = datetime(2012, 12, 11, 13, 0, tzinfo=timezone('UTC'))
        self._conf2.setDates(sd2, ed2)
        ch.add(self._conf2)

        self._stopDBReq()

    def tearDown(self):
        super(TestTasks, self).tearDown()
        ContextManager.destroy()

    @with_context('database')
    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)
예제 #7
0
class TestStorage(IndicoTestCase):
    """ Tests plugin storage management
    """

    _requires = ['db.Database', 'db.DummyUser']

    def setUp(self):
        super(TestStorage, self).setUp()
        self._startDBReq()

        PluginsHolder().updateAllPluginInfo()
        PluginsHolder().getPluginType('calendaring').setActive(True)
        PluginsHolder().getPluginType('calendaring').getPlugin(
            'outlook').setActive(True)

        # Create two dummy users
        ah = AvatarHolder()
        self._avatar1 = Avatar()
        self._avatar1.setName("fake-3")
        self._avatar1.setSurName("fake3")
        self._avatar1.setOrganisation("fake3")
        self._avatar1.setEmail("*****@*****.**")
        ah.add(self._avatar1)
        self._avatar2 = Avatar()
        self._avatar2.setName("fake-4")
        self._avatar2.setSurName("fake4")
        self._avatar2.setOrganisation("fake4")
        self._avatar2.setEmail("*****@*****.**")
        ah.add(self._avatar2)

        # Create two dummy conferences
        category = conf.CategoryManager().getById('0')
        ch = ConferenceHolder()

        self._conf1 = category.newConference(self._avatar1)
        self._conf1.setTimezone('UTC')
        sd1 = datetime(2020, 12, 1, 10, 0, tzinfo=timezone('UTC'))
        ed1 = datetime(2020, 12, 1, 18, 0, tzinfo=timezone('UTC'))
        self._conf1.setDates(sd1, ed1)
        ch.add(self._conf1)

        self._conf2 = category.newConference(self._avatar2)
        self._conf2.setTimezone('UTC')
        sd2 = datetime(2020, 12, 10, 11, 0, tzinfo=timezone('UTC'))
        ed2 = datetime(2020, 12, 11, 13, 0, tzinfo=timezone('UTC'))
        self._conf2.setDates(sd2, ed2)
        ch.add(self._conf2)

        self._stopDBReq()

    @with_context('database')
    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)

    @with_context('database')
    def testUpdateConference(self):
        """ Tests if update works properly after making changes in the conference
        """
        storage = getAvatarConferenceStorage()

        participant1 = Participant(self._conf1, self._avatar1)
        participant2 = Participant(self._conf1, self._avatar2)
        participant3 = Participant(self._conf2, self._avatar2)

        self._conf1.getParticipation().addParticipant(participant1)
        self._conf1.getParticipation().addParticipant(participant2)
        self._conf2.getParticipation().addParticipant(participant3)

        self._conf1.setTitle('title')
        self.assertEqual(len(storage), 3)
        self.assertEqual(
            len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(
            len(storage[self._avatar2.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(
            len(storage[self._avatar2.getId() + '_' + self._conf2.getId()]), 1)

        self._conf1.setDescription('description')
        self.assertEqual(len(storage), 3)
        self.assertEqual(
            len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(
            len(storage[self._avatar2.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(
            len(storage[self._avatar2.getId() + '_' + self._conf2.getId()]), 1)

        self._conf2.setTitle('title')
        self.assertEqual(len(storage), 3)
        self.assertEqual(
            len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(
            len(storage[self._avatar2.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(
            len(storage[self._avatar2.getId() + '_' + self._conf2.getId()]), 2)

    @with_context('database')
    def testUpdateParticipantStatus(self):
        """ Tests if update of participant status works properly
        """
        storage = getAvatarConferenceStorage()

        participant1 = Participant(self._conf1, self._avatar1)
        self._conf1.getParticipation().addParticipant(participant1)
        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")

        participant1.setStatusAdded()
        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")

        participant1.setStatusRefused()
        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")

        participant2 = Participant(self._conf1, self._avatar2)
        participant2.setStatusInvited()
        self.assertEqual(len(storage), 1)
        self.assertEqual(
            len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)

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

        participant3 = Participant(self._conf2, self._avatar1)
        participant3.setStatusInvited()
        self.assertEqual(len(storage), 2)
        self.assertEqual(
            len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(
            len(storage[self._avatar2.getId() + '_' + self._conf1.getId()]), 1)

        participant3.setStatusRejected()
        self.assertEqual(len(storage), 3)
        self.assertEqual(
            len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(
            len(storage[self._avatar2.getId() + '_' + self._conf1.getId()]), 1)
        self.assertEqual(
            len(storage[self._avatar1.getId() + '_' + self._conf2.getId()]), 1)
        self.assertEqual(
            storage[self._avatar1.getId() + '_' +
                    self._conf2.getId()][0]["eventType"], "removed")

    @with_context('database')
    def testUpdateRegistrantStatus(self):
        """ Tests if update of registrant status works properly
        """
        storage = getAvatarConferenceStorage()

        registrant1 = Registrant()
        registrant1.setAvatar(self._avatar1)
        registrant1.setEmail("*****@*****.**")
        self._conf1.addRegistrant(registrant1, self._avatar1)
        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")

        registrant2 = Registrant()
        registrant2.setAvatar(self._avatar2)
        registrant2.setEmail("*****@*****.**")
        self._conf1.addRegistrant(registrant2, self._avatar2)
        self.assertEqual(len(storage), 2)
        self.assertEqual(
            len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 1)
        self.assertEqual(
            len(storage[self._avatar2.getId() + '_' + self._conf1.getId()]), 1)
        self.assertEqual(
            storage[self._avatar2.getId() + '_' +
                    self._conf1.getId()][0]["eventType"], "added")

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

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