def test_setter(self):
        """ Try behavior properties """
        self.loginAsPortalOwner()
        self.portal.invokeFactory("Document", "doc")
        doc = self.portal.doc

        self.assertTrue(IMobileContentish.providedBy(doc))
        behavior = IMobileBehavior(doc)

        self.assertTrue(isinstance(behavior, MobileBehaviorStorage))
        self.assertEqual(behavior.mobileFolderListing, True)

        behavior.mobileFolderListing = False
    def test_set_media(self):
        """ Try behavior properties """
        self.loginAsPortalOwner()
        self.portal.invokeFactory("Document", "doc")
        doc = self.portal.doc

        self.assertTrue(IMobileContentish.providedBy(doc))
        behavior = IMultiChannelBehavior(doc)

        self.assertEqual(behavior.contentMedias, ContentMediaOption.USE_PARENT)

        behavior.contentMedias = ContentMediaOption.WEB
        behavior.save()

        # Recreate behavior
        behavior = IMultiChannelBehavior(doc)
        self.assertEqual(behavior.contentMedias, ContentMediaOption.WEB)
    def test_has_behavior(self):
        """ Test behavior and assignable works nicely.
        """

        self.loginAsPortalOwner()
        self.portal.invokeFactory("Document", "doc")
        doc = self.portal.doc

        # Check assignable works
        from plone.behavior.interfaces import IBehaviorAssignable
        assignable = IBehaviorAssignable(doc, None)

        self.assertTrue(assignable.supports(IMobileBehavior))
        self.assertNotEqual(assignable, None)


        # Check behavior works
        self.assertTrue(IMobileContentish.providedBy(doc))
        behavior = IMobileBehavior(doc)

        self.assertNotEquals(behavior, None)
    def make_some_evil_site_content(self):
        """ Test behavior and assignable works nicely.
        """

        self.loginAsPortalOwner()
        self.portal.invokeFactory("Document", "doc")
        doc = self.portal.doc
        doc.processForm()

        # Check assignable works
        from plone.behavior.interfaces import IBehaviorAssignable
        assignable = IBehaviorAssignable(doc, None)

        self.assertTrue(assignable.supports(IMultiChannelBehavior))
        self.assertNotEqual(assignable, None)


        # Check behavior works
        self.assertTrue(IMobileContentish.providedBy(doc))
        behavior = IMultiChannelBehavior(doc)
        behavior.contentMedias = ContentMediaOption.BOTH
        behavior.save()