예제 #1
0
파일: tests.py 프로젝트: wpjunior/proled
class PrincipalAnnotationTests(PlacefulSetup, TestCase):
    def setUp(self):
        PlacefulSetup.setUp(self)
        sm = self.buildFolders(site="/")
        self.util = PrincipalAnnotationUtility()
        zope.component.provideUtility(self.util, IPrincipalAnnotationUtility)

    def testGetSimple(self):
        prince = Principal("somebody")
        self.assert_(not self.util.hasAnnotations(prince))

        princeAnnotation = self.util.getAnnotations(prince)
        # Just getting doesn't actualy store. We don't want to store unless
        # we make a change.
        self.assert_(not self.util.hasAnnotations(prince))

        princeAnnotation["something"] = "whatever"

        # But now we should have the annotation:
        self.assert_(self.util.hasAnnotations(prince))

    def testGetFromLayered(self):
        princeSomebody = Principal("somebody")
        sm1 = self.makeSite("folder1")
        subUtil = setup.addUtility(sm1, "", IPrincipalAnnotationUtility, PrincipalAnnotationUtility())

        parentAnnotation = self.util.getAnnotations(princeSomebody)

        # Just getting doesn't actualy store. We don't want to store unless
        # we make a change.
        self.assert_(not subUtil.hasAnnotations(princeSomebody))

        parentAnnotation["hair_color"] = "blue"

        # But now we should have the annotation:
        self.assert_(self.util.hasAnnotations(princeSomebody))

        subAnnotation = subUtil.getAnnotations(princeSomebody)
        self.assertEquals(subAnnotation["hair_color"], "blue")

        subAnnotation["foo"] = "bar"

        self.assertEquals(parentAnnotation.get("foo"), None)
예제 #2
0
파일: tests.py 프로젝트: wpjunior/proled
 def setUp(self):
     PlacefulSetup.setUp(self)
     sm = self.buildFolders(site="/")
     self.util = PrincipalAnnotationUtility()
     zope.component.provideUtility(self.util, IPrincipalAnnotationUtility)