コード例 #1
0
    def test_move_rename(self):
        """Test move or rename"""
        adapter = CreateContentFixtures(self, self.layer)
        suffixes = WORKSPACE_GROUPS.keys()
        proj_id1 = 'proj_handler_test_move_rename'
        self.assertNotIn(proj_id1, self.portal.contentIds())
        allgroups_before = self.groups_plugin.listGroupIds()
        proj = adapter.add_project(proj_id1, title='Project 1')
        proj_uid = IUUID(proj)
        transaction.get().commit()  # necessary for rename to work below
        self.assertIn(proj_id1, self.portal.contentIds())
        allgroups_after = self.groups_plugin.listGroupIds()
        self.assertEquals(len(allgroups_after) - len(allgroups_before), 3)
        for g in ['%s-%s' % (proj_uid, suffix) for suffix in suffixes]:
            assert g in allgroups_after
        proj.setTitle('Project 1a')
        self.portal.manage_renameObject(proj_id1, proj_id1 + 'a')
        self.assertNotIn(proj_id1, self.portal.contentIds())  # old name
        self.assertIn(proj_id1 + 'a', self.portal.contentIds())  # new name
        allgroups_postrename = self.groups_plugin.listGroupIds()
        self.assertEquals(len(allgroups_postrename), len(allgroups_after))
        for suffix in suffixes:
            groupname = '%s-%s' % (proj_uid, suffix)
            assert groupname in allgroups_postrename  # new names
            title_suffix = WORKSPACE_GROUPS.get(suffix).get('title')
            title = self.groups_plugin.getGroupInfo(groupname).get('title')
            expected = 'Project 1a - %s' % title_suffix
            self.assertEquals(title, expected)

        ## now create a team workspace inside the project, similarly:
        team_id1 = 'team1'
        allgroups_before = self.groups_plugin.listGroupIds()
        team = adapter.add_workspace_to(proj, team_id1)
        team_uid = IUUID(team)
        roster = WorkspaceRoster(team)
        roster.add(TEST_USER_NAME)
        assert TEST_USER_NAME in roster
        assert len(roster) == 1
        transaction.get().commit()  # necessary for rename to work below
        allgroups_after = self.groups_plugin.listGroupIds()
        ## necessary/sufficient: all expected groups (and only these):
        self.assertEquals(len(allgroups_after) - len(allgroups_before), 3)
        for g in ['-'.join((team_uid, s)) for s in suffixes]:
            assert g in allgroups_after
        ## now rename the team
        newid = team_id1 + 'a'
        proj.manage_renameObject(team_id1, newid)
        team = proj.get(newid)
        assert IUUID(team) == team_uid  # UUID does not change
        # ensure that users are copied to groups on rename:
        roster = WorkspaceRoster(team)
        assert TEST_USER_NAME in roster
        assert len(roster) == 1
        allgroups_postrename = self.groups_plugin.listGroupIds()
        self.assertEquals(len(allgroups_postrename), len(allgroups_after))
        for g in ['-'.join((team_uid, s)) for s in suffixes]:
            assert g in allgroups_postrename  # new names
コード例 #2
0
 def test_move_rename(self):
     """Test move or rename"""
     adapter = CreateContentFixtures(self, self.layer)
     suffixes = WORKSPACE_GROUPS.keys()
     proj_id1 = 'proj_handler_test_move_rename'
     self.assertNotIn(proj_id1, self.portal.contentIds())
     allgroups_before = self.groups_plugin.listGroupIds()
     proj = adapter.add_project(proj_id1, title='Project 1')
     proj_uid = IUUID(proj)
     transaction.get().commit()   # necessary for rename to work below
     self.assertIn(proj_id1, self.portal.contentIds())
     allgroups_after = self.groups_plugin.listGroupIds()
     self.assertEquals(len(allgroups_after) - len(allgroups_before), 3)
     for g in ['%s-%s' % (proj_uid, suffix) for suffix in suffixes]:
         assert g in allgroups_after
     proj.setTitle('Project 1a')
     self.portal.manage_renameObject(proj_id1, proj_id1 + 'a')
     self.assertNotIn(proj_id1, self.portal.contentIds())     # old name
     self.assertIn(proj_id1 + 'a', self.portal.contentIds())  # new name
     allgroups_postrename = self.groups_plugin.listGroupIds()
     self.assertEquals(len(allgroups_postrename), len(allgroups_after))
     for suffix in suffixes:
         groupname = '%s-%s' % (proj_uid, suffix)
         assert groupname in allgroups_postrename        # new names
         title_suffix = WORKSPACE_GROUPS.get(suffix).get('title')
         title = self.groups_plugin.getGroupInfo(groupname).get('title')
         expected = 'Project 1a - %s' % title_suffix
         self.assertEquals(title, expected)
         
     ## now create a team workspace inside the project, similarly:
     team_id1 = 'team1'
     allgroups_before = self.groups_plugin.listGroupIds()
     team = adapter.add_workspace_to(proj, team_id1)
     team_uid = IUUID(team)
     roster = WorkspaceRoster(team)
     roster.add(TEST_USER_NAME)
     assert TEST_USER_NAME in roster
     assert len(roster) == 1
     transaction.get().commit()   # necessary for rename to work below
     allgroups_after = self.groups_plugin.listGroupIds()
     ## necessary/sufficient: all expected groups (and only these):
     self.assertEquals(len(allgroups_after) - len(allgroups_before), 3)
     for g in ['-'.join((team_uid, s)) for s in suffixes]:
         assert g in allgroups_after
     ## now rename the team
     newid = team_id1 + 'a'
     proj.manage_renameObject(team_id1, newid)
     team = proj.get(newid)
     assert IUUID(team) == team_uid  # UUID does not change
     # ensure that users are copied to groups on rename:
     roster = WorkspaceRoster(team)
     assert TEST_USER_NAME in roster
     assert len(roster) == 1
     allgroups_postrename = self.groups_plugin.listGroupIds()
     self.assertEquals(len(allgroups_postrename), len(allgroups_after))
     for g in ['-'.join((team_uid, s)) for s in suffixes]:
         assert g in allgroups_postrename        # new names
