コード例 #1
0
    def test_not_matching(self):
        self.assertEquals(
            ['Foo'],
            get_roles_inherited_by(['Foo'], [('Bar', 'Baz')]))

        self.assertEquals(
            ['Foo'],
            get_roles_inherited_by(['Foo'], [('Bar', 'Foo')]))
コード例 #2
0
    def test_recursive(self):
        expected = ['Foo', 'Bar', 'Baz']
        roles = ['Foo']

        self.assertEquals(
            expected,
            get_roles_inherited_by(roles, [('Foo', 'Bar'), ('Bar', 'Baz')]))

        self.assertEquals(
            expected,
            get_roles_inherited_by(roles, [('Bar', 'Baz'), ('Foo', 'Bar')]))
コード例 #3
0
    def test_docstring_example(self):
        # A inherits from B
        # B inherits from C
        role_inheritance = (('A', 'B'), ('B', 'C'))

        self.assertEquals(['A', 'B', 'C'],
                          get_roles_inherited_by(['A'], role_inheritance))
        self.assertEquals(['B', 'C'],
                          get_roles_inherited_by(['B'], role_inheritance))
        self.assertEquals(['C'], get_roles_inherited_by(['C'],
                                                        role_inheritance))
コード例 #4
0
    def test_docstring_example(self):
        # A inherits from B
        # B inherits from C
        role_inheritance = (('A', 'B'), ('B', 'C'))

        self.assertEquals(['A', 'B', 'C'],
                          get_roles_inherited_by(['A'], role_inheritance))
        self.assertEquals(['B', 'C'],
                          get_roles_inherited_by(['B'], role_inheritance))
        self.assertEquals(['C'],
                          get_roles_inherited_by(['C'], role_inheritance))
コード例 #5
0
    def test_circular(self):
        expected = set(['Foo', 'Bar', 'Baz'])
        roles = ['Foo']
        role_inheritance = [('Foo', 'Bar'), ('Bar', 'Baz'), ('Baz', 'Foo')]

        self.assertEquals(expected,
                          set(get_roles_inherited_by(roles, role_inheritance)))
コード例 #6
0
ファイル: sharing.py プロジェクト: jowent/ftw.lawgiver
    def _get_action_group_grid_data(self, spec, rolename):
        """Returns a nested dict with the table / grid data, where
        the outer dict keys are the action groups and the innner
        dict keys are the statues and the inner dict values is the
        HTML cell value (tick character).

        result['edit']['Private'] = self.CHECKED
        """

        action_groups = defaultdict(dict)
        for status in spec.states.values():
            ploneroles = [spec.role_mapping[rolename]]

            role_inheritance = merge_role_inheritance(spec, status)
            ploneroles = get_roles_inherited_by(ploneroles, role_inheritance)
            statements = spec.generals + status.statements

            for statement_spec_role, action_group in statements:
                statement_plone_role = spec.role_mapping[statement_spec_role]
                if statement_plone_role not in ploneroles:
                    continue

                action_groups[action_group][status.title] = self.CHECKED

        return action_groups
コード例 #7
0
ファイル: sharing.py プロジェクト: 4teamwork/ftw.lawgiver
    def _get_action_group_grid_data(self, spec, rolename):
        """Returns a nested dict with the table / grid data, where
        the outer dict keys are the action groups and the innner
        dict keys are the statues and the inner dict values is the
        HTML cell value (tick character).

        result['edit']['Private'] = self.CHECKED
        """

        action_groups = defaultdict(dict)
        for status in spec.states.values():
            ploneroles = [spec.role_mapping[rolename]]

            role_inheritance = merge_role_inheritance(spec, status)
            ploneroles = get_roles_inherited_by(ploneroles, role_inheritance)
            statements = spec.generals + status.statements

            for statement_spec_role, action_group in statements:
                statement_plone_role = spec.role_mapping[statement_spec_role]
                if statement_plone_role not in ploneroles:
                    continue

                action_groups[action_group][status.title] = self.CHECKED

        return action_groups
コード例 #8
0
    def test_recursive(self):
        expected = ['Foo', 'Bar', 'Baz']
        roles = ['Foo']

        self.assertEquals(
            expected,
            get_roles_inherited_by(
                roles,
                [('Foo', 'Bar'),
                 ('Bar', 'Baz')]))

        self.assertEquals(
            expected,
            get_roles_inherited_by(
                roles,
                [('Bar', 'Baz'),
                 ('Foo', 'Bar')]))
コード例 #9
0
    def test_circular(self):
        expected = set(['Foo', 'Bar', 'Baz'])
        roles = ['Foo']
        role_inheritance = [('Foo', 'Bar'),
                            ('Bar', 'Baz'),
                            ('Baz', 'Foo')]

        self.assertEquals(
            expected,
            set(get_roles_inherited_by(roles, role_inheritance)))
コード例 #10
0
    def test_not_matching(self):
        self.assertEquals(['Foo'],
                          get_roles_inherited_by(['Foo'], [('Bar', 'Baz')]))

        self.assertEquals(['Foo'],
                          get_roles_inherited_by(['Foo'], [('Bar', 'Foo')]))
コード例 #11
0
 def test_basic(self):
     self.assertItemsEqual(['Foo', 'Bar'],
                           get_roles_inherited_by(['Bar'],
                                                  [('Bar', 'Foo')]))
コード例 #12
0
 def test_basic(self):
     self.assertItemsEqual(
         ['Foo', 'Bar'],
         get_roles_inherited_by(['Bar'], [('Bar', 'Foo')]))