<s> from flask import url_for <EOL> from flask_views . db . mongoengine . list import ListView <EOL> from flask_views . tests . functional . db . mongoengine . base import BaseMongoTestCase <EOL> class ListViewTestCase ( BaseMongoTestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> super ( ListViewTestCase , self ) . setUp ( ) <EOL> test_obj = self . TestDocument ( <EOL> name = '<STR_LIT>' , <EOL> username = '<STR_LIT:user>' , <EOL> ) <EOL> test_obj . save ( ) <EOL> for i in range ( <NUM_LIT:1> , <NUM_LIT:12> ) : <EOL> test_obj = self . TestDocument ( <EOL> name = '<STR_LIT>' , <EOL> username = '<STR_LIT>' . format ( i ) <EOL> ) <EOL> test_obj . save ( ) <EOL> class TestView ( ListView ) : <EOL> document_class = self . TestDocument <EOL> filter_fields = { <EOL> '<STR_LIT:name>' : '<STR_LIT:name>' , <EOL> } <EOL> template_name = '<STR_LIT>' <EOL> items_per_page = <NUM_LIT:3> <EOL> self . app . add_url_rule ( <EOL> '<STR_LIT>' , <EOL> view_func = TestView . as_view ( '<STR_LIT:test>' ) <EOL> ) <EOL> def test_get_pages ( self ) : <EOL> """<STR_LIT>""" <EOL> for i in range ( <NUM_LIT:1> , <NUM_LIT:5> ) : <EOL> with self . app . test_request_context ( ) : <EOL> response = self . client . get ( <EOL> url_for ( '<STR_LIT:test>' , name = '<STR_LIT>' , page = i ) ) <EOL> self . assertEqual ( <NUM_LIT:200> , response . status_code ) <EOL> def test_get_404 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . app . test_request_context ( ) : <EOL> response = self . client . get ( <EOL> url_for ( '<STR_LIT:test>' , name = '<STR_LIT>' , page = <NUM_LIT:5> ) ) <EOL> self . assertEqual ( <NUM_LIT> , response . status_code ) <EOL> def test_template_context ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . app . test_request_context ( ) : <EOL> response = self . client . get ( <EOL> url_for ( '<STR_LIT:test>' , name = '<STR_LIT>' , page = <NUM_LIT:4> ) ) <EOL> self . assertTrue ( '<STR_LIT>' in response . data ) <EOL> self . assertTrue ( '<STR_LIT>' in response . data ) <EOL> self . assertTrue ( '<STR_LIT>' in response . data ) <EOL> self . assertTrue ( '<STR_LIT>' in response . data ) </s>