コード例 #3
0
 def setUp(self):
     self.portal = self.layer['portal']
     self.request = self.layer['request']
     self.wftool = getToolByName(self.portal, 'portal_workflow')
     setRoles(self.portal, TEST_USER_ID, ['Manager'])
     alsoProvides(self.request, ITeamworkProductLayer)
     CreateContentFixtures(self, self.layer).create()
     self.test_member = CreateContentFixtures.TEST_MEMBER
コード例 #4
0
 def setUp(self):
     self.portal = self.layer['portal']
     self.request = self.layer['request']
     setRoles(self.portal, TEST_USER_ID, ['Manager'])
     CreateContentFixtures(self, self.layer).create()
     import transaction
     transaction.get().commit()
     #login(self.portal, TEST_USER_NAME)
     self.browser = Browser(self.layer['app'])
     self.portal_url = 'http://nohost/plone'
     if not getattr(self, 'logged_in', False):
         self.login()
コード例 #5
0
 def test_create(self):
     adapter = CreateContentFixtures(self, self.layer)
     suffixes = WORKSPACE_GROUPS.keys()
     proj_id1 = 'proj_handler_test_create1'
     allgroups_before = self.groups_plugin.listGroupIds()
     proj = adapter.add_project(proj_id1)
     proj_uid = IUUID(proj)
     allgroups_after = self.groups_plugin.listGroupIds()
     ## necessary/sufficient: all expected groups (and only these):
     self.assertEquals(len(allgroups_after) - len(allgroups_before), 3)
     for g in ['%s-%s' % (proj_uid, suffix) for suffix in suffixes]:
         assert g in allgroups_after
     ## now create a team workspace inside the project, similarly:
     team_id1 = 'team1'
     allgroups_before = self.groups_plugin.listGroupIds()
     team = adapter.add_workspace_to(proj, team_id1)
     team_uid = IUUID(team)
     allgroups_after = self.groups_plugin.listGroupIds()
     ## necessary/sufficient: all expected groups (and only these):
     self.assertEquals(len(allgroups_after) - len(allgroups_before), 3)
     for g in ['-'.join((team_uid, s)) for s in suffixes]:
         assert g in allgroups_after
コード例 #6
0
 def test_create(self):
     adapter = CreateContentFixtures(self, self.layer)
     suffixes = WORKSPACE_GROUPS.keys()
     proj_id1 = 'proj_handler_test_create1'
     allgroups_before = self.groups_plugin.listGroupIds()
     proj = adapter.add_project(proj_id1)
     proj_uid = IUUID(proj)
     allgroups_after = self.groups_plugin.listGroupIds()
     ## necessary/sufficient: all expected groups (and only these):
     self.assertEquals(len(allgroups_after) - len(allgroups_before), 3)
     for g in ['%s-%s' % (proj_uid, suffix) for suffix in suffixes]:
         assert g in allgroups_after
     ## now create a team workspace inside the project, similarly:
     team_id1 = 'team1'
     allgroups_before = self.groups_plugin.listGroupIds()
     team = adapter.add_workspace_to(proj, team_id1)
     team_uid = IUUID(team)
     allgroups_after = self.groups_plugin.listGroupIds()
     ## necessary/sufficient: all expected groups (and only these):
     self.assertEquals(len(allgroups_after) - len(allgroups_before), 3)
     for g in ['-'.join((team_uid, s)) for s in suffixes]:
         assert g in allgroups_after
コード例 #7
0
 def test_remove(self):
     """test removal of project and team, make sure no orphan groups"""
     adapter = CreateContentFixtures(self, self.layer)
     suffixes = WORKSPACE_GROUPS.keys()
     proj_id1 = 'proj_handler_test_remove'
     self.assertNotIn(proj_id1, self.portal.contentIds())
     allgroups_before = self.groups_plugin.listGroupIds()
     proj = adapter.add_project(proj_id1)
     proj_uid = IUUID(proj)
     self.assertIn(proj_id1, self.portal.contentIds())
     allgroups_after = self.groups_plugin.listGroupIds()
     self.assertEquals(len(allgroups_after) - len(allgroups_before), 3)
     for g in ['%s-%s' % (proj_uid, suffix) for suffix in suffixes]:
         assert g in allgroups_after
     ## now create a team workspace inside the project, similarly:
     team_id1 = 'team1'
     allgroups_before = self.groups_plugin.listGroupIds()
     team = adapter.add_workspace_to(proj, team_id1)
     team_uid = IUUID(team)
     allgroups_after = self.groups_plugin.listGroupIds()
     ## necessary/sufficient: all expected groups (and only these):
     self.assertEquals(len(allgroups_after) - len(allgroups_before), 3)
     for g in ['-'.join((team_uid, s)) for s in suffixes]:
         assert g in allgroups_after
     ## now remove from inside-out, starting with team
     proj.manage_delObjects([team_id1])
     allgroups_postdel = self.groups_plugin.listGroupIds()
     self.assertEquals(len(allgroups_after) - len(allgroups_postdel), 3)
     for g in ['-'.join((team_uid, s)) for s in suffixes]:
         assert g not in allgroups_after
     self.portal.manage_delObjects([proj_id1])
     allgroups_donedel = self.groups_plugin.listGroupIds()
     self.assertEquals(len(allgroups_postdel) - len(allgroups_donedel), 3)
     for g in ['-'.join((team_uid, s)) for s in suffixes]:
         assert g not in allgroups_donedel
     for g in ['-'.join((proj_uid, s)) for s in suffixes]:
         assert g not in allgroups_donedel
コード例 #8
0
 def test_remove(self):
     """test removal of project and team, make sure no orphan groups"""
     adapter = CreateContentFixtures(self, self.layer)
     suffixes = WORKSPACE_GROUPS.keys()
     proj_id1 = 'proj_handler_test_remove'
     self.assertNotIn(proj_id1, self.portal.contentIds())
     allgroups_before = self.groups_plugin.listGroupIds()
     proj = adapter.add_project(proj_id1)
     proj_uid = IUUID(proj)
     self.assertIn(proj_id1, self.portal.contentIds())
     allgroups_after = self.groups_plugin.listGroupIds()
     self.assertEquals(len(allgroups_after) - len(allgroups_before), 3)
     for g in ['%s-%s' % (proj_uid, suffix) for suffix in suffixes]:
         assert g in allgroups_after
     ## now create a team workspace inside the project, similarly:
     team_id1 = 'team1'
     allgroups_before = self.groups_plugin.listGroupIds()
     team = adapter.add_workspace_to(proj, team_id1)
     team_uid = IUUID(team)
     allgroups_after = self.groups_plugin.listGroupIds()
     ## necessary/sufficient: all expected groups (and only these):
     self.assertEquals(len(allgroups_after) - len(allgroups_before), 3)
     for g in ['-'.join((team_uid, s)) for s in suffixes]:
         assert g in allgroups_after
     ## now remove from inside-out, starting with team
     proj.manage_delObjects([team_id1])
     allgroups_postdel = self.groups_plugin.listGroupIds()
     self.assertEquals(len(allgroups_after) - len(allgroups_postdel), 3)
     for g in ['-'.join((team_uid, s)) for s in suffixes]:
         assert g not in allgroups_after
     self.portal.manage_delObjects([proj_id1])
     allgroups_donedel = self.groups_plugin.listGroupIds()
     self.assertEquals(len(allgroups_postdel) - len(allgroups_donedel), 3)
     for g in ['-'.join((team_uid, s)) for s in suffixes]:
         assert g not in allgroups_donedel
     for g in ['-'.join((proj_uid, s)) for s in suffixes]:
         assert g not in allgroups_donedel
コード例 #9
0
 def _fixtures(self):
     adapter = CreateContentFixtures(self, self.layer)  # noqa
     adapter.create()
     self.some_user = adapter.TEST_MEMBER
コード例 #10
0
 def _fixtures(self):
     adapter = CreateContentFixtures(self, self.layer)  # noqa
     adapter.create()
     self.some_user = adapter.TEST_MEMBER
コード例 #11
0
 def test_content_creation(self):
     from collective.teamwork.tests.fixtures import CreateContentFixtures
     CreateContentFixtures(self, self.layer).create()