예제 #1
0
 def test_locateChildPreservesQueryArguments(self):
     """
     L{LoginPage.locateChild} should create a new L{LoginPage} with query
     arguments extracted from the traversal context.
     """
     self.request.args = {'foo': ['bar']}
     page = LoginPage(self.siteStore)
     child, remaining = page.locateChild(self.context, None)
     self.assertTrue(isinstance(child, LoginPage))
     self.assertEqual(child.arguments, self.request.args)
예제 #2
0
 def test_locateChildPreservesQueryArguments(self):
     """
     L{LoginPage.locateChild} should create a new L{LoginPage} with query
     arguments extracted from the traversal context.
     """
     self.request.args = {'foo': ['bar']}
     page = LoginPage(self.siteStore)
     child, remaining = page.locateChild(self.context, None)
     self.assertTrue(isinstance(child, LoginPage))
     self.assertEqual(child.arguments, self.request.args)
예제 #3
0
 def test_locateChildPreservesSegments(self):
     """
     L{LoginPage.locateChild} should create a new L{LoginPage} with segments
     extracted from the traversal context.
     """
     segments = ('foo', 'bar')
     page = LoginPage(self.siteStore)
     child, remaining = page.locateChild(self.context, segments)
     self.assertTrue(isinstance(child, LoginPage))
     self.assertEqual(remaining, ())
     self.assertEqual(child.segments, segments)
예제 #4
0
 def test_locateChildPreservesSegments(self):
     """
     L{LoginPage.locateChild} should create a new L{LoginPage} with segments
     extracted from the traversal context.
     """
     segments = ('foo', 'bar')
     page = LoginPage(self.siteStore)
     child, remaining = page.locateChild(self.context, segments)
     self.assertTrue(isinstance(child, LoginPage))
     self.assertEqual(remaining, ())
     self.assertEqual(child.segments, segments)
예제 #5
0
 def test_segments(self):
     """
     L{LoginPage.beforeRender} should fill the I{login-action} slot with an
     L{URL} which includes all the segments given to the L{LoginPage}.
     """
     segments = ('foo', 'bar')
     page = LoginPage(self.siteStore, segments)
     page.beforeRender(self.context)
     loginAction = self.context.locateSlotData('login-action')
     expectedLocation = URL.fromString('/')
     for segment in (LOGIN_AVATAR, ) + segments:
         expectedLocation = expectedLocation.child(segment)
     self.assertEqual(loginAction, expectedLocation)
예제 #6
0
 def test_segments(self):
     """
     L{LoginPage.beforeRender} should fill the I{login-action} slot with an
     L{URL} which includes all the segments given to the L{LoginPage}.
     """
     segments = ('foo', 'bar')
     page = LoginPage(self.siteStore, segments)
     page.beforeRender(self.context)
     loginAction = self.context.locateSlotData('login-action')
     expectedLocation = URL.fromString('/')
     for segment in (LOGIN_AVATAR,) + segments:
         expectedLocation = expectedLocation.child(segment)
     self.assertEqual(loginAction, expectedLocation)
예제 #7
0
 def test_queryArguments(self):
     """
     L{LoginPage.beforeRender} should fill the I{login-action} slot with an
     L{URL} which includes all the query arguments given to the
     L{LoginPage}.
     """
     args = {'foo': ['bar']}
     page = LoginPage(self.siteStore, (), args)
     page.beforeRender(self.context)
     loginAction = self.context.locateSlotData('login-action')
     expectedLocation = URL.fromString('/')
     expectedLocation = expectedLocation.child(LOGIN_AVATAR)
     expectedLocation = expectedLocation.add('foo', 'bar')
     self.assertEqual(loginAction, expectedLocation)
예제 #8
0
 def test_queryArguments(self):
     """
     L{LoginPage.beforeRender} should fill the I{login-action} slot with an
     L{URL} which includes all the query arguments given to the
     L{LoginPage}.
     """
     args = {'foo': ['bar']}
     page = LoginPage(self.siteStore, (), args)
     page.beforeRender(self.context)
     loginAction = self.context.locateSlotData('login-action')
     expectedLocation = URL.fromString('/')
     expectedLocation = expectedLocation.child(LOGIN_AVATAR)
     expectedLocation = expectedLocation.add('foo', 'bar')
     self.assertEqual(loginAction, expectedLocation)
예제 #9
0
 def test_loginPageLoader(self):
     """
     L{LoginPage.fragment} is the I{login} template loaded from the store's
     ITemplateNameResolver.
     """
     self.fakeResolver.correctName = 'login'
     page = LoginPage(self.store)
     self.assertIdentical(page.fragment, self.correctDocumentFactory)
예제 #10
0
 def child_post(self, ctx):
     """
     If the user is authorized, return a L{BlurbPostingResource}
     """
     store = sharing.itemFromProxy(self.original).store
     if ihyperbola.ICommentable.providedBy(self.original):
         return BlurbPostingResource(
             store, self.original, self.customizedFor)
     return LoginPage.fromRequest(store.parent, inevow.IRequest(ctx))
예제 #11
0
    def test_staticShellContent(self):
        """
        The L{IStaticShellContent} adapter for the C{store} argument to
        L{LoginPage.__init__} should become its C{staticContent} attribute.
        """
        originalInterface = publicweb.IStaticShellContent
        adaptions = []
        result = object()

        def stubInterface(object, default):
            adaptions.append((object, default))
            return result

        publicweb.IStaticShellContent = stubInterface
        try:
            page = LoginPage(self.siteStore)
        finally:
            publicweb.IStaticShellContent = originalInterface
        self.assertEqual(len(adaptions), 1)
        self.assertIdentical(adaptions[0][0], self.siteStore)
        self.assertIdentical(page.staticContent, result)