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')]))
    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')]))
    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))
    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))
    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)))
Beispiel #6
0
    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
Beispiel #7
0
    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
    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')]))
    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)))
    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')]))
 def test_basic(self):
     self.assertItemsEqual(['Foo', 'Bar'],
                           get_roles_inherited_by(['Bar'],
                                                  [('Bar', 'Foo')]))
 def test_basic(self):
     self.assertItemsEqual(
         ['Foo', 'Bar'],
         get_roles_inherited_by(['Bar'], [('Bar', 'Foo')]))