Hi.<div><br></div><div>I want to do some integration testing with gocept.selenium. I've ran into some problems with fanstatic resources. I tought it was something to do with the testing layers of gocept.selenium, but I layed out a test with zope.testbrowser and even though fanstatic resources are being injected, when I command zope.testbrowser to GET the resource, the result is a HTTP 404.</div>
<div><br></div><div>Why cannot fanstatic work fully on integration tests?</div><div><br></div><div>Here's the code of my test:</div><div><br></div><div>-----</div><div><div>import unittest</div><div><br></div><div>#ZTK & Grok</div>
<div>import transaction</div><div>from zope.app.wsgi.testlayer import Browser</div><div>from zope.component import getGlobalSiteManager</div><div>from zope.publisher.interfaces.browser import IBrowserRequest</div><div>from zope.interface import Interface</div>
<div><br></div><div>#Fanstatic imports</div><div>import fanstatic</div><div>from zope.fanstatic.testing import ZopeFanstaticBrowserLayer</div><div>from zope.fanstatic.zcml import create_factory</div><div><br></div><div>#tzicatl namespace</div>
<div>from tzicatl.testselenium.resource import library</div><div>import tzicatl.testselenium</div><div>from tzicatl.testselenium.app import SampleApplication</div><div><br></div><div>class TestLayerWithInjector(ZopeFanstaticBrowserLayer):</div>
<div> def testSetup(self):</div><div> super(TestLayerWithInjector, self).testSetup()</div><div> #Because is difficult to dynamically register an entry_point in tests,</div><div> #we do the setup by hand.</div>
<div> resource_factory = create_factory(style)</div><div> gsm = getGlobalSiteManager()</div><div> gsm.registerAdapter(</div><div> resource_factory,</div><div> (IBrowserRequest, ),</div>
<div> Interface,</div><div> <a href="http://library.name">library.name</a></div><div> )</div><div><br></div><div>layer_with_fanstatic_injector = TestLayerWithInjector(</div><div> tzicatl.testselenium.tests</div>
<div>)</div><div> </div><div>class SeleniumWithZopeTestBrowser(unittest.TestCase):</div><div> layer = layer_with_fanstatic_injector</div><div> </div><div> def test_open_index(self):</div><div> browser = Browser()</div>
<div> browser.open('<a href="http://localhost/@@mygenericview">http://localhost/@@mygenericview</a>')</div><div> self.assertIn('Welcome to my sample application', browser.contents)</div><div>
self.assertIn('<a href="http://localhost/fanstatic/tzicatl.testselenium/style.css">http://localhost/fanstatic/tzicatl.testselenium/style.css</a>',</div><div> browser.contents)</div><div>
</div><div> def test_open_fanstatic_resource(self):</div><div> browser = Browser()</div><div> browser.open('<a href="http://localhost/fanstatic/tzicatl.testselenium/style.css">http://localhost/fanstatic/tzicatl.testselenium/style.css</a>')</div>
<div> self.assertFalse(browser.isHtml)</div><div> self.assertEqual(browser.headers['content-type'], 'text/css')</div><div> </div></div><div><br></div><div><br></div><div>-- <br><span style="color:rgb(255,204,102)">---</span><br>
<span style="color:rgb(204,153,51)">Noe Nieto</span><br>
NNieto Consulting Services<br>
M: <a href="mailto:nnieto@noenieto.com" target="_blank">nnieto@noenieto.com</a><br>
W: <a href="http://noenieto.com" target="_blank">http://noenieto.com</a><br>
T: <a href="https://twitter.com/#%21/tzicatl" target="_blank">@tzicatl</a><br>Li: <a href="http://www.linkedin.com/profile/view?id=84300665" target="_blank">Perfil en LinkedIn</a><br><br>
</div>