def test_UserID_member(self): from plone.app.caching.operations.etags import UserID class DummyMember(object): def getId(self): return 'bob' class DummyPortalState(object): implements(Interface) adapts(DummyContext, Interface) def __init__(self, context, request): pass def member(self): return DummyMember() provideAdapter(DummyPortalState, name=u"plone_portal_state") environ = {'SERVER_NAME': 'example.com', 'SERVER_PORT': '80'} response = HTTPResponse() request = HTTPRequest(StringIO(), environ, response) published = DummyPublished(DummyContext()) etag = UserID(published, request) self.assertEqual('bob', etag())
def test_UserID_anonymous(self): from plone.app.caching.operations.etags import UserID @implementer(Interface) @adapter(DummyContext, Interface) class DummyPortalState(object): def __init__(self, context, request): pass def member(self): return None provideAdapter(DummyPortalState, name=u'plone_portal_state') environ = {'SERVER_NAME': 'example.com', 'SERVER_PORT': '80'} response = HTTPResponse() request = HTTPRequest(StringIO(), environ, response) published = DummyPublished(DummyContext()) etag = UserID(published, request) self.assertIsNone(etag())