def testResource(self): self.assertEqual( zapi.queryMultiAdapter((ob, request), name='zmi_icon'), None) import zope.app.publisher.browser.tests as p path = os.path.dirname(p.__file__) path = os.path.join(path, 'testfiles', 'test.gif') xmlconfig(StringIO(template % ( ''' <browser:resource name="zmi_icon_res" image="%s" /> <browser:icon name="zmi_icon" for="zope.app.component.tests.views.IC" resource="zmi_icon_res" /> ''' % path ))) view = zapi.getMultiAdapter((ob, request), name='zmi_icon') rname = "zmi_icon_res" self.assertEqual( view(), '<img src="http://127.0.0.1/@@/%s" alt="IC" width="16" ' 'height="16" border="0" />' % rname) resource = ProxyFactory(zapi.getAdapter(request, name=rname)) self.assertRaises(Forbidden, getattr, resource, '_testData') resource = removeSecurityProxy(resource) self.assertEqual(resource._testData(), open(path, 'rb').read())
def testResource(self): self.assertEqual( component.queryMultiAdapter((ob, request), name='zmi_icon'), None) import zope.app.publisher.browser.tests as p path = os.path.dirname(p.__file__) path = os.path.join(path, 'testfiles', 'test.gif') xmlconfig( StringIO(template % (''' <browser:resource name="zmi_icon_res" image="%s" /> <browser:icon name="zmi_icon" for="zope.app.component.tests.views.IC" resource="zmi_icon_res" /> ''' % path))) view = component.getMultiAdapter((ob, request), name='zmi_icon') rname = "zmi_icon_res" self.assertEqual( view(), '<img src="http://127.0.0.1/@@/%s" alt="IC" width="16" ' 'height="16" border="0" />' % rname) resource = ProxyFactory(component.getAdapter(request, name=rname)) self.assertRaises(Forbidden, getattr, resource, '_testData') resource = removeSecurityProxy(resource) self.assertEqual(resource._testData(), open(path, 'rb').read())
def test(self): self.assertEqual( component.queryMultiAdapter((ob, request), name='zmi_icon'), None) import zope.app.publisher.browser.tests as p path = os.path.dirname(p.__file__) path = os.path.join(path, 'testfiles', 'test.gif') # Configure the icon and make sure we can render the resulting view: xmlconfig( StringIO(template % (''' <browser:icon name="zmi_icon" for="zope.app.component.tests.views.IC" file="%s" /> ''' % path))) view = component.getMultiAdapter((ob, request), name='zmi_icon') rname = 'zope-app-component-tests-views-IC-zmi_icon.gif' self.assertEqual( view(), '<img src="http://127.0.0.1/@@/%s" alt="IC" ' 'width="16" height="16" border="0" />' % rname) # Make sure that the title attribute works xmlconfig( StringIO(template % (''' <browser:icon name="zmi_icon_w_title" for="zope.app.component.tests.views.IC" file="%s" title="click this!" /> ''' % path))) view = component.getMultiAdapter((ob, request), name='zmi_icon_w_title') rname = 'zope-app-component-tests-views-IC-zmi_icon_w_title.gif' self.assertEqual( view(), '<img src="http://127.0.0.1/@@/%s" alt="click this!" ' 'width="16" height="16" border="0" />' % rname) # Make sure that the width and height attributes work xmlconfig( StringIO(template % (''' <browser:icon name="zmi_icon_w_width_and_height" for="zope.app.component.tests.views.IC" file="%s" width="20" height="12" /> ''' % path))) view = component.getMultiAdapter((ob, request), name='zmi_icon_w_width_and_height') rname = ('zope-app-component-tests-views-IC-' 'zmi_icon_w_width_and_height.gif') self.assertEqual( view(), '<img src="http://127.0.0.1/@@/%s" alt="IC" ' 'width="20" height="12" border="0" />' % rname) # Make sure that the image was installed as a resource: resource = ProxyFactory(component.getAdapter(request, name=rname)) self.assertRaises(Forbidden, getattr, resource, '_testData') resource = removeSecurityProxy(resource) self.assertEqual(resource._testData(), open(path, 'rb').read())
def test(self): self.assertEqual( component.queryMultiAdapter((ob, request), name='zmi_icon'), None) import zope.browserresource.tests as p path = os.path.dirname(p.__file__) path = os.path.join(path, 'testfiles', 'test.gif') # Configure the icon and make sure we can render the resulting view: xmlconfig(StringIO(template % ( ''' <browser:icon name="zmi_icon" for="zope.component.testfiles.views.IC" file="%s" /> ''' % path ))) view = component.getMultiAdapter((ob, request), name='zmi_icon') rname = 'zope-component-testfiles-views-IC-zmi_icon.gif' self.assertEqual( view(), '<img src="http://127.0.0.1/@@/%s" alt="C" ' 'width="16" height="16" border="0" />' % rname) self.assertEqual(view.url(), 'http://127.0.0.1/@@/' + rname) # Make sure that the title attribute works xmlconfig(StringIO(template % ( ''' <browser:icon name="zmi_icon_w_title" for="zope.component.testfiles.views.IC" file="%s" title="click this!" /> ''' % path ))) view = component.getMultiAdapter( (ob, request), name='zmi_icon_w_title') rname = 'zope-component-testfiles-views-IC-zmi_icon_w_title.gif' self.assertEqual( view(), '<img src="http://127.0.0.1/@@/%s" alt="click this!" ' 'width="16" height="16" border="0" />' % rname) # Make sure that the width and height attributes work xmlconfig(StringIO(template % ( ''' <browser:icon name="zmi_icon_w_width_and_height" for="zope.component.testfiles.views.IC" file="%s" width="20" height="12" /> ''' % path ))) view = component.getMultiAdapter((ob, request), name='zmi_icon_w_width_and_height') rname = ('zope-component-testfiles-views-IC-' 'zmi_icon_w_width_and_height.gif') self.assertEqual( view(), '<img src="http://127.0.0.1/@@/%s" alt="C" ' 'width="20" height="12" border="0" />' % rname) # Make sure that the image was installed as a resource: resource = ProxyFactory(component.getAdapter(request, name=rname)) self.assertRaises(Forbidden, getattr, resource, '_testData') resource = removeSecurityProxy(resource) self.assertEqual(resource._testData(), open(path, 'rb').read())