コード例 #1
0
    def test_supports(self):

        # Context mock
        context_dummy = self.create_dummy(portal_type=u"testtype")

        # Behavior mock
        behavior_dummy_1 = self.create_dummy(interface=IOne)
        self.mock_utility(behavior_dummy_1,
                          IBehavior,
                          name=IOne.__identifier__)
        behavior_dummy_4 = self.create_dummy(interface=IFour)
        self.mock_utility(behavior_dummy_4,
                          IBehavior,
                          name=IFour.__identifier__)

        # FTI mock
        fti = DexterityFTI(u"testtype")
        fti.behaviors = [IOne.__identifier__, IFour.__identifier__]
        self.mock_utility(fti, IDexterityFTI, name=u"testtype")

        self.replay()

        assignable = DexterityBehaviorAssignable(context_dummy)

        self.assertEqual(True, assignable.supports(IOne))
        self.assertEqual(False, assignable.supports(ITwo))
        self.assertEqual(True, assignable.supports(IThree))
        self.assertEqual(True, assignable.supports(IFour))
コード例 #2
0
    def test_supports(self):

        # Context mock
        context_dummy = self.create_dummy(portal_type=u"testtype")

        # Behavior mock
        behavior_dummy_1 = self.create_dummy(interface=IOne)
        self.mock_utility(
            behavior_dummy_1,
            IBehavior,
            name=IOne.__identifier__
        )
        behavior_dummy_4 = self.create_dummy(interface=IFour)
        self.mock_utility(
            behavior_dummy_4,
            IBehavior,
            name=IFour.__identifier__
        )

        # FTI mock
        fti = DexterityFTI(u"testtype")
        fti.behaviors = [IOne.__identifier__, IFour.__identifier__]
        self.mock_utility(fti, IDexterityFTI, name=u"testtype")

        assignable = DexterityBehaviorAssignable(context_dummy)

        self.assertEqual(True, assignable.supports(IOne))
        self.assertEqual(False, assignable.supports(ITwo))
        self.assertEqual(True, assignable.supports(IThree))
        self.assertEqual(True, assignable.supports(IFour))
コード例 #3
0
    def offtest_supports(self):
        """ """
        # Context mock
        with api.env.adopt_roles('Manager'):
            id_ = self.portal.invokeFactory('Organization', 'hospital')
            organization_context = self.portal[id_]
            id_ = organization_context.invokeFactory('Patient', 'patient')
            patient_context = organization_context[id_]

        # Test: Organization has IHeartIdChooser but not IOidConnectClaims
        assignable = DexterityBehaviorAssignable(organization_context)
        self.assertEqual(False, assignable.supports(IOidConnectClaims))
        self.assertEqual(True, assignable.supports(IHeartIdChooser))

        # Test: Patient has both behaviors
        assignable = DexterityBehaviorAssignable(patient_context)
        self.assertEqual(True, assignable.supports(IOidConnectClaims))
        self.assertEqual(True, assignable.supports(IHeartIdChooser))
コード例 #4
0
    def test_supports(self):
        """ """
        # Context mock
        with api.env.adopt_roles('Manager'):
            id_ = self.portal.invokeFactory('OidcTestUser', 'test_oidc_user')  # noqa: P001
            user_context = self.portal[id_]

        # Test: OidcTestUser has expected behaviors
        assignable = DexterityBehaviorAssignable(user_context)
        self.assertEqual(True, assignable.supports(IOidConnectClaims))
コード例 #5
0
    def getGroupsForPrincipal(self, principal, request=None):
        person = self.context
        groups = {}
        for held_position in person.get_held_positions():
            position = held_position.position
            if position:
                obj = position.to_object
                if obj:
                    assignable = DexterityBehaviorAssignable(obj)
                    if assignable.supports(IMembraneGroup):
                        group = IGroup(obj)
                        group_id = group.getGroupId()
                        groups[group_id] = 1

        return tuple(groups.keys())