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( )
def setUp(self): super(TestAuthentication, self).setUp() with self._context("database"): # Create few users and groups gh = GroupHolder() ah = AvatarHolder() self._authMgr = AuthenticatorMgr() for i in xrange(1, 3): group = Group() group.setName("fake-group-%d" % i) group.setDescription("fake") group.setEmail("*****@*****.**" % i) group.setId("fake-group-%d" % i) avatar = Avatar() avatar.setName("fake-%d" % i) avatar.setSurName("fake") avatar.setOrganisation("fake") avatar.setLang("en_GB") avatar.setEmail("*****@*****.**" % i) avatar.setId("fake-%d" % i) avatar.activateAccount() group.addMember(avatar) ah.add(avatar) gh.add(group) identity = self._authMgr.createIdentity(LoginInfo("fake-%d" % i, "fake-%d" % i), avatar, "Local") self._authMgr.add(identity)
def setUp(self): super(TestAuthentication, self).setUp() with self._context("database"): # Create few users and groups gh = GroupHolder() ah = AvatarHolder() self._authMgr = AuthenticatorMgr() for i in xrange(1, 3): group = Group() group.setName("fake-group-%d" % i) group.setDescription("fake") group.setEmail("*****@*****.**" % i) group.setId("fake-group-%d" % i) avatar = Avatar() avatar.setName("fake-%d" % i) avatar.setSurName("fake") avatar.setOrganisation("fake") avatar.setLang("en_GB") avatar.setEmail("*****@*****.**" % i) avatar.setId("fake-%d" % i) avatar.activateAccount() group.addMember(avatar) ah.add(avatar) gh.add(group) identity = self._authMgr.createIdentity( LoginInfo("fake-%d" % i, "fake-%d" % i), avatar, "Local") self._authMgr.add(identity)
def create_dummy_user(): """ Creates a dummy user for testing purposes """ avatar = Avatar() avatar.setName("fake") avatar.setSurName("fake") avatar.setOrganisation("fake") avatar.setLang("en_GB") avatar.setEmail("*****@*****.**") # registering user ah = AvatarHolder() ah.add(avatar) # setting up the login info li = LoginInfo("dummyuser", "dummyuser") ih = AuthenticatorMgr() userid = ih.createIdentity(li, avatar, "Local") ih.add(userid) # activate the account avatar.activateAccount() # since the DB is empty, we have to add dummy user as admin minfo = HelperMaKaCInfo.getMaKaCInfoInstance() al = minfo.getAdminList() al.grant(avatar) dc = DefaultConference() HelperMaKaCInfo.getMaKaCInfoInstance().setDefaultConference(dc) return avatar
def setUp(self): super(TestAbstractSubmission, self).setUp() self._startDBReq() # Create few users ah = AvatarHolder() # Create dummy avatars in obj._avatarN self._avatars = [] for i in xrange(1, 5): avatar = Avatar() avatar.setName("fake-%d" % i) avatar.setSurName("fake") avatar.setOrganisation("fake") avatar.setLang("en_GB") avatar.setEmail("*****@*****.**" % i) avatar.setId("fake-%d" % i) ah.add(avatar) self._avatars.append(avatar) setattr(self, '_avatar%d' % i, avatar) # Create a conference category = conference.CategoryManager().getById('0') self._conf = category.newConference(self._avatar1) self._conf.setTimezone('UTC') sd = datetime(2011, 11, 1, 10, 0, tzinfo=timezone('UTC')) ed = datetime(2011, 11, 1, 18, 0, tzinfo=timezone('UTC')) self._conf.setDates(sd, ed) ch = ConferenceHolder() ch.add(self._conf) self._stopDBReq()
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()
def setUp(self): super(TestAbstractJudgements, self).setUp() self._startDBReq() # Get dummy user and create another one ah = AvatarHolder() avatar1 = ah.getById(0) avatar2 = Avatar() avatar2.setName("fake-2") avatar2.setSurName("fake") avatar2.setOrganisation("fake") avatar2.setLang("en_GB") avatar2.setEmail("*****@*****.**") avatar2.setId("fake-2") ah.add(avatar2) setattr(self, '_avatar1', avatar1) setattr(self, '_avatar2', avatar2) # Create a conference category = conference.CategoryManager().getById('0') self._conf = category.newConference(self._avatar1) self._conf.setTimezone('UTC') sd = datetime(2011, 11, 1, 10, 0, tzinfo=timezone('UTC')) ed = datetime(2011, 11, 1, 18, 0, tzinfo=timezone('UTC')) self._conf.setDates(sd, ed) ch = ConferenceHolder() ch.add(self._conf) self._ctOral = conference.ContributionType("oral", "", self._conf) self._conf.addContribType(self._ctOral) self._track1 = self._conf.newTrack() self._track2 = self._conf.newTrack() self._track3 = self._conf.newTrack() self._abstract1 = self._conf.getAbstractMgr().newAbstract( self._avatar1) self._abstract2 = self._conf.getAbstractMgr().newAbstract( self._avatar1) self._abstract3 = self._conf.getAbstractMgr().newAbstract( self._avatar1) self._abstract4 = self._conf.getAbstractMgr().newAbstract( self._avatar1) self._abstract5 = self._conf.getAbstractMgr().newAbstract( self._avatar1) self._abstract1.setTracks([self._track1, self._track2, self._track3]) self._abstract2.setTracks([self._track1, self._track2]) self._abstract3.setTracks([self._track1]) self._abstract4.setTracks([self._track2, self._track3]) self._abstract5.setTracks([self._track3]) self._stopDBReq()
def setUp(self): super(TestAbstractJudgements, self).setUp() self._startDBReq() # Get dummy user and create another one ah = AvatarHolder() avatar1 = ah.getById(0) avatar2 = Avatar() avatar2.setName("fake-2") avatar2.setSurName("fake") avatar2.setOrganisation("fake") avatar2.setLang("en_GB") avatar2.setEmail("*****@*****.**") avatar2.setId("fake-2") ah.add(avatar2) setattr(self, '_avatar1', avatar1) setattr(self, '_avatar2', avatar2) # Create a conference category = conference.CategoryManager().getById('0') self._conf = category.newConference(self._avatar1) self._conf.setTimezone('UTC') sd = datetime(2011, 11, 1, 10, 0, tzinfo=timezone('UTC')) ed = datetime(2011, 11, 1, 18, 0, tzinfo=timezone('UTC')) self._conf.setDates(sd, ed) ch = ConferenceHolder() ch.add(self._conf) self._ctOral = conference.ContributionType("oral", "", self._conf) self._conf.addContribType(self._ctOral) self._track1 = self._conf.newTrack() self._track2 = self._conf.newTrack() self._track3 = self._conf.newTrack() self._abstract1 = self._conf.getAbstractMgr().newAbstract(self._avatar1) self._abstract2 = self._conf.getAbstractMgr().newAbstract(self._avatar1) self._abstract3 = self._conf.getAbstractMgr().newAbstract(self._avatar1) self._abstract4 = self._conf.getAbstractMgr().newAbstract(self._avatar1) self._abstract5 = self._conf.getAbstractMgr().newAbstract(self._avatar1) self._abstract1.setTracks([self._track1, self._track2, self._track3]) self._abstract2.setTracks([self._track1, self._track2]) self._abstract3.setTracks([self._track1]) self._abstract4.setTracks([self._track2, self._track3]) self._abstract5.setTracks([self._track3]) self._stopDBReq()
def create_user(name, login, authManager, set_password=False): avatar = Avatar() avatar.setName(name) avatar.setSurName(name) avatar.setOrganisation("fake") avatar.setLang("en_GB") avatar.setEmail("*****@*****.**" % name) # setting up the login info li = LoginInfo(login, login if set_password else None) userid = authManager.createIdentity(li, avatar, "Local") authManager.add(userid) # activate the account avatar.activateAccount() return avatar
def create_user(name, login, authManager): avatar = Avatar() avatar.setName(name) avatar.setSurName(name) avatar.setOrganisation("fake") avatar.setLang("en_GB") avatar.setEmail("*****@*****.**" % name) # setting up the login info li = LoginInfo(login, login) userid = authManager.createIdentity(li, avatar, "Local") authManager.add(userid) # activate the account avatar.activateAccount() return avatar
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)))
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)
class TestProtection(IndicoTestCase): _requires = ['db.Database', 'db.DummyUser'] def setUp(self): super(TestProtection, self).setUp() self._startDBReq() # Create a user ah = AvatarHolder() self._avatar = Avatar() self._avatar.setName("fake") self._avatar.setSurName("fake") self._avatar.setOrganisation("fake") self._avatar.setLang("en_GB") self._avatar.setEmail("*****@*****.**") self._avatar.setId("fake") ah.add(self._avatar) # Create a conference category = conference.CategoryManager().getById('0') self._conf = category.newConference(self._avatar) self._conf.setTimezone('UTC') sd = datetime(2011, 11, 1, 10, 0, tzinfo=timezone('UTC')) ed = datetime(2011, 11, 1, 18, 0, tzinfo=timezone('UTC')) self._conf.setDates(sd, ed) ch = ConferenceHolder() ch.add(self._conf) self._contrib1 = conference.Contribution() self._conf.addContribution(self._contrib1) self._session1 = conference.Session() self._conf.addSession(self._session1) self._session2 = conference.Session() self._conf.addSession(self._session2) self._contrib2 = conference.Contribution() self._session1.addContribution(self._contrib2) #Now we create the material (id=0) and attach it to the contrib self._material = conference.Material() self._contrib1.addMaterial( self._material ) #Now we create a dummy file and attach it to the material filePath = os.path.join( os.getcwd(), "test.txt" ) fh = open(filePath, "w") fh.write("hola") fh.close() self._resource = conference.LocalFile() self._resource.setFilePath( filePath ) self._resource.setFileName( "test.txt" ) self._material.addResource( self._resource ) self._stopDBReq() @with_context('database') def testOnlyPublic(self): self.assertEqual(self._conf.getAccessController().isFullyPublic(), True) self.assertEqual(self._contrib1.getAccessController().isFullyPublic(), True) self.assertEqual(self._contrib2.getAccessController().isFullyPublic(), True) self.assertEqual(self._session1.getAccessController().isFullyPublic(), True) self.assertEqual(self._session2.getAccessController().isFullyPublic(), True) self.assertEqual(self._material.getAccessController().isFullyPublic(), True) self.assertEqual(self._resource.getAccessController().isFullyPublic(), True) @with_context('database') def testOnlyPrivate(self): self._conf.setProtection(1) self._contrib1.setProtection(1) self._contrib2.setProtection(1) self._session1.setProtection(1) self._session2.setProtection(1) self._material.setProtection(1) self._resource.setProtection(1) self.assertEqual(self._conf.getAccessController().isFullyPrivate(), True) self.assertEqual(self._contrib1.getAccessController().isFullyPrivate(), True) self.assertEqual(self._contrib2.getAccessController().isFullyPrivate(), True) self.assertEqual(self._session1.getAccessController().isFullyPrivate(), True) self.assertEqual(self._session2.getAccessController().isFullyPrivate(), True) self.assertEqual(self._material.getAccessController().isFullyPrivate(), True) self.assertEqual(self._resource.getAccessController().isFullyPrivate(), True) @with_context('database') def testPrivateInPublic(self): self._contrib2.setProtection(1) self._session2.setProtection(1) self._resource.setProtection(1) self.assertEqual(self._session1.getAccessController().isFullyPublic(), False) self.assertEqual(self._conf.getAccessController().isFullyPublic(), False) self.assertEqual(self._session1.getAccessController().getProtectedChildren(), [self._contrib2]) self.assertEqual(self._contrib1.getAccessController().getProtectedChildren(), [self._resource]) self.assertEqual(self._material.getAccessController().getProtectedChildren(), [self._resource]) self.assertEqual(set(self._conf.getAccessController().getProtectedChildren()), set([self._contrib2, self._session2, self._resource])) self._contrib1.removeMaterial(self._material) self.assertEqual(self._contrib1.getAccessController().isFullyPublic(), True) self.assertEqual(self._material.getAccessController().getProtectedChildren(), []) self.assertEqual(set(self._conf.getAccessController().getProtectedChildren()), set([self._contrib2, self._session2])) self._conf.removeContribution(self._contrib2) self.assertEqual(self._session1.getAccessController().isFullyPublic(), True) self.assertEqual(self._session1.getAccessController().getProtectedChildren(), []) self.assertEqual(self._conf.getAccessController().getProtectedChildren(), [self._session2]) @with_context('database') def testPublicInPrivate(self): self._conf.setProtection(1) self._contrib2.setProtection(-1) self._session2.setProtection(-1) self._resource.setProtection(-1) self.assertEqual(self._session1.getAccessController().isFullyPrivate(), False) self.assertEqual(self._conf.getAccessController().isFullyPrivate(), False) self.assertEqual(self._session1.getAccessController().getPublicChildren(), [self._contrib2]) self.assertEqual(self._contrib1.getAccessController().getPublicChildren(), [self._resource]) self.assertEqual(self._material.getAccessController().getPublicChildren(), [self._resource]) self.assertEqual(set(self._conf.getAccessController().getPublicChildren()), set([self._contrib2, self._session2, self._resource])) self._contrib1.removeMaterial(self._material) self.assertEqual(self._contrib1.getAccessController().isFullyPrivate(), True) self.assertEqual(self._material.getAccessController().getPublicChildren(), []) self.assertEqual(set(self._conf.getAccessController().getPublicChildren()), set([self._contrib2, self._session2])) self._conf.removeContribution(self._contrib2) self.assertEqual(self._session1.getAccessController().isFullyPrivate(), True) self.assertEqual(self._session1.getAccessController().getPublicChildren(), []) self.assertEqual(self._conf.getAccessController().getPublicChildren(), [self._session2])
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)
def start(self, obj): super(RoomBooking_Feature, self).start(obj) with obj._context('database'): # Tell indico to use the current database for roombooking stuff minfo = HelperMaKaCInfo.getMaKaCInfoInstance() cfg = Configuration.Config.getInstance() minfo.setRoomBookingDBConnectionParams(cfg.getDBConnectionParams()) obj._ph.getById('RoomBooking').setActive(True) DALManagerCERN.connect() initializeRoomBookingDB("Universe", force=False) DALManagerCERN.disconnect() # do not use the method for it as it tries to re-create jsvars and fails minfo._roomBookingModuleActive = True DALManagerCERN.connect() # Create dummy avatars in obj._avatarN ah = AvatarHolder() obj._avatars = [] for i in xrange(1, 5): avatar = Avatar() avatar.setName("fake-%d" % i) avatar.setSurName("fake") avatar.setOrganisation("fake") avatar.setLang("en_GB") avatar.setEmail("*****@*****.**" % i) avatar.setId("rb-fake-%d" % i) # setting up the login info li = LoginInfo("fake-%d" % i, "fake-%d" % i) ih = AuthenticatorMgr() userid = ih.createIdentity(li, avatar, "Local") ih.add(userid) # activate the account avatar.activateAccount() ah.add(avatar) obj._avatars.append(avatar) setattr(obj, '_avatar%d' % i, avatar) # Create dummy rooms in obj._roomN - owners are fake1 and fake2 (r1 has f1, r2 has f2, r3 has f1, ...) location = Location.getDefaultLocation() obj._rooms = [] for i in xrange(1, 8): room = location.newRoom() room.locationName = location.friendlyName room.name = 'DummyRoom%d' % i room.site = 'a' room.building = 1 room.floor = 'b' room.roomNr = 'c' room.latitude = '' room.longitude = '' room.isActive = True room.isReservable = True room.resvsNeedConfirmation = False room.responsibleId = 'rb-fake-%d' % (((i - 1) % 2) + 1) room.whereIsKey = 'Nowhere' room.telephone = '123456789' room.capacity = 10 room.division = '' room.surfaceArea = 50 room.comments = '' room.setEquipment([]) room.setAvailableVC([]) room.insert() obj._rooms.append(room) setattr(obj, '_room%d' % i, room)
class TestProtection(IndicoTestCase): _requires = ['db.Database', 'db.DummyUser'] def setUp(self): super(TestProtection, self).setUp() self._startDBReq() # Create a user ah = AvatarHolder() self._avatar = Avatar() self._avatar.setName("fake") self._avatar.setSurName("fake") self._avatar.setOrganisation("fake") self._avatar.setLang("en_GB") self._avatar.setEmail("*****@*****.**") self._avatar.setId("fake") ah.add(self._avatar) # Create a conference category = conference.CategoryManager().getById('0') self._conf = category.newConference(self._avatar) self._conf.setTimezone('UTC') sd = datetime(2011, 11, 1, 10, 0, tzinfo=timezone('UTC')) ed = datetime(2011, 11, 1, 18, 0, tzinfo=timezone('UTC')) self._conf.setDates(sd, ed) ch = ConferenceHolder() ch.add(self._conf) self._contrib1 = conference.Contribution() self._conf.addContribution(self._contrib1) self._session1 = conference.Session() self._conf.addSession(self._session1) self._session2 = conference.Session() self._conf.addSession(self._session2) self._contrib2 = conference.Contribution() self._session1.addContribution(self._contrib2) #Now we create the material (id=0) and attach it to the contrib self._material = conference.Material() self._contrib1.addMaterial(self._material) #Now we create a dummy file and attach it to the material filePath = os.path.join(os.getcwd(), "test.txt") fh = open(filePath, "w") fh.write("hola") fh.close() self._resource = conference.LocalFile() self._resource.setFilePath(filePath) self._resource.setFileName("test.txt") self._material.addResource(self._resource) self._stopDBReq() @with_context('database') def testOnlyPublic(self): self.assertEqual(self._conf.getAccessController().isFullyPublic(), True) self.assertEqual(self._contrib1.getAccessController().isFullyPublic(), True) self.assertEqual(self._contrib2.getAccessController().isFullyPublic(), True) self.assertEqual(self._session1.getAccessController().isFullyPublic(), True) self.assertEqual(self._session2.getAccessController().isFullyPublic(), True) self.assertEqual(self._material.getAccessController().isFullyPublic(), True) self.assertEqual(self._resource.getAccessController().isFullyPublic(), True) @with_context('database') def testOnlyPrivate(self): self._conf.setProtection(1) self._contrib1.setProtection(1) self._contrib2.setProtection(1) self._session1.setProtection(1) self._session2.setProtection(1) self._material.setProtection(1) self._resource.setProtection(1) self.assertEqual(self._conf.getAccessController().isFullyPrivate(), True) self.assertEqual(self._contrib1.getAccessController().isFullyPrivate(), True) self.assertEqual(self._contrib2.getAccessController().isFullyPrivate(), True) self.assertEqual(self._session1.getAccessController().isFullyPrivate(), True) self.assertEqual(self._session2.getAccessController().isFullyPrivate(), True) self.assertEqual(self._material.getAccessController().isFullyPrivate(), True) self.assertEqual(self._resource.getAccessController().isFullyPrivate(), True) @with_context('database') def testPrivateInPublic(self): self._contrib2.setProtection(1) self._session2.setProtection(1) self._resource.setProtection(1) self.assertEqual(self._session1.getAccessController().isFullyPublic(), False) self.assertEqual(self._conf.getAccessController().isFullyPublic(), False) self.assertEqual( self._session1.getAccessController().getProtectedChildren(), [self._contrib2]) self.assertEqual( self._contrib1.getAccessController().getProtectedChildren(), [self._resource]) self.assertEqual( self._material.getAccessController().getProtectedChildren(), [self._resource]) self.assertEqual( set(self._conf.getAccessController().getProtectedChildren()), set([self._contrib2, self._session2, self._resource])) self._contrib1.removeMaterial(self._material) self.assertEqual(self._contrib1.getAccessController().isFullyPublic(), True) self.assertEqual( self._material.getAccessController().getProtectedChildren(), []) self.assertEqual( set(self._conf.getAccessController().getProtectedChildren()), set([self._contrib2, self._session2])) self._conf.removeContribution(self._contrib2) self.assertEqual(self._session1.getAccessController().isFullyPublic(), True) self.assertEqual( self._session1.getAccessController().getProtectedChildren(), []) self.assertEqual( self._conf.getAccessController().getProtectedChildren(), [self._session2]) @with_context('database') def testPublicInPrivate(self): self._conf.setProtection(1) self._contrib2.setProtection(-1) self._session2.setProtection(-1) self._resource.setProtection(-1) self.assertEqual(self._session1.getAccessController().isFullyPrivate(), False) self.assertEqual(self._conf.getAccessController().isFullyPrivate(), False) self.assertEqual( self._session1.getAccessController().getPublicChildren(), [self._contrib2]) self.assertEqual( self._contrib1.getAccessController().getPublicChildren(), [self._resource]) self.assertEqual( self._material.getAccessController().getPublicChildren(), [self._resource]) self.assertEqual( set(self._conf.getAccessController().getPublicChildren()), set([self._contrib2, self._session2, self._resource])) self._contrib1.removeMaterial(self._material) self.assertEqual(self._contrib1.getAccessController().isFullyPrivate(), True) self.assertEqual( self._material.getAccessController().getPublicChildren(), []) self.assertEqual( set(self._conf.getAccessController().getPublicChildren()), set([self._contrib2, self._session2])) self._conf.removeContribution(self._contrib2) self.assertEqual(self._session1.getAccessController().isFullyPrivate(), True) self.assertEqual( self._session1.getAccessController().getPublicChildren(), []) self.assertEqual(self._conf.getAccessController().getPublicChildren(), [self._session2])
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")
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")