def test_01_package_page(self): query = model.Session.query(model.Package) page = AlphaPage( collection=query, alpha_attribute='title', page='A', other_text=other, ) pager = page.pager() assert_true( pager.startswith('<div class="pagination pagination-alphabet">'), pager) assert_in('<li class="active"><a href="/tag?page=A">A</a></li>', pager, pager) assert_true( re.search(r'\<li\>\<a href="\/tag\?page=B"\>B\<\/a\>\<\/li\>', pager), pager) assert_true( re.search( r'\<li class="disabled"\>\<a href="\/tag\?page=E"\>E' r'\<\/a\>\<\/li\>', pager), pager) assert_true( re.search( r'\<li\>\<a href="\/tag\?page=Other"\>Other\<\/a\>\<\/li\>', pager), pager)
def test_01_package_page(self): query = model.Session.query(model.Package) page = AlphaPage( collection=query, alpha_attribute='title', page='A', other_text=other, ) pager = page.pager() assert not pager
def index(self): c.q = request.params.get('q', '') context = {'model': model, 'session': model.Session, 'user': c.user, 'auth_user_obj': c.userobj, 'for_view': True} data_dict = {'all_fields': True} if c.q: page = h.get_page_number(request.params) data_dict['q'] = c.q data_dict['limit'] = LIMIT data_dict['offset'] = (page - 1) * LIMIT data_dict['return_objects'] = True results = logic.get_action('tag_list')(context, data_dict) if c.q: c.page = h.Page( collection=results, page=page, item_count=len(results), items_per_page=LIMIT ) c.page.items = results else: c.page = AlphaPage( collection=results, page=request.params.get('page', 'A'), alpha_attribute='name', other_text=_('Other'), ) return base.render('tag/index.html')
def index(self): context = {'model': model, 'session': model.Session, 'user': c.user or c.author} data_dict = {'all_fields': True} try: check_access('site_read', context) except NotAuthorized: abort(401, _('Not authorized to see this page')) # TODO: Fix this up, we only really need to do this when we are # showing the hierarchy (and then we should load on demand really). c.all_groups = model.Session.query(model.Group).\ filter(model.Group.type == 'publisher').\ filter(model.Group.state == 'active').\ order_by('title') c.page = AlphaPage( controller_name="ckanext.dgu.controllers.publisher:PublisherController", collection=c.all_groups, page=request.params.get('page', 'A'), alpha_attribute='title', other_text=_('Other'), ) return render('publisher/index.html')
def test_04_count(self): query = model.Session.query(model.Package) page = AlphaPage( collection=query, alpha_attribute='title', page=other, other_text=other, ) assert page.item_count == self.num_pkgs, page.item_count
def test_02_package_items(self): query = model.Session.query(model.Package) page = AlphaPage( collection=query, alpha_attribute='title', page='B', other_text=other, ) items = page.items assert len(items) == self.num_pkgs, items
def test_01_package_page(self): query = model.Session.query(model.Package) page = AlphaPage( collection=query, alpha_attribute='title', page='A', other_text=other, ) pager = page.pager() assert_true( pager.startswith( '<div class="pagination pagination-alphabet">' ), pager ) assert_in( '<li class="active"><a href="/tag?page=A">A</a></li>', pager, pager ) assert_true( re.search( r'\<li\>\<a href="\/tag\?page=B"\>B\<\/a\>\<\/li\>', pager ), pager ) assert_true( re.search( r'\<li class="disabled"\>\<a href="\/tag\?page=E"\>E' r'\<\/a\>\<\/li\>', pager ), pager ) assert_true( re.search( r'\<li\>\<a href="\/tag\?page=Other"\>Other\<\/a\>\<\/li\>', pager ), pager )
def test_02_package_items(self): query = model.Session.query(model.Package) page = AlphaPage( collection=query, alpha_attribute='title', page='B', other_text=other, ) items = page.items assert len(items) == 10, items for item in items: assert item.title.startswith('b'), item.title
def test_03_package_other_items(self): query = model.Session.query(model.Package) page = AlphaPage( collection=query, alpha_attribute='title', page=other, other_text=other, ) items = page.items assert len(items) == 20, [item.title for item in items] for item in items: assert_true( item.title.startswith('1') or item.title.startswith('2'), item.title)
def test_00_model(self): query = model.Session.query(model.Package) page = AlphaPage( collection=query, alpha_attribute='title', page='A', other_text=other, ) assert_equal( page.available, { 'Other': 20, 'A': 10, 'C': 10, 'B': 10, 'E': 0, 'D': 10, 'G': 0, 'F': 0, 'I': 0, 'H': 0, 'K': 0, 'J': 0, 'M': 0, 'L': 0, 'O': 0, 'N': 0, 'Q': 0, 'P': 0, 'S': 0, 'R': 0, 'U': 0, 'T': 0, 'W': 0, 'V': 0, 'Y': 0, 'X': 0, 'Z': 0 })