Ejemplo n.º 1
0
    def testClearContents(self):
        user = PrincipalStub('srichter')

        annotationutil = zope.component.getUtility(IPrincipalAnnotationUtility)
        annotations = annotationutil.getAnnotations(user)
        clipboard = IPrincipalClipboard(annotations)
        clipboard.clearContents()
        self.failUnless(clipboard.getContents() == ())
Ejemplo n.º 2
0
    def testClearContents(self):
        user = PrincipalStub('srichter')

        annotationutil = zope.component.getUtility(IPrincipalAnnotationUtility)
        annotations = annotationutil.getAnnotations(user)
        clipboard = IPrincipalClipboard(annotations)
        clipboard.clearContents()
        self.failUnless(clipboard.getContents() == ())
Ejemplo n.º 3
0
    def testSetContents(self):
        user = PrincipalStub('srichter')

        annotationutil = zope.component.getUtility(IPrincipalAnnotationUtility)
        annotations = annotationutil.getAnnotations(user)
        clipboard = IPrincipalClipboard(annotations)

        expected = ({'action':'move', 'target':'bla'},
                    {'action':'move', 'target':'bla/foo'},
                    {'action':'move', 'target':'bla/bar'})
        clipboard.setContents(expected)
        self.failUnless(clipboard.getContents() == expected)
        clipboard.addItems('copy', ['bla'])
        expected = expected + ({'action':'copy', 'target':'bla'},)
        self.failUnless(clipboard.getContents() == expected)
Ejemplo n.º 4
0
    def testSetContents(self):
        user = PrincipalStub('srichter')

        annotationutil = zope.component.getUtility(IPrincipalAnnotationUtility)
        annotations = annotationutil.getAnnotations(user)
        clipboard = IPrincipalClipboard(annotations)

        expected = ({
            'action': 'move',
            'target': 'bla'
        }, {
            'action': 'move',
            'target': 'bla/foo'
        }, {
            'action': 'move',
            'target': 'bla/bar'
        })
        clipboard.setContents(expected)
        self.failUnless(clipboard.getContents() == expected)
        clipboard.addItems('copy', ['bla'])
        expected = expected + ({'action': 'copy', 'target': 'bla'}, )
        self.failUnless(clipboard.getContents() == expected)
Ejemplo n.º 5
0
def getPrincipalClipboard(request):
    """Return the clipboard based on the request."""
    user = request.principal
    annotations = IAnnotations(user)
    return IPrincipalClipboard(annotations)