def test_without_question_mark_exists(self):
		#test with default size
		pageLinks = PageLinks(1,1,'/blah', 'page')
		
		myLinks = pageLinks.get_links()
		self.assertTrue(myLinks[0][1].count('?') == 1)
		self.assertTrue(myLinks[0][1].count('&') == 0) 
	def test_with_one_page(self):
		#test with default size
		pageLinks = PageLinks(1,1,'/blah', 'page')
		
		myLinks = pageLinks.get_links()	
		self.assertTrue(len(myLinks) == 1) 
		
		#test with custom size
		pageLinks = PageLinks(1,1,'/blah', 'page',6)		
		myLinks = pageLinks.get_links()
		self.assertTrue(len(myLinks) == 1)
Esempio n. 3
0
def main(current_page=1):
    query = LieModel.all().filter('status = ', 'approved')
    """Add some logic later to figure out if we have a new page"""
    pagedQuery = PagedQuery(query, 10)
    pagedQuery.order('-timestamp')
    lies = pagedQuery.fetch_page(current_page)
    page_count = pagedQuery.page_count()

    lieLinks = PageLinks(page=current_page,
                         page_count=pagedQuery.page_count(),
                         url_root="/",
                         page_field='page',
                         page_range=5)
    navigation_links = lieLinks.get_links()

    return render_template('list_lies.html',
                           lies=lies,
                           navigation_links=navigation_links)
	def test_large_page_count(self):
		#test with default size
		pageLinks = PageLinks(2,30,'/blah', 'page')
		
		myLinks = pageLinks.get_links()
		self.assertTrue(len(myLinks) == 12) #ten page + 2
		
		#test with custom size
		pageLinks = PageLinks(2,30,'/blah', 'page',6)		
		myLinks = pageLinks.get_links()
		self.assertTrue(len(myLinks) == 8) #ten page + 2
		
		#test with first page
		pageLinks = PageLinks(1,30,'/blah', 'page',6)
		myLinks = pageLinks.get_links()
		self.assertTrue(len(myLinks) == 7) #6 pages + 1
		
		#test with last page
		pageLinks = PageLinks(30,30,'/blah', 'page',6)
		myLinks = pageLinks.get_links()
		self.assertTrue(len(myLinks) == 5) #4 pages + 1
	def test_small_page_count(self):
		
		#test with default size
		pageLinks = PageLinks(2,3,'/blah', 'page')
		
		myLinks = pageLinks.get_links()
		self.assertTrue(len(myLinks) == 5)
		
		#test with different size
		pageLinks = PageLinks(2,3,'/blah', 'page',3)
		
		myLinks = pageLinks.get_links()
		self.assertTrue(len(myLinks) == 5)
		
		#test with different size
		pageLinks = PageLinks(2,3,'/blah', 'page',20)
		
		myLinks = pageLinks.get_links()
		self.assertTrue(len(myLinks) == 5)