<s> """<STR_LIT>""" <EOL> from __future__ import unicode_literals <EOL> from django . test import TestCase <EOL> from django . test . client import RequestFactory <EOL> from endless_pagination import decorators <EOL> class DecoratorsTestMixin ( object ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> self . factory = RequestFactory ( ) <EOL> self . ajax_headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> self . default = '<STR_LIT>' <EOL> self . page = '<STR_LIT>' <EOL> self . page_url = '<STR_LIT>' <EOL> self . mypage = '<STR_LIT>' <EOL> self . mypage_url = '<STR_LIT>' <EOL> def get_decorator ( self ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError <EOL> def assertTemplatesEqual ( self , expected_active , expected_page , templates ) : <EOL> """<STR_LIT>""" <EOL> self . assertSequenceEqual ( [ expected_active , expected_page ] , templates ) <EOL> def decorate ( self , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> def view ( request , extra_context = None , template = self . default ) : <EOL> """<STR_LIT>""" <EOL> context = { } <EOL> if extra_context is not None : <EOL> context . update ( extra_context ) <EOL> return template , context [ '<STR_LIT>' ] <EOL> decorator = self . get_decorator ( ) <EOL> return decorator ( * args , ** kwargs ) ( view ) <EOL> def test_decorated ( self ) : <EOL> view = self . decorate ( self . arg ) <EOL> templates = view ( self . factory . get ( '<STR_LIT:/>' ) ) <EOL> self . assertTemplatesEqual ( self . default , self . page , templates ) <EOL> def test_request_with_querystring_key ( self ) : <EOL> view = self . decorate ( self . arg ) <EOL> templates = view ( self . factory . get ( self . page_url ) ) <EOL> self . assertTemplatesEqual ( self . default , self . page , templates ) <EOL> def test_ajax_request ( self ) : <EOL> view = self . decorate ( self . arg ) <EOL> templates = view ( self . factory . get ( '<STR_LIT:/>' , ** self . ajax_headers ) ) <EOL> self . assertTemplatesEqual ( self . page , self . page , templates ) <EOL> def test_ajax_request_with_querystring_key ( self ) : <EOL> view = self . decorate ( self . arg ) <EOL> templates = view ( self . factory . get ( self . page_url , ** self . ajax_headers ) ) <EOL> self . assertTemplatesEqual ( self . page , self . page , templates ) <EOL> def test_unexistent_page ( self ) : <EOL> view = self . decorate ( self . arg ) <EOL> templates = view ( self . factory . get ( '<STR_LIT>' ) ) <EOL> self . assertTemplatesEqual ( self . default , self . page , templates ) <EOL> class PageTemplateTest ( DecoratorsTestMixin , TestCase ) : <EOL> arg = '<STR_LIT>' <EOL> def get_decorator ( self ) : <EOL> return decorators . page_template <EOL> def test_request_with_querystring_key_to_mypage ( self ) : <EOL> view = self . decorate ( self . arg ) <EOL> templates = view ( self . factory . get ( self . mypage_url ) ) <EOL> self . assertTemplatesEqual ( self . default , self . page , templates ) <EOL> def test_ajax_request_with_querystring_key_to_mypage ( self ) : <EOL> view = self . decorate ( self . arg ) <EOL> templates = view ( <EOL> self . factory . get ( self . mypage_url , ** self . ajax_headers ) ) <EOL> self . assertTemplatesEqual ( self . default , self . page , templates ) <EOL> def test_ajax_request_to_mypage ( self ) : <EOL> view = self . decorate ( self . mypage , key = '<STR_LIT>' ) <EOL> templates = view ( <EOL> self . factory . get ( self . mypage_url , ** self . ajax_headers ) ) <EOL> self . assertTemplatesEqual ( self . mypage , self . mypage , templates ) <EOL> class PageTemplatesTest ( DecoratorsTestMixin , TestCase ) : <EOL> arg = { '<STR_LIT>' : None , '<STR_LIT>' : '<STR_LIT>' } <EOL> def get_decorator ( self ) : <EOL> return decorators . page_templates <EOL> def test_request_with_querystring_key_to_mypage ( self ) : <EOL> view = self . decorate ( self . arg ) <EOL> templates = view ( self . factory . get ( self . mypage_url ) ) <EOL> self . assertTemplatesEqual ( self . default , self . mypage , templates ) <EOL> def test_ajax_request_with_querystring_key_to_mypage ( self ) : <EOL> view = self . decorate ( self . arg ) <EOL> templates = view ( <EOL> self . factory . get ( self . mypage_url , ** self . ajax_headers ) ) <EOL> self . assertTemplatesEqual ( self . mypage , self . mypage , templates ) <EOL> class PageTemplatesWithTupleTest ( PageTemplatesTest ) : <EOL> arg = ( ( '<STR_LIT>' , None ) , ( '<STR_LIT>' , '<STR_LIT>' ) ) </s>
