Пример #1
0
    def offtest_enumerate(self):
        """ """
        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_]

        oid_connection_claims = queryUtility(
            IBehavior, name=IOidConnectClaims.__identifier__)
        id_chooser = queryUtility(IBehavior,
                                  name=IHeartIdChooser.__identifier__)

        assignable = DexterityBehaviorAssignable(organization_context)

        # Organization has IHeartIdChooser
        self.assertIn(id_chooser, list(assignable.enumerateBehaviors()))
        self.assertNotIn(oid_connection_claims,
                         list(assignable.enumerateBehaviors()))

        # Patient has both
        assignable = DexterityBehaviorAssignable(patient_context)
        self.assertIn(id_chooser, list(assignable.enumerateBehaviors()))
        self.assertIn(oid_connection_claims,
                      list(assignable.enumerateBehaviors()))
Пример #2
0
    def test_enumerate(self):
        """ """
        with api.env.adopt_roles('Manager'):
            id_ = self.portal.invokeFactory('OidcTestUser', 'test_oidc_user2')  # noqa: P001
            user_context = self.portal[id_]

        oid_connection_claims = queryUtility(IBehavior, name=IOidConnectClaims.__identifier__)

        assignable = DexterityBehaviorAssignable(user_context)
        self.assertIn(
            oid_connection_claims,
            list(assignable.enumerateBehaviors())
        )
Пример #3
0
    def test_enumerate(self):

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

        # Behavior mock
        behavior_dummy = self.create_dummy()
        self.mock_utility(behavior_dummy, IBehavior, name=IOne.__identifier__)

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

        assignable = DexterityBehaviorAssignable(context_dummy)

        self.assertEqual([behavior_dummy],
                         list(assignable.enumerateBehaviors()))
Пример #4
0
    def test_enumerate(self):

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

        # Behavior mock
        behavior_dummy = self.create_dummy()
        self.mock_utility(behavior_dummy, IBehavior, name=IOne.__identifier__)

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

        self.replay()

        assignable = DexterityBehaviorAssignable(context_dummy)

        self.assertEqual([behavior_dummy], list(assignable.enumerateBehaviors()))