Esempio n. 1
0
    def bookmarks_overrides(self, fixture):
        """Various bits of information can be overridden from the defaults when creating a bookmark from a View.
        """
        user_interface = UserInterface(None, '/a_ui', {}, False, 'test_ui')
        view = UrlBoundView(user_interface, '/aview', 'A View title', {})
        bookmark = view.as_bookmark(description='different description',
                                    query_arguments={'arg1': 'val1'},
                                    locale='af')

        # What the bookmark knows
        vassert(bookmark.description == 'different description')
        vassert(bookmark.query_arguments == {'arg1': 'val1'})
        vassert(bookmark.locale == 'af')
Esempio n. 2
0
    def bookmarks(self, fixture):
        """Bookmarks are pointers to Views. You need them, because Views are relative to a UserInterface and
           a Bookmark can, at run time, turn these into absolute URLs. Bookmarks also contain metadata,
           such as the title of the View it points to.
        """
        user_interface = UserInterface(None, '/a_ui', {}, False, 'test_ui')
        view = UrlBoundView(user_interface, '/aview', 'A View title', {})
        bookmark = view.as_bookmark()

        # What the bookmark knows
        vassert(bookmark.href.path == '/a_ui/aview')
        vassert(bookmark.description == 'A View title')
        vassert(bookmark.base_path == '/a_ui')
        vassert(bookmark.relative_path == '/aview')

        # How you would use a bookmark in other views (possibly in other UserInterfaces)
        a = A.from_bookmark(fixture.view, bookmark)
        vassert(str(a.href) == str(bookmark.href))
Esempio n. 3
0
 def new_user_interface(self):
     """A :class:`UserInterface` for testing."""
     return UserInterface(None, '/', {}, False, 'test_ui')
Esempio n. 4
0
 def new_user_interface_factory(self):
     factory = UserInterface.factory('test_user_interface_name')
     factory.attach_to('/', {})
     return factory
Esempio n. 5
0
 def new_user_interface(self):
     return UserInterface(None, '/', {}, False, 'test_ui')