Ejemplo n.º 1
0
    def test_getJSModuleURL(self):
        """
        L{MantissaLivePage.getJSModuleURL} should return a child of its
        C{_moduleRoot} attribute of the form::

            _moduleRoot/<SHA1 digest of module contents>/Package.ModuleName
        """
        module = 'Mantissa'
        url = URL(scheme='https', netloc='example.com', pathsegs=['foo'])
        page = MantissaLivePage(None)
        page._moduleRoot = url
        jsDir = FilePath(__file__).parent().parent().child("js")
        modulePath = jsDir.child(module).child("__init__.js")
        moduleContents = modulePath.open().read()
        expect = sha.new(moduleContents).hexdigest()
        self.assertEqual(page.getJSModuleURL(module),
                         url.child(expect).child(module))
Ejemplo n.º 2
0
    def test_getJSModuleURL(self):
        """
        L{MantissaLivePage.getJSModuleURL} should return a child of its
        C{_moduleRoot} attribute of the form::

            _moduleRoot/<SHA1 digest of module contents>/Package.ModuleName
        """
        module = 'Mantissa'
        url = URL(scheme='https', netloc='example.com', pathsegs=['foo'])
        page = MantissaLivePage(None)
        page._moduleRoot = url
        jsDir = FilePath(__file__).parent().parent().child("js")
        modulePath = jsDir.child(module).child("__init__.js")
        moduleContents = modulePath.open().read()
        expect = sha1(moduleContents).hexdigest()
        self.assertEqual(page.getJSModuleURL(module),
                         url.child(expect).child(module))
Ejemplo n.º 3
0
 def test_beforeRenderSetsModuleRoot(self):
     """
     L{MantissaLivePage.beforeRender} should set I{_moduleRoot} to the
     C{__jsmodule__} child of the URL returned by the I{rootURL}
     method of the L{WebSite} it wraps.
     """
     receivedRequests = []
     root = URL(netloc='example.com', pathsegs=['a', 'b'])
     class FakeWebSite(object):
         def rootURL(self, request):
             receivedRequests.append(request)
             return root
     request = FakeRequest()
     page = MantissaLivePage(FakeWebSite())
     page.beforeRender(request)
     self.assertEqual(receivedRequests, [request])
     self.assertEqual(page._moduleRoot, root.child('__jsmodule__'))
Ejemplo n.º 4
0
    def test_beforeRenderSetsModuleRoot(self):
        """
        L{MantissaLivePage.beforeRender} should set I{_moduleRoot} to the
        C{__jsmodule__} child of the URL returned by the I{rootURL}
        method of the L{WebSite} it wraps.
        """
        receivedRequests = []
        root = URL(netloc='example.com', pathsegs=['a', 'b'])

        class FakeWebSite(object):
            def rootURL(self, request):
                receivedRequests.append(request)
                return root

        request = FakeRequest()
        page = MantissaLivePage(FakeWebSite())
        page.beforeRender(request)
        self.assertEqual(receivedRequests, [request])
        self.assertEqual(page._moduleRoot, root.child('__jsmodule__'))