def test_json_with_subportals(self): t = self.t manage_addNySite(self.portal.info, id='subsite', title='subsite', lang='en') self.req.form = {'node': 'info'} res = json.loads(self.portal.getNavigationSiteMap(self.req, subportals=True)) self.assertEqual(len(res), 5) self.assertEqual(t(res[0]), 'info/accessibility') self.assertEqual(t(res[1]), 'info/cookie_policy') self.assertEqual(t(res[2]), 'info/contact') self.assertEqual(t(res[3]), 'info/sub_approved') self.assertEqual(t(res[4]), 'info/subsite') self.assertEqual(len(res[4]['children']), 1) self.assertEqual(t(res[4]['children'][0]), 'info/subsite/info') self.assertEqual(t(res[4]['children'][0]['children'][0]), 'info/subsite/info/accessibility') self.assertEqual(len(res[4]['children'][0]['children']), 3) self.req.form = {'node': 'info/subsite'} res = json.loads(self.portal.getNavigationSiteMap(self.req, only_folders=True, subportals=True)) self.assertEqual(len(res), 1) self.assertEqual(t(res[0]), 'info/subsite/info')
def afterSetUp(self): """ add a Naaya portal and create a Naaya Folder """ self.root = app #get Zope ROOT #create a default user in the users folder self.root.acl_users.userFolderAddUser("admin", "admin", ["Manager"], []) user = self.root.acl_users.getUserById('admin').__of__( self.root.acl_users) newSecurityManager(None, user) #add REQUEST variabiles self.root.REQUEST.AUTHENTICATED_USER = self.root.acl_users.getUser( 'admin') #add Naaya portal and patch the Localizer manage_addNySite(self.root, id='naaya-test', title='Naaya test site', default_content=True) self.portal = self.root._getOb('naaya-test') fixupTranslationServices(self.root, self.portal) #create NyFolder addNyFolder(self.portal, title='test_folder', id='folder_test', lang='en')
def test_getUsersRoles(self): acl_users = self.portal.acl_users acl_users._doAddUser('user1', 'user1', ['Contributor'], '', 'User name', 'User other name', '*****@*****.**') manage_addNySite(self.portal, id='subsite', title='subsite', lang='en') acl_users.manage_addUsersRoles('user1', roles=['Administrator'], location='info') acl_users.manage_addUsersRoles('user1', roles=['Manager'], location='subsite/info') users_roles = acl_users.getUsersRoles() self.assertTrue('user1' in users_roles) user1_roles = users_roles['user1'] self.assertTrue((['Contributor'], '') in user1_roles) self.assertTrue((['Administrator'], 'info') in user1_roles) self.assertTrue((['Manager'], 'subsite/info') in user1_roles)
def create_portal(self): #add a portal in ZODB try: print '\tCreating the portal object in ZODB...\n' self.root.manage_addProperty('management_page_charset', 'utf-8', 'string') add_error = manage_addNySite(self.root, id='portal', lang='en') except Exception, error: #failed to add the portal self.exit_script('\tFailed to add the portal object in ZODB: %s.\n' % str(error))
def portal_fixture(app): from Products.Naaya.NySite import manage_addNySite manage_addNySite(app, "portal", "Naaya Test Site") portal = app.portal portal.mail_address_from = "*****@*****.**" portal.administrator_email = "*****@*****.**" acl_users = portal.acl_users acl_users._doAddUser("test_user_1_", "secret", ["Manager"], "", "", "", "") acl_users._doAddUser( "contributor", "contributor", ["Contributor"], "", "Contributor", "Test", "*****@*****.**" ) acl_users._doAddUser("reviewer", "reviewer", ["Reviewer"], "", "Reviewer", "Test", "*****@*****.**") acl_users._doAddUser("user1", "user1", ["Contributor"], "", "User", "One", "*****@*****.**") acl_users._doAddUser("user2", "user2", ["Contributor"], "", "User", "Two", "*****@*****.**") acl_users._doAddUser("user3", "user3", ["Contributor"], "", "User", "Three", "*****@*****.**")
def portal_fixture(app): from Products.Naaya.NySite import manage_addNySite manage_addNySite(app, 'portal', 'Naaya Test Site') portal = app.portal portal.mail_address_from = '*****@*****.**' portal.administrator_email = '*****@*****.**' acl_users = portal.acl_users acl_users._doAddUser('test_user_1_', 'secret', ['Manager'], '', '', '', '') acl_users._doAddUser('contributor', 'contributor', ['Contributor'], '', 'Contributor', 'Test', '*****@*****.**') acl_users._doAddUser('reviewer', 'reviewer', ['Reviewer'], '', 'Reviewer', 'Test', '*****@*****.**') acl_users._doAddUser('user1', 'user1', ['Contributor'], '', 'User', 'One', '*****@*****.**') acl_users._doAddUser('user2', 'user2', ['Contributor'], '', 'User', 'Two', '*****@*****.**') acl_users._doAddUser('user3', 'user3', ['Contributor'], '', 'User', 'Three', '*****@*****.**')
def addPortal(self, portal_id): manage_addNySite(self.app, portal_id)
def portal_fixture(self, app): """ Create and return a portal""" from Products.Naaya.NySite import manage_addNySite portal_id = 'portal' manage_addNySite(app, portal_id, 'Naaya Test Site') return portal_id
def addPortal(self): from Products.Naaya.NySite import manage_addNySite manage_addNySite(self.app, 'portal', 'Naaya Test Site') self.portal = getattr(self.app, 'portal') self.portal.mail_address_from = '*****@*****.**'
def setUp(self): super(NaayaTestCase, self).setUp() manage_addNySite(self.portal.info, id='subsite', title='subsite', lang='en')
def addPortal(self): from Products.Naaya.NySite import manage_addNySite manage_addNySite(self.app, "portal", "Naaya Test Site") self.portal = getattr(self.app, "portal") self.portal.mail_address_from = "*****@*****.**"