def setUp(self): portal = self.layer['portal'] setRoles(portal, TEST_USER_ID, ('Manager',)) portal.invokeFactory('my315ok.products.productfolder', 'productfolder1', PerPagePrdtNum=5,PerRowPrdtNum=3,title="productfolder1",description="demo productfolder") portal['productfolder1'].invokeFactory('my315ok.products.product','product1',title="Gif image",description="a gif image") portal['productfolder1'].invokeFactory('my315ok.products.product','product2',title="Jpeg image",description="a jpeg image") portal['productfolder1'].invokeFactory('my315ok.products.product','product3',title="Png image",description="a png image") portal['productfolder1'].invokeFactory('my315ok.products.product','product4',title="Jpeg image2",description="a jpeg image2") portal['productfolder1'].invokeFactory('my315ok.products.product','product5',title="Png image2",description="a png image2") data = getFile('image.gif').read() item = portal['productfolder1']['product1'] item.image = NamedImage(data, 'image/gif', u'image.gif') data2 = getFile('image.jpg').read() item2 = portal['productfolder1']['product2'] item2.image = NamedImage(data2, 'image/jpeg', u'image.jpg') data3 = getFile('image.png').read() item3 = portal['productfolder1']['product3'] item3.image = NamedImage(data3, 'image/png', u'image.png') item4 = portal['productfolder1']['product4'] item4.image = NamedImage(data3, 'image/png', u'image.png') item5 = portal['productfolder1']['product5'] item5.image = NamedImage(data3, 'image/png', u'image.png') self.portal = portal
def test_install(self): """When p.app.intid is intalled it registers some utility from zope.intid and five.intid and search in portal_catalog all contents in order to register them in these utilities. This test checks that all pre existing contents are registered correctly """ from plone.app.intid.setuphandlers import add_intids from plone.app.testing import applyProfile # we create a folder before the intallation of plone.app.intid setRoles(self.portal, TEST_USER_ID, ['Manager']) folder_id = self.portal.invokeFactory('Folder', 'folder') folder = self.portal[folder_id] # now we install manually the intid utilities add_intids(self.portal) intids = getUtility(IIntIds) # this folder is not referenced by intid utility self.assertRaises(KeyError, intids.getId, folder) # when we install p.app.intid our folder is referencend by intid applyProfile(self.portal, 'plone.app.intid:default') self.assertIsNotNone(intids.getId(folder))
def setUpPloneSite(self, portal): # Install into Plone site using portal_setup self.applyProfile(portal, '%s:default' % PROJECTNAME) login(portal, TEST_USER_NAME) setRoles(portal, TEST_USER_ID, ['Manager']) portal.invokeFactory('Survey', 's1') s1 = getattr(portal, 's1') s1.setAllowAnonymous(True) # workflow_tool = getToolByName(portal, 'portal_workflow') # workflow_tool.doActionFor(s1,'publish') s1.setEmailInvite(DEFAULT_SURVEY_INVITE) s1.invokeFactory('Sub Survey', 'ss1') s1.invokeFactory('Sub Survey', 'ss2') s1.invokeFactory('Sub Survey', 'ss3') ss1 = getattr(s1, 'ss1') ss2 = getattr(s1, 'ss2') ss3 = getattr(s1, 'ss3') s1.invokeFactory('Survey Select Question', 'ssq1') ss1.invokeFactory('Survey Select Question', 'ssq2') ss2.invokeFactory('Survey Select Question', 'ssq3') ss1.setRequiredQuestion('ssq1') ss1.setRequiredAnswer('No') ss2.setRequiredQuestion('ssq1') ss2.setRequiredAnswer('Yes') ss3.setRequiredQuestion('ssq2') ss3.setRequiredAnswer('Yes')
def setUp(self): layer = self.globs["layer"] browser = Browser(layer["app"]) portal = layer["portal"] # Update global variables within the tests. self.globs.update( { "browser": browser, "portal": portal, "TEST_USER_NAME": TEST_USER_NAME, "TEST_USER_PASSWORD": TEST_USER_PASSWORD, } ) browser.setBaseUrl(portal.absolute_url()) browser.handleErrors = True portal.error_log._ignored_exceptions = () setRoles(portal, TEST_USER_ID, ["Manager"]) data_path = "/".join(__file__.split("/")[:-1] + ["files", "data.csv"]) self.globs["data_path"] = data_path self.globs["data_file"] = open(data_path) transaction.commit()
def setUp(self): self.portal = self.layer['portal'] self.request = self.layer['request'] setRoles(self.portal, TEST_USER_ID, ['Manager']) registry = getUtility(IRegistry) self.navigation_settings = registry.forInterface( INavigationSchema, prefix="plone")
def test_statusmap_on_inactive_content(self, browser): inactive_folder = create(Builder('folder') .titled('Inactive Folder') .having(effectiveDate=DateTime() + 10) .within(self.portal)) create(Builder('folder') .titled('Active Folder') .within(inactive_folder)) # A user not having the permission to access inactive content must # be able to change the state of the inactive content itself, i.e. # calling the statusmap view on an inactive context. setRoles(self.portal, TEST_USER_ID, ['Contributor']) transaction.commit() browser.login().visit(inactive_folder, view="@@statusmap") self.assertEqual( ['Inactive Folder', 'Active Folder'], browser.css('.listing tr td span').text ) # The same applies to a user having the permission to access inactive # content. setRoles(self.portal, TEST_USER_ID, ['Manager']) transaction.commit() browser.login().visit(inactive_folder, view="@@statusmap") self.assertEqual( ['Inactive Folder', 'Active Folder'], browser.css('.listing tr td span').text )
def setUp(self): portal = self.layer['portal'] self.portal = portal self.request = self.layer['request'] setRoles(portal, TEST_USER_ID, ['Manager']) setHooks() setSite(portal)
def setUp(self): self.portal = self.layer["portal"] setRoles(self.portal, TEST_USER_ID, ["Manager"]) self.registry = getUtility(IRegistry) # uninstall the package self.qi = getattr(self.portal, "portal_quickinstaller") self.qi.uninstallProducts(products=["collective.routes"])
def test_statusmap_on_objects_having_inactive_content(self, browser): # Create a container which will hold the content used for this test. # The container does not play an important role in the test. folder = create(Builder('folder').titled('Container')) # Create some content used in this test. create(Builder('folder') .titled('Active Folder') .within(folder)) create(Builder('folder') .titled('Inactive Folder') .having(effectiveDate=DateTime() + 10) .within(folder)) # A user not having the permission to access inactive content can only # change the state of the container and the active folder inside the # container, but not the inactive folder inside the container. # Thus the inactive folder must not be visible in the statusmap view. setRoles(self.portal, TEST_USER_ID, ['Contributor']) transaction.commit() browser.login().visit(folder, view="@@statusmap") self.assertEqual( ['Container', 'Active Folder'], browser.css('.listing tr td span').text ) # A manager can also change the state of the inactive folder. # Thus the inactive folder must be visible in the statusmap view too. setRoles(self.portal, TEST_USER_ID, ['Manager']) transaction.commit() browser.login().visit(folder, view="@@statusmap") self.assertEqual( ['Container', 'Active Folder', 'Inactive Folder'], browser.css('.listing tr td span').text )
def setUp(self): self.portal = self.layer['portal'] setRoles(self.portal, TEST_USER_ID, ['Manager']) self.portal.invokeFactory(id='doc1', title='Document 1', type_name='Document') # Create a conversation. In this case we doesn't assign it to an # object, as we just want to check the Conversation object API. conversation = IConversation(self.portal.doc1) # Add a comment. Note: in real life, we always create comments via the # factory to allow different factories to be swapped in comment = createObject('plone.Comment') comment.text = 'Lorem ipsum dolor sit amet.' comment.creator = "jim" comment.author_name = "Jim" comment.creation_date = datetime(2006, 9, 17, 14, 18, 12) comment.modification_date = datetime(2008, 3, 12, 7, 32, 52) self.comment_id = conversation.addComment(comment) self.comment = comment.__of__(conversation) self.conversation = conversation
def setUp(self): super(IntegrationTestCase, self).setUp() self.portal = self.layer['portal'] testing.setRoles(self.portal, testing.TEST_USER_ID, ['Manager']) self.portal.invokeFactory('Folder', 'test-folder') testing.setRoles(self.portal, testing.TEST_USER_ID, ['Member']) self.folder = self.portal['test-folder']
def setUpPloneSite(self, portal): """ Setup Plone """ applyProfile(portal, 'eea.app.visualization:default') # Login as manager setRoles(portal, TEST_USER_ID, ['Manager'])
def setUp(self): """Custom shared utility setup for tests.""" self.portal = self.layer['portal'] login(self.portal, TEST_USER_NAME) setRoles(self.portal, TEST_USER_ID, ['Manager']) self.folder = api.content.create( container=self.portal, type='Folder', title='Folder')
def test_handler(self): portal = self.layer['portal'] setRoles(portal, TEST_USER_ID, ['Manager']) login(portal, TEST_USER_NAME) portal.invokeFactory('Document', 'referenced') vocabulary = ReferenceableVocabulary(portal.referenced) ref_schema = ATDocument.schema.copy() + \ Schema( (StringField( name='folderCategory', enforceVocabulary=True, vocabulary=vocabulary, ), )) class WithReferencedField(ATDocument): schema = ref_schema registerType(WithReferencedField, 'p.a.referenceintegrity') from plone.app.referenceintegrity import vocabularies source = WithReferencedField('source') source = source.__of__(self.layer['portal']) source.initializeArchetype() vocabularies.modifiedArchetype(source, None) references = source.getReferences(relationship=vocabularyRelationship) self.assertEquals([portal.referenced], references)
def setUp(self): portal = self.layer["portal"] self.portal = portal self.request = self.layer["request"] setRoles(portal, TEST_USER_ID, ["Manager"]) setHooks() setSite(portal)
def test_permission(self): setRoles(self.portal, TEST_USER_ID, ['Editor']) self.portal.REQUEST.set('ACTUAL_URL', 'http://nohost') self.newsletter.invokeFactory( "ENLIssue", id="issue") self.newsletter.issue.title = "Test Newsletter Issue" self.newsletter.issue.setText("<h1>This is the newsletter body!") view = self.newsletter.restrictedTraverse("enl_drafts_view") view_result = view() self.assertIn('test-folder/newsletter/issue', view_result) view = self.newsletter.restrictedTraverse("issue/send-issue-form") view_result = view() self.assertIn('Test Newsletter', view_result) # Editor is not allowed to call the one-step send-issue meant for cron with self.assertRaises(Unauthorized): self.newsletter.restrictedTraverse("issue/send-issue") # check for postonly view = self.newsletter.restrictedTraverse("issue/send-issue-from-form") with self.assertRaises(Forbidden): view()
def setUp(self): self.portal = self.layer['portal'] setRoles(self.portal, TEST_USER_ID, ['Manager']) login(self.portal, TEST_USER_NAME) self.portal.invokeFactory('Folder', 'test-folder') self.folder = self.portal['test-folder'] self.portal = self.layer['portal'] self.folder.invokeFactory("EasyNewsletter", "newsletter") self.newsletter = self.folder.newsletter self.newsletter.senderEmail = "*****@*****.**" self.newsletter.senderName = "ACME newsletter" self.newsletter.testEmail = "*****@*****.**" # Set up a mock mailhost self.portal._original_MailHost = self.portal.MailHost self.portal.MailHost = mailhost = MockMailHost('MailHost') sm = getSiteManager(context=self.portal) sm.unregisterUtility(provided=IMailHost) sm.registerUtility(mailhost, provided=IMailHost) # We need to fake a valid mail setup self.portal.email_from_address = "*****@*****.**" self.mailhost = self.portal.MailHost # image for image testing self.folder.invokeFactory("Image", "image") self.image = self.folder.image img1 = open(os.path.join(TESTS_HOME, 'img1.png'), 'rb').read() self.image.edit(image=img1)
def setUp(self): self.portal = self.layer['portal'] self.portal_url = self.portal.portal_url() # create EasyNewsletter instance and add some subscribers setRoles(self.portal, TEST_USER_ID, ['Manager']) login(self.portal, TEST_USER_NAME) self.portal._original_MailHost = self.portal.MailHost self.portal.MailHost = mailhost = MockMailHost('MailHost') sm = getSiteManager(context=self.portal) sm.unregisterUtility(provided=IMailHost) sm.registerUtility(mailhost, provided=IMailHost) self.mail_host = getUtility(IMailHost) if not IS_PLONE_5: # BBB self.portal.email_from_address = "*****@*****.**" self.portal.email_from_name = u"Plone Master" self.mail_host.smtp_host = u"example.com" self.mail_host.smtp_port = 25 self.mail_host.smtp_userid = u"*****@*****.**" self.mail_host.smtp_pass = u"Password" else: self.registry = getUtility(IRegistry) reg_mail = self.registry.forInterface( IMailSchema, prefix='plone') reg_mail.email_from_address = '*****@*****.**' reg_mail.email_from_name = u'Plone Master' reg_mail.smtp_host = u'example.com' reg_mail.smtp_port = 25 reg_mail.smtp_userid = u'*****@*****.**' reg_mail.smtp_pass = u'Password'
def setUp(self): self.portal = self.layer['portal'] self.request = self.layer['request'] self.registry = getUtility(IRegistry) setRoles(self.portal, TEST_USER_ID, ('Manager',)) self.portal.invokeFactory('Folder', 'f1', title=u"Folder 1") self.portal['f1'].invokeFactory('Document', 'd1', title=u"Document 1") setRoles(self.portal, TEST_USER_ID, ('Member',)) if HAS_PLONE_APP_CONTENTTYPES: from plone.app.contenttypes.interfaces import IDocument iface = IDocument else: iface = self.portal['f1']['d1'].__class__ from plone.app.blocks.layoutbehavior import ILayoutAware from plone.app.blocks.layoutbehavior import LayoutAwareBehavior sm = getGlobalSiteManager() sm.registerAdapter(LayoutAwareBehavior, [iface]) registrations = sm.getAdapters( (self.portal['f1']['d1'],), ILayoutAware ) self.assertEqual(len(list(registrations)), 1) self.behavior = ILayoutAware(self.portal['f1']['d1'])
def setUp(self): self.portal = self.layer['portal'] setRoles(self.portal, TEST_USER_ID, ['Manager']) # Create a conversation. conversation = IConversation(self.portal.doc1) comment1 = createObject('plone.Comment') comment1.text = 'Comment Text' comment1.creator = "jim" comment1.author_username = "******" comment1.creation_date = datetime(2006, 9, 17, 14, 18, 12) comment1.modification_date = datetime(2006, 9, 17, 14, 18, 12) self.new_id1 = conversation.addComment(comment1) comment2 = createObject('plone.Comment') comment2.text = 'Comment Text' comment2.creator = "emma" comment2.author_username = "******" comment2.creation_date = datetime(2007, 12, 13, 4, 18, 12) comment2.modification_date = datetime(2007, 12, 13, 4, 18, 12) self.new_id2 = conversation.addComment(comment2) comment3 = createObject('plone.Comment') comment3.text = 'Comment Text' comment3.creator = "lukas" comment3.author_username = "******" comment3.creation_date = datetime(2009, 4, 12, 11, 12, 12) comment3.modification_date = datetime(2009, 4, 12, 11, 12, 12) self.new_id3 = conversation.addComment(comment3) self.conversation = conversation
def setUp(self): self.portal = self.layer['portal'] self.request = self.layer['request'] setRoles(self.portal, TEST_USER_ID, ['Manager']) login(self.portal, TEST_USER_NAME) transaction.commit()
def setUp(self): self.portal = self.layer['portal'] self.request = self.layer['request'] setRoles(self.portal, TEST_USER_ID, ['Manager']) self.portal.invokeFactory('Folder', 'test-folder') self.folder = self.portal['test-folder'] interface.alsoProvides( self.portal.REQUEST, interfaces.IDiscussionLayer, ) typetool = self.portal.portal_types typetool.constructContent('Document', self.portal, 'doc1') wftool = getToolByName(self.portal, "portal_workflow") wftool.doActionFor(self.portal.doc1, action='publish') self.discussionTool = getToolByName( self.portal, 'portal_discussion', None ) self.discussionTool.overrideDiscussionFor(self.portal.doc1, False) self.membershipTool = getToolByName(self.folder, 'portal_membership') self.memberdata = self.portal.portal_memberdata self.context = getattr(self.portal, 'doc1') # Allow discussion registry = queryUtility(IRegistry) settings = registry.forInterface(IDiscussionSettings) settings.globally_enabled = True
def setUp(self): """Shared test environment set-up, ran before every test.""" layer = self.globs["layer"] # Update global variables within the tests. self.globs.update( { "portal": layer["portal"], "request": layer["request"], "browser": Browser(layer["app"]), "TEST_USER_NAME": TEST_USER_NAME, "TEST_USER_PASSWORD": TEST_USER_PASSWORD, "self": self, } ) portal = self.globs["portal"] browser = self.globs["browser"] browser.handleErrors = True portal.error_log._ignored_exceptions = () setRoles(portal, TEST_USER_ID, ["Manager"]) applyProfile(portal, "Products.CMFPlone:plone") transaction.commit()
def setUp(self): self.portal = self.layer['portal'] self.installer = api.portal.get_tool('portal_quickinstaller') roles_before = api.user.get_roles(TEST_USER_ID) setRoles(self.portal, TEST_USER_ID, ['Manager']) self.installer.uninstallProducts(['rg.prenotazioni']) setRoles(self.portal, TEST_USER_ID, roles_before)
def setUp(self): layer = self.globs['layer'] browser = Browser(layer['app']) portal = layer['portal'] self.globs.update({ 'TEST_USER_NAME': TEST_USER_NAME, 'TEST_USER_PASSWORD': TEST_USER_PASSWORD, 'browser': browser, 'portal': portal, }) browser.setBaseUrl(portal.absolute_url()) browser.handleErrors = True portal.error_log._ignored_exceptions = () setRoles(portal, TEST_USER_ID, ['Manager']) # Create News Item. newsitem = portal[portal.invokeFactory('News Item', 'newsitem')] newsitem.reindexObject() # Set the site back in English mode to make testing easier. portal.portal_languages.manage_setLanguageSettings('en', ['en', 'fi']) transaction.commit()
def setUp(self): self.portal = self.layer["portal"] setRoles(self.portal, TEST_USER_ID, ["Manager"]) self.portal.invokeFactory(id="doc1", Title="Document 1", type_name="Document") self.catalog = getToolByName(self.portal, "portal_catalog") conversation = IConversation(self.portal.doc1) comment1 = createObject("plone.Comment") comment1.title = "Comment 1" comment1.text = "Comment text" comment1.creator = "Jim" comment1.author_username = "******" comment1.creation_date = datetime(2006, 9, 17, 14, 18, 12) comment1.modification_date = datetime(2006, 9, 17, 14, 18, 12) new_comment1_id = conversation.addComment(comment1) self.comment_id = new_comment1_id brains = self.catalog.searchResults( dict(path={"query": "/".join(self.portal.doc1.getPhysicalPath())}, portal_type="Document") ) self.conversation = conversation self.brains = brains self.doc1_brain = brains[0] self.comment1 = comment1 self.new_comment1_id = new_comment1_id
def setUp(self): self.portal = self.layer['portal'] setRoles(self.portal, TEST_USER_ID, ['Manager']) login(self.portal, TEST_USER_NAME) self.portal.invokeFactory('Folder', 'test-folder') self.folder = self.portal['test-folder'] self.types = self.portal.portal_types
def setUp(self): self.portal = self.layer['portal'] self.request = self.layer['request'] setRoles(self.portal, TEST_USER_ID, ['Manager']) self.portal.invokeFactory('Folder', 'test-folder') self.folder = self.portal['test-folder'] interface.alsoProvides( self.request, interfaces.IDiscussionLayer ) self.workflowTool = getToolByName(self.portal, 'portal_workflow') self.workflowTool.setDefaultChain('one_state_workflow') typetool = self.portal.portal_types typetool.constructContent('Document', self.portal, 'doc1') self.portal_discussion = getToolByName( self.portal, 'portal_discussion', None ) self.membershipTool = getToolByName(self.folder, 'portal_membership') self.memberdata = self.portal.portal_memberdata context = getattr(self.portal, 'doc1') self.viewlet = CommentsViewlet(context, self.request, None, None) # Allow discussion registry = queryUtility(IRegistry) settings = registry.forInterface(IDiscussionSettings) settings.globally_enabled = True
def setUp(self): portal = self.layer['portal'] setRoles(portal, TEST_USER_ID, ('Manager',)) portal.invokeFactory('my315ok.socialorgnization.orgnizationfolder', 'orgnizationfolder1', PerPagePrdtNum=5,PerRowPrdtNum=3,title="orgnizationfolder1",description="demo orgnizationfolder") portal['orgnizationfolder1'].invokeFactory('my315ok.socialorgnization.orgnization','orgnization1', title=u"宝庆商会", description=u"运输业", address=u"建设北路", register_code="8341", supervisor=u"交通局", organization_type=u"登记", law_person=u"张建明", ) portal['orgnizationfolder1'].invokeFactory('my315ok.socialorgnization.orgnization','orgnization2',title="Jpeg image",description="a jpeg image") portal['orgnizationfolder1'].invokeFactory('my315ok.socialorgnization.orgnization','orgnization3',title="Png image",description="a png image") portal['orgnizationfolder1'].invokeFactory('my315ok.socialorgnization.orgnization','orgnization4',title="Jpeg image2",description="a jpeg image2") portal['orgnizationfolder1'].invokeFactory('my315ok.socialorgnization.orgnization','orgnization5',title="Png image2",description="a png image2") data = getFile('image.gif').read() item = portal['orgnizationfolder1']['orgnization1'] item.image = NamedImage(data, 'image/gif', u'image.gif') data2 = getFile('image.jpg').read() item2 = portal['orgnizationfolder1']['orgnization2'] item2.image = NamedImage(data2, 'image/jpeg', u'image.jpg') data3 = getFile('image.png').read() item3 = portal['orgnizationfolder1']['orgnization3'] item3.image = NamedImage(data3, 'image/png', u'image.png') item4 = portal['orgnizationfolder1']['orgnization4'] item4.image = NamedImage(data3, 'image/png', u'image.png') item5 = portal['orgnizationfolder1']['orgnization5'] item5.image = NamedImage(data3, 'image/png', u'image.png') self.portal = portal
def test_permission_to_vote_closed_poll(self): setRoles(self.portal, TEST_USER_ID, ['Manager']) wt = self.wt poll = self.p3 wt.doActionFor(poll, 'close') roles = poll.rolesOfPermission(PERMISSION_VOTE) self.assertEqual(self._active_roles(roles), [])
def setUp(self): """Custom shared utility setup for tests.""" self.portal = self.layer['portal'] setRoles(self.portal, TEST_USER_ID, ['Manager']) self.parent = self.portal
def setUpPloneSite(self, portal): # install into the Plone site applyProfile(portal, 'collective.elasticsearch:default') setRoles(portal, TEST_USER_ID, ('Member', 'Manager')) workflowTool = getToolByName(portal, 'portal_workflow') workflowTool.setDefaultChain('plone_workflow')
def setUp(self): self.portal = self.layer['portal'] setRoles(self.portal, TEST_USER_ID, ['Manager']) self.qi = getattr(self.portal, 'portal_quickinstaller') self.qi.uninstallProducts(products=[PROJECTNAME])
def setUp(self): self.portal = self.layer['portal'] self.request = TestRequest() setRequest(self.request) setRoles(self.portal, TEST_USER_ID, ['Manager'])
def grant(self, *roles): setRoles(self.portal, TEST_USER_ID, list(roles)) transaction.commit()
def setUp(self): self.portal = self.layer['portal'] self.request = self.layer['request'] set_browserlayer(self.request) setRoles(self.portal, TEST_USER_ID, ['Manager'])
def test_ct_newsletter_issue_globally_not_addable(self): setRoles(self.portal, TEST_USER_ID, ["Contributor"]) fti = queryUtility(IDexterityFTI, name="Newsletter Issue") self.assertFalse(fti.global_allow, "{0} is globally addable!".format(fti.id))
def setUp(self): self.portal = self.layer['portal'] self.app = self.layer['app'] self.request = self.app.REQUEST setRoles(self.portal, TEST_USER_ID, ['Manager'])
def setUp(self): self.portal = self.layer['portal'] self.request = self.layer['request'] setRoles(self.portal, TEST_USER_ID, ['Manager']) registry = getUtility(IRegistry) self.settings = registry.forInterface(ILanguageSchema, prefix="plone")
def setUp(self): self.portal = self.layer['portal'] setRoles(self.portal, TEST_USER_ID, ['Manager'])
def setUp(self): self.portal = self.layer['portal'] self.request = self.layer['request'] self.catalog = self.portal.portal_catalog self.wf = self.portal.portal_workflow setRoles(self.portal, TEST_USER_ID, ['Manager']) self.portal.invokeFactory('Folder', 'test-folder') self.folder = self.portal['test-folder'] self.set_default_workflow() # Let's create 3 sections in the registry registry = getUtility(IRegistry) settings = registry.forInterface(INITFSettings) settings.available_sections = set( [u'Section 1', u'Section 2', u'Section 3']) # Let's create 15 nitf's for each of 3 different sections for index in range(1, 16): self.folder.invokeFactory('collective.nitf.content', 'section1-nitf-{0}'.format(index)) n = self.folder['section1-nitf-{0}'.format(index)] n.title = 'Section 1 Nitf {0}'.format(index) n.section = 'Section 1' n.genre = 'Genre {0}'.format(index) n.created = DateTime('{year}/1/{index} {index}:00:00'.format( year=DateTime().year(), index=index)) n.reindexObject() # After 5 indexes, publish if index % 5 == 0: self.wf.doActionFor(n, 'publish') self.folder.invokeFactory('collective.nitf.content', 'section2-nitf-{0}'.format(index)) n = self.folder['section2-nitf-{0}'.format(index)] n.title = 'Section 2 Nitf {0}'.format(index) n.section = 'Section 2' n.genre = 'Genre {0}'.format(index) n.created = DateTime('{year}/2/{index} {index}:00:00'.format( year=DateTime().year(), index=index)) n.reindexObject() # After 5 indexes, publish if index % 5 == 0: self.wf.doActionFor(n, 'publish') self.folder.invokeFactory('collective.nitf.content', 'section3-nitf-{0}'.format(index)) n = self.folder['section3-nitf-{0}'.format(index)] n.title = 'Section 3 Nitf {0}'.format(index) n.section = 'Section 3' n.genre = 'Genre {0}'.format(index) n.created = DateTime('{year}/3/{index} {index}:00:00'.format( year=DateTime().year(), index=index)) n.reindexObject() # After 5 indexes, publish if index % 5 == 0: self.wf.doActionFor(n, 'publish') self.default_query = { 'Type': ('News Article', ), 'sort_on': 'created', 'sort_order': 'reverse', 'sort_limit': 10 }
def test_ct_infocard_globally_not_addable(self): setRoles(self.portal, TEST_USER_ID, ['Contributor']) fti = queryUtility(IDexterityFTI, name='Infocard') self.assertFalse(fti.global_allow, u'{0} is globally addable!'.format(fti.id))
def setUp(self): super(FunctionalTestCase, self).setUp() self.portal = self.layer['portal'] testing.setRoles(self.portal, testing.TEST_USER_ID, ['Manager']) testing.setRoles(self.portal, testing.TEST_USER_ID, ['Member'])
def test_render_field(self): setRoles(self.portal, TEST_USER_ID, ['Manager']) view = self.portal.unrestrictedTraverse('incoming-mail/mail-searches/all_mails/@@tabular_view')
def setUp(self): layer = self.globs['layer'] # Update global variables within the tests. self.globs.update({ 'portal': layer['portal'], 'portal_url': layer['portal'].absolute_url(), 'browser': Browser(layer['app']), }) ztc.utils.setupCoreSessions(layer['app']) portal = self.globs['portal'] browser = self.globs['browser'] portal_url = self.globs['portal_url'] browser.setBaseUrl(portal_url) browser.handleErrors = True portal.error_log._ignored_exceptions = () setRoles(portal, TEST_USER_ID, ['Manager']) portal.invokeFactory('CartFolder', 'cfolder') portal.invokeFactory( 'ShippingMethod', 'method01', title="ShippingMethod01", base_charge=10.0, weight_charge=5.0, ) method01 = portal.method01 method01.reindexObject() ## Create Product00 portal.invokeFactory( 'Document', 'doc00', title='Product00', description='Description of Product00', ) doc00 = portal.doc00 alsoProvides(doc00, IAddableToCart) IAnnotations(doc00)['collective.cart.core'] = ProductAnnotations() product00 = IProduct(doc00) product00.price = Decimal('100.00') product00.unlimited_stock = True product00.max_addable_quantity = 5 ## Create Product01 portal.invokeFactory( 'Document', 'doc01', title='Product01', description='Description of Product01', ) doc01 = portal.doc01 alsoProvides(doc01, IAddableToCart) IAnnotations(doc01)['collective.cart.core'] = ProductAnnotations() product01 = IProduct(doc01) product01.price = Decimal('10.00') product01.stock = 50 product01.max_addable_quantity = 30 ## Create Product02 portal.invokeFactory( 'Document', 'doc02', title='Product02', description='Description of Product02', ) doc02 = portal.doc02 alsoProvides(doc02, IAddableToCart) IAnnotations(doc02)['collective.cart.core'] = ProductAnnotations() product02 = IProduct(doc02) product02.price = Decimal('5.00') product02.stock = 20 product02.max_addable_quantity = 50 transaction.commit()
def setUp(self): self.app = self.layer["app"] self.portal = self.layer["portal"] setRoles(self.portal, TEST_USER_ID, ["Manager"])
def test_view_get_valid(self): setRoles(self.portal, TEST_USER_ID, ['Manager']) self.view.update() self.assertEqual(200, self.view.request.response.status)
def setUp(self): """Custom shared utility setup for tests.""" self.portal = self.layer['portal'] setRoles(self.portal, TEST_USER_ID, ['Manager']) self.installer = api.portal.get_tool('portal_quickinstaller')
def setUp(self): self.portal = self.layer['portal'] setRoles(self.portal, TEST_USER_ID, ['Manager']) self.registry = Registry() self.registry.registerInterface(IDecoSettings)
def setUp(self): self.portal = self.layer['portal'] setRoles(self.portal, TEST_USER_ID, ['Manager']) self.portal.invokeFactory('Folder', 'folder', title="Test Folder") self.folder = self.portal.folder
def test_ct_classification_folder_globally_not_addable(self): setRoles(self.portal, TEST_USER_ID, ["Contributor"]) fti = queryUtility(IDexterityFTI, name="ClassificationFolder") self.assertFalse(fti.global_allow, u"{0} is globally addable!".format(fti.id))
def setUp(self): self.portal = self.layer['portal'] self.request = self.layer['request'] setRoles(self.portal, TEST_USER_ID, ['Manager']) setHooks()
def test_configure_group_encoder(self): setRoles(self.portal, TEST_USER_ID, ['Manager']) # activate imail group encoder activate_group_encoder(self.portal) self.assertIn(CREATING_GROUP_SUFFIX, [fct['fct_id'] for fct in get_registry_functions()]) for portal_type in ('dmsincomingmail', 'dmsincoming_email'): fti = getUtility(IDexterityFTI, name=portal_type) self.assertIn( 'imio.dms.mail.content.behaviors.IDmsMailCreatingGroup', fti.behaviors) self.assertIn('creating_group', [tup[0] for tup in get_localrole_fields(fti)]) self.assertTrue( fti.localroles.get('creating_group')) # config dic not empty crit = ICriteria(self.portal['incoming-mail']['mail-searches']) self.assertIn('c90', crit.keys()) fields = api.portal.get_registry_record( 'imio.dms.mail.browser.settings.IImioDmsMailConfig.imail_fields') self.assertIn('IDmsMailCreatingGroup.creating_group', [f['field_name'] for f in fields]) # activate omail group encoder activate_group_encoder(self.portal, typ='omail') self.assertIn(CREATING_GROUP_SUFFIX, [fct['fct_id'] for fct in get_registry_functions()]) # for portal_type in ('dmsoutgoingmail', 'dmsoutgoing_email'): for portal_type in ('dmsoutgoingmail', ): fti = getUtility(IDexterityFTI, name=portal_type) self.assertIn( 'imio.dms.mail.content.behaviors.IDmsMailCreatingGroup', fti.behaviors, portal_type) self.assertIn('creating_group', [tup[0] for tup in get_localrole_fields(fti)], portal_type) self.assertTrue(fti.localroles.get('creating_group'), portal_type) # config dic not empty crit = ICriteria(self.portal['outgoing-mail']['mail-searches']) self.assertIn('c90', crit.keys()) fields = api.portal.get_registry_record( 'imio.dms.mail.browser.settings.IImioDmsMailConfig.omail_fields') self.assertIn('IDmsMailCreatingGroup.creating_group', [f['field_name'] for f in fields]) # activate contact group encoder activate_group_encoder(self.portal, typ='contact') self.assertIn(CREATING_GROUP_SUFFIX, [fct['fct_id'] for fct in get_registry_functions()]) self.assertIn(CONTACTS_PART_SUFFIX, [fct['fct_id'] for fct in get_registry_functions()]) for portal_type in ('organization', 'person', 'held_position', 'contact_list'): fti = getUtility(IDexterityFTI, name=portal_type) self.assertIn( 'imio.dms.mail.content.behaviors.IDmsMailCreatingGroup', fti.behaviors) self.assertIn('creating_group', [tup[0] for tup in get_localrole_fields(fti)]) for fid in ('orgs-searches', 'persons-searches', 'hps-searches', 'cls-searches'): crit = ICriteria(self.portal['contacts'][fid]) self.assertIn('c90', crit.keys())
def setUpUser(self): setRoles(self.portal, TEST_USER_ID, ['Manager', 'Editor', 'Reviewer']) login(self.portal, TEST_USER_NAME)
def test_composite_views(self): # This is a clone of the same test for 'without-caching-proxy' # Can we just call that test from this context? catalog = self.portal['portal_catalog'] skins_tool = self.portal['portal_skins'] # Add folder content setRoles(self.portal, TEST_USER_ID, ('Manager', )) self.portal.invokeFactory('Folder', 'f1') self.portal['f1'].title = "one" self.portal['f1'].description = u"Folder one description" self.portal['f1'].reindexObject() # Add page content self.portal['f1'].invokeFactory('Document', 'd1') self.portal['f1']['d1'].title = u"Document one" self.portal['f1']['d1'].description = u"Document one description" testText = "Testing... body one" self.portal['f1']['d1'].text = RichTextValue(testText, 'text/plain', 'text/html') self.portal['f1']['d1'].reindexObject() # Publish the folder and page self.portal.portal_workflow.doActionFor(self.portal['f1'], 'publish') self.portal.portal_workflow.doActionFor(self.portal['f1']['d1'], 'publish') # Should we set up the etag components? # - set member? No # - reset catalog counter? Maybe # - set server language? # - turn on gzip? # - set skin? Maybe # - leave status unlocked # import transaction transaction.commit() # Request the authenticated folder now = stable_now() browser = Browser(self.app) browser.addHeader( 'Authorization', 'Basic %s:%s' % ( TEST_USER_NAME, TEST_USER_PASSWORD, )) browser.open(self.portal['f1'].absolute_url()) self.assertEqual('plone.content.folderView', browser.headers['X-Cache-Rule']) self.assertEqual('plone.app.caching.weakCaching', browser.headers['X-Cache-Operation']) # This should use cacheInBrowser self.assertEqual('max-age=0, must-revalidate, private', browser.headers['Cache-Control']) self.assertEqual( '"|test_user_1_|%d|en|0|%s|0|0' % (catalog.getCounter(), skins_tool.default_skin), _normalize_etag(browser.headers['ETag'])) self.assertTrue( now > dateutil.parser.parse(browser.headers['Expires'])) # Set the copy/cut cookie and then request the folder view again browser.cookies.create('__cp', 'xxx') browser.open(self.portal['f1'].absolute_url()) # The response should be the same as before except for the etag self.assertEqual('plone.content.folderView', browser.headers['X-Cache-Rule']) self.assertEqual('plone.app.caching.weakCaching', browser.headers['X-Cache-Operation']) self.assertEqual('max-age=0, must-revalidate, private', browser.headers['Cache-Control']) self.assertEqual( '"|test_user_1_|%d|en|0|%s|0|1' % (catalog.getCounter(), skins_tool.default_skin), _normalize_etag(browser.headers['ETag'])) # Request the authenticated page now = stable_now() browser = Browser(self.app) browser.addHeader( 'Authorization', 'Basic %s:%s' % ( TEST_USER_NAME, TEST_USER_PASSWORD, )) browser.open(self.portal['f1']['d1'].absolute_url()) self.assertTrue(testText in browser.contents) self.assertEqual('plone.content.itemView', browser.headers['X-Cache-Rule']) self.assertEqual('plone.app.caching.weakCaching', browser.headers['X-Cache-Operation']) # This should use cacheInBrowser self.assertEqual('max-age=0, must-revalidate, private', browser.headers['Cache-Control']) self.assertEqual( '"|test_user_1_|%d|en|0|%s|0' % (catalog.getCounter(), skins_tool.default_skin), _normalize_etag(browser.headers['ETag'])) self.assertTrue( now > dateutil.parser.parse(browser.headers['Expires'])) # Request the authenticated page again -- to test RAM cache. browser = Browser(self.app) browser.addHeader( 'Authorization', 'Basic %s:%s' % ( TEST_USER_NAME, TEST_USER_PASSWORD, )) browser.open(self.portal['f1']['d1'].absolute_url()) self.assertEqual('plone.content.itemView', browser.headers['X-Cache-Rule']) self.assertEqual('plone.app.caching.weakCaching', browser.headers['X-Cache-Operation']) # Authenticated should NOT be RAM cached self.assertEqual(None, browser.headers.get('X-RAMCache')) # Request the authenticated page again -- with an INM header to test 304 etag = browser.headers['ETag'] browser = Browser(self.app) browser.raiseHttpErrors = False # we really do want to see the 304 browser.addHeader( 'Authorization', 'Basic %s:%s' % ( TEST_USER_NAME, TEST_USER_PASSWORD, )) browser.addHeader('If-None-Match', etag) browser.open(self.portal['f1']['d1'].absolute_url()) # This should be a 304 response self.assertEqual('304 Not Modified', browser.headers['Status']) self.assertEqual('', browser.contents) # Request the anonymous folder now = stable_now() browser = Browser(self.app) browser.open(self.portal['f1'].absolute_url()) self.assertEqual('plone.content.folderView', browser.headers['X-Cache-Rule']) self.assertEqual('plone.app.caching.weakCaching', browser.headers['X-Cache-Operation']) # This should use cacheInBrowser self.assertEqual('max-age=0, must-revalidate, private', browser.headers['Cache-Control']) self.assertEqual( '"||%d|en|0|%s|0|0' % (catalog.getCounter(), skins_tool.default_skin), _normalize_etag(browser.headers['ETag'])) self.assertTrue( now > dateutil.parser.parse(browser.headers['Expires'])) # Request the anonymous page now = stable_now() browser = Browser(self.app) browser.open(self.portal['f1']['d1'].absolute_url()) self.assertEqual('plone.content.itemView', browser.headers['X-Cache-Rule']) self.assertEqual('plone.app.caching.weakCaching', browser.headers['X-Cache-Operation']) self.assertTrue(testText in browser.contents) # This should use cacheInBrowser self.assertEqual('max-age=0, must-revalidate, private', browser.headers['Cache-Control']) self.assertEqual( '"||%d|en|0|%s|0' % (catalog.getCounter(), skins_tool.default_skin), _normalize_etag(browser.headers['ETag'])) self.assertTrue( now > dateutil.parser.parse(browser.headers['Expires'])) # Request the anonymous page again -- to test RAM cache. # Anonymous should be RAM cached now = stable_now() browser = Browser(self.app) browser.open(self.portal['f1']['d1'].absolute_url()) self.assertEqual('plone.content.itemView', browser.headers['X-Cache-Rule']) self.assertEqual('plone.app.caching.weakCaching', browser.headers['X-Cache-Operation']) # This should come from RAM cache self.assertEqual('plone.app.caching.operations.ramcache', browser.headers['X-RAMCache']) self.assertTrue(testText in browser.contents) self.assertEqual('max-age=0, must-revalidate, private', browser.headers['Cache-Control']) self.assertEqual( '"||%d|en|0|%s|0' % (catalog.getCounter(), skins_tool.default_skin), _normalize_etag(browser.headers['ETag'])) self.assertTrue( now > dateutil.parser.parse(browser.headers['Expires'])) # Request the anonymous page again -- with an INM header to test 304. etag = browser.headers['ETag'] browser = Browser(self.app) browser.raiseHttpErrors = False browser.addHeader('If-None-Match', etag) browser.open(self.portal['f1']['d1'].absolute_url()) self.assertEqual('plone.content.itemView', browser.headers['X-Cache-Rule']) self.assertEqual('plone.app.caching.weakCaching', browser.headers['X-Cache-Operation']) # This should be a 304 response self.assertEqual('304 Not Modified', browser.headers['Status']) self.assertEqual('', browser.contents) # Edit the page to update the etag testText2 = "Testing... body two" self.portal['f1']['d1'].text = RichTextValue(testText2, 'text/plain', 'text/html') self.portal['f1']['d1'].reindexObject() import transaction transaction.commit() # Request the anonymous page again -- to test expiration of 304 and RAM. etag = browser.headers['ETag'] browser = Browser(self.app) browser.addHeader('If-None-Match', etag) browser.open(self.portal['f1']['d1'].absolute_url()) self.assertEqual('plone.content.itemView', browser.headers['X-Cache-Rule']) self.assertEqual('plone.app.caching.weakCaching', browser.headers['X-Cache-Operation']) # The etag has changed so we should get a fresh page. self.assertEqual(None, browser.headers.get('X-RAMCache')) self.assertEqual('200 Ok', browser.headers['Status'])
def setUp(self): self.portal = self.layer['portal'] setRoles(self.portal, TEST_USER_ID, ['Manager']) api.content.create(self.portal, 'Folder', 'other-folder') api.content.create(self.portal, 'Collection', 'my-collection')
def test_content_feeds(self): catalog = self.portal['portal_catalog'] skins_tool = self.portal['portal_skins'] # Enable syndication setRoles(self.portal, TEST_USER_ID, ('Manager', )) self.syndication = getToolByName(self.portal, 'portal_syndication') self.syndication.editProperties(isAllowed=True) self.syndication.enableSyndication(self.portal) import transaction transaction.commit() # Request the rss feed now = stable_now() browser = Browser(self.app) browser.open(self.portal.absolute_url() + '/RSS') self.assertEqual('plone.content.feed', browser.headers['X-Cache-Rule']) self.assertEqual('plone.app.caching.moderateCaching', browser.headers['X-Cache-Operation']) # This should use cacheInProxy self.assertEqual('max-age=0, s-maxage=86400, must-revalidate', browser.headers['Cache-Control']) self.assertEqual( '"||%d|en|0|%s"' % (catalog.getCounter(), skins_tool.default_skin), browser.headers['ETag']) self.assertTrue( now > dateutil.parser.parse(browser.headers['Expires'])) # Request the rss feed again -- to test RAM cache now = stable_now() rssText = browser.contents browser = Browser(self.app) browser.open(self.portal.absolute_url() + '/RSS') self.assertEqual('plone.content.feed', browser.headers['X-Cache-Rule']) self.assertEqual('plone.app.caching.moderateCaching', browser.headers['X-Cache-Operation']) # This should come from the RAM cache self.assertEqual('plone.app.caching.operations.ramcache', browser.headers['X-RAMCache']) self.assertEqual(rssText, browser.contents) self.assertEqual('max-age=0, s-maxage=86400, must-revalidate', browser.headers['Cache-Control']) self.assertEqual( '"||%d|en|0|%s"' % (catalog.getCounter(), skins_tool.default_skin), browser.headers['ETag']) self.assertTrue( now > dateutil.parser.parse(browser.headers['Expires'])) # Request the rss feed again -- with an INM header to test 304. etag = browser.headers['ETag'] browser = Browser(self.app) browser.raiseHttpErrors = False browser.addHeader('If-None-Match', etag) browser.open(self.portal.absolute_url() + '/RSS') self.assertEqual('plone.content.feed', browser.headers['X-Cache-Rule']) self.assertEqual('plone.app.caching.moderateCaching', browser.headers['X-Cache-Operation']) # This should be a 304 response self.assertEqual('304 Not Modified', browser.headers['Status']) self.assertEqual('', browser.contents) # Request the authenticated rss feed now = stable_now() browser = Browser(self.app) browser.addHeader( 'Authorization', 'Basic %s:%s' % ( TEST_USER_NAME, TEST_USER_PASSWORD, )) browser.open(self.portal.absolute_url() + '/RSS') self.assertEqual('plone.content.feed', browser.headers['X-Cache-Rule']) self.assertEqual('plone.app.caching.moderateCaching', browser.headers['X-Cache-Operation']) # This should use cacheInBrowser self.assertEqual('max-age=0, must-revalidate, private', browser.headers['Cache-Control']) self.assertEqual( '"|test_user_1_|%d|en|0|%s"' % (catalog.getCounter(), skins_tool.default_skin), browser.headers['ETag']) self.assertTrue( now > dateutil.parser.parse(browser.headers['Expires'])) # Request the authenticated rss feed again -- to test RAM cache browser = Browser(self.app) browser.addHeader( 'Authorization', 'Basic %s:%s' % ( TEST_USER_NAME, TEST_USER_PASSWORD, )) browser.open(self.portal.absolute_url() + '/RSS') self.assertEqual('plone.content.feed', browser.headers['X-Cache-Rule']) self.assertEqual('plone.app.caching.moderateCaching', browser.headers['X-Cache-Operation']) # Authenticated should NOT be RAM cached self.assertEqual(None, browser.headers.get('X-RAMCache'))
def afterSetUp(self): setRoles(self.portal, TEST_USER_ID, ['Manager'])
def tearDown(self): setRoles(self.portal, TEST_USER_ID, ['Member']) from plone.protect import auto auto.CSRF_DISABLED = False
def test_content_files(self): # Add folder content setRoles(self.portal, TEST_USER_ID, ('Manager', )) self.portal.invokeFactory('Folder', 'f1') self.portal['f1'].title = u"Folder one" self.portal['f1'].description = u"Folder one description" self.portal['f1'].reindexObject() # Add content image self.portal['f1'].invokeFactory('Image', 'i1') self.portal['f1']['i1'].title = u"Image one" self.portal['f1']['i1'].description = u"Image one description" self.portal['f1']['i1'].image = test_image() self.portal['f1']['i1'].reindexObject() import transaction transaction.commit() # Request the image with Manager role now = stable_now() browser = Browser(self.app) browser.addHeader( 'Authorization', 'Basic %s:%s' % ( SITE_OWNER_NAME, SITE_OWNER_PASSWORD, )) browser.open(self.portal['f1']['i1'].absolute_url()) self.assertEqual('plone.content.file', browser.headers['X-Cache-Rule']) self.assertEqual('plone.app.caching.moderateCaching', browser.headers['X-Cache-Operation']) # Folder not published yet so image should not be cached in proxy # so this should use cacheInBrowser self.assertEqual('max-age=0, must-revalidate, private', browser.headers['Cache-Control']) self.assertFalse(None == browser.headers.get( 'Last-Modified')) # remove this when the next line works #self.assertEqual('---lastmodified---', browser.headers['Last-Modified']) self.assertTrue( now > dateutil.parser.parse(browser.headers['Expires'])) # Request an image scale with Manager role now = stable_now() browser = Browser(self.app) browser.addHeader( 'Authorization', 'Basic %s:%s' % ( SITE_OWNER_NAME, SITE_OWNER_PASSWORD, )) browser.open(self.portal['f1']['i1'].absolute_url() + '/@@images/image/preview') self.assertEqual('plone.content.file', browser.headers['X-Cache-Rule']) self.assertEqual('plone.app.caching.moderateCaching', browser.headers['X-Cache-Operation']) # Folder not published yet so image scale should not be cached in proxy # so this should use cacheInBrowser self.assertEqual('max-age=0, must-revalidate, private', browser.headers['Cache-Control']) self.assertFalse(None == browser.headers.get( 'Last-Modified')) # remove this when the next line works #self.assertEqual('---lastmodified---', browser.headers['Last-Modified']) self.assertTrue( now > dateutil.parser.parse(browser.headers['Expires'])) # Publish the folder self.portal.portal_workflow.doActionFor(self.portal['f1'], 'publish') import transaction transaction.commit() # Request the image now = stable_now() browser = Browser(self.app) browser.open(self.portal['f1']['i1'].absolute_url()) self.assertEqual('plone.content.file', browser.headers['X-Cache-Rule']) self.assertEqual('plone.app.caching.moderateCaching', browser.headers['X-Cache-Operation']) # Now visible to anonymous so this should use cacheInProxy self.assertEqual('max-age=0, s-maxage=86400, must-revalidate', browser.headers['Cache-Control']) self.assertFalse(None == browser.headers.get( 'Last-Modified')) # remove this when the next line works #self.assertEqual('---lastmodified---', browser.headers['Last-Modified']) self.assertTrue( now > dateutil.parser.parse(browser.headers['Expires'])) # Request the image again -- with an IMS header to test 304 lastmodified = browser.headers['Last-Modified'] browser = Browser(self.app) browser.raiseHttpErrors = False browser.addHeader('If-Modified-Since', lastmodified) browser.open(self.portal['f1']['i1'].absolute_url()) self.assertEqual('plone.content.file', browser.headers['X-Cache-Rule']) self.assertEqual('plone.app.caching.moderateCaching', browser.headers['X-Cache-Operation']) # This should be a 304 response self.assertEqual('304 Not Modified', browser.headers['Status']) self.assertEqual('', browser.contents) # Request an image scale now = stable_now() browser = Browser(self.app) browser.open(self.portal['f1']['i1'].absolute_url() + '/@@images/image/preview') self.assertEqual('plone.content.file', browser.headers['X-Cache-Rule']) self.assertEqual('plone.app.caching.moderateCaching', browser.headers['X-Cache-Operation']) # Now visible to anonymous so this should use cacheInProxy self.assertEqual('max-age=0, s-maxage=86400, must-revalidate', browser.headers['Cache-Control']) self.assertFalse(None == browser.headers.get( 'Last-Modified')) # remove this when the next line works #self.assertEqual('---lastmodified---', browser.headers['Last-Modified']) self.assertTrue( now > dateutil.parser.parse(browser.headers['Expires']))