<s> from __future__ import unicode_literals <EOL> import datetime <EOL> from decimal import Decimal as D <EOL> import django <EOL> from django . core . exceptions import ImproperlyConfigured <EOL> from django . forms import ValidationError <EOL> from django . test import TestCase <EOL> if django . VERSION < ( <NUM_LIT:1> , <NUM_LIT:8> ) : <EOL> from django . utils . unittest import expectedFailure <EOL> else : <EOL> from unittest import expectedFailure <EOL> from . models import Item , Order , Tag , Event <EOL> class FormSetViewTests ( TestCase ) : <EOL> management_data = { <EOL> '<STR_LIT>' : '<STR_LIT:2>' , <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> def test_create ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertTrue ( '<STR_LIT>' in res . context ) <EOL> self . assertFalse ( '<STR_LIT>' in res . context ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] . __class__ . __name__ , '<STR_LIT>' ) <EOL> def test_formset_named ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , res . context [ '<STR_LIT>' ] ) <EOL> def test_missing_management ( self ) : <EOL> with self . assertRaises ( ValidationError ) : <EOL> self . client . post ( '<STR_LIT>' , { } ) <EOL> def test_success ( self ) : <EOL> res = self . client . post ( '<STR_LIT>' , self . management_data , follow = True ) <EOL> self . assertRedirects ( res , '<STR_LIT>' , status_code = <NUM_LIT> ) <EOL> @ expectedFailure <EOL> def test_put ( self ) : <EOL> res = self . client . put ( '<STR_LIT>' , self . management_data , follow = True ) <EOL> self . assertRedirects ( res , '<STR_LIT>' , status_code = <NUM_LIT> ) <EOL> def test_success_url ( self ) : <EOL> res = self . client . post ( '<STR_LIT>' , self . management_data , follow = True ) <EOL> self . assertRedirects ( res , '<STR_LIT>' ) <EOL> def test_invalid ( self ) : <EOL> data = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> data . update ( self . management_data ) <EOL> res = self . client . post ( '<STR_LIT>' , data , follow = True ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertTrue ( '<STR_LIT>' in res . context [ '<STR_LIT>' ] . errors [ <NUM_LIT:0> ] ) <EOL> def test_formset_class ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> class ModelFormSetViewTests ( TestCase ) : <EOL> management_data = { <EOL> '<STR_LIT>' : '<STR_LIT:2>' , <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> def test_create ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertTrue ( '<STR_LIT>' in res . context ) <EOL> self . assertFalse ( '<STR_LIT>' in res . context ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] . __class__ . __name__ , '<STR_LIT>' ) <EOL> def test_override ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> form = res . context [ '<STR_LIT>' ] . forms [ <NUM_LIT:0> ] <EOL> self . assertEqual ( form [ '<STR_LIT>' ] . value ( ) , True ) <EOL> self . assertEqual ( form [ '<STR_LIT>' ] . value ( ) , '<STR_LIT>' ) <EOL> def test_post ( self ) : <EOL> order = Order ( name = '<STR_LIT>' ) <EOL> order . save ( ) <EOL> data = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : D ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : order . id , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> } <EOL> data . update ( self . management_data ) <EOL> data [ '<STR_LIT>' ] = '<STR_LIT:1>' <EOL> res = self . client . post ( '<STR_LIT>' , data , follow = True ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( Item . objects . all ( ) . count ( ) , <NUM_LIT:1> ) <EOL> def test_context ( self ) : <EOL> order = Order ( name = '<STR_LIT>' ) <EOL> order . save ( ) <EOL> for i in range ( <NUM_LIT:10> ) : <EOL> item = Item ( name = '<STR_LIT>' % i , sku = str ( i ) * <NUM_LIT> , price = D ( '<STR_LIT>' ) , order = order , status = <NUM_LIT:0> ) <EOL> item . save ( ) <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertTrue ( '<STR_LIT>' in res . context ) <EOL> self . assertEqual ( len ( res . context [ '<STR_LIT>' ] ) , <NUM_LIT:10> ) <EOL> class InlineFormSetViewTests ( TestCase ) : <EOL> management_data = { <EOL> '<STR_LIT>' : '<STR_LIT:2>' , <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> def test_create ( self ) : <EOL> order = Order ( name = '<STR_LIT>' ) <EOL> order . save ( ) <EOL> for i in range ( <NUM_LIT:10> ) : <EOL> item = Item ( name = '<STR_LIT>' % i , sku = str ( i ) * <NUM_LIT> , price = D ( '<STR_LIT>' ) , order = order , status = <NUM_LIT:0> ) <EOL> item . save ( ) <EOL> res = self . client . get ( '<STR_LIT>' . format ( order . id ) ) <EOL> self . assertTrue ( '<STR_LIT:object>' in res . context ) <EOL> self . assertTrue ( '<STR_LIT>' in res . context ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertTrue ( '<STR_LIT>' in res . context ) <EOL> self . assertFalse ( '<STR_LIT>' in res . context ) <EOL> def test_post ( self ) : <EOL> order = Order ( name = '<STR_LIT>' ) <EOL> order . save ( ) <EOL> data = { } <EOL> data . update ( self . management_data ) <EOL> res = self . client . post ( '<STR_LIT>' . format ( order . id ) , data , follow = True ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertTrue ( '<STR_LIT>' in res . context ) <EOL> self . assertFalse ( '<STR_LIT>' in res . context ) <EOL> def test_save ( self ) : <EOL> order = Order ( name = '<STR_LIT>' ) <EOL> order . save ( ) <EOL> data = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : D ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : True , <EOL> } <EOL> data . update ( self . management_data ) <EOL> self . assertEqual ( <NUM_LIT:0> , order . items . count ( ) ) <EOL> res = self . client . post ( '<STR_LIT>' . format ( order . id ) , data , follow = True ) <EOL> order = Order . objects . get ( id = order . id ) <EOL> context_instance = res . context [ '<STR_LIT>' ] [ <NUM_LIT:0> ] . instance <EOL> self . assertEqual ( '<STR_LIT>' , context_instance . name ) <EOL> self . assertEqual ( '<STR_LIT>' , res . context [ '<STR_LIT>' ] [ <NUM_LIT:1> ] . instance . name ) <EOL> self . assertEqual ( <NUM_LIT:1> , order . items . count ( ) ) <EOL> class GenericInlineFormSetViewTests ( TestCase ) : <EOL> def test_get ( self ) : <EOL> order = Order ( name = '<STR_LIT>' ) <EOL> order . save ( ) <EOL> order2 = Order ( name = '<STR_LIT>' ) <EOL> order2 . save ( ) <EOL> tag = Tag ( name = '<STR_LIT>' , content_object = order ) <EOL> tag . save ( ) <EOL> tag = Tag ( name = '<STR_LIT>' , content_object = order2 ) <EOL> tag . save ( ) <EOL> res = self . client . get ( '<STR_LIT>' . format ( order . id ) ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertTrue ( '<STR_LIT>' in res . context ) <EOL> self . assertFalse ( '<STR_LIT>' in res . context ) <EOL> self . assertEqual ( '<STR_LIT>' , res . context [ '<STR_LIT>' ] . forms [ <NUM_LIT:0> ] [ '<STR_LIT:name>' ] . value ( ) ) <EOL> def test_post ( self ) : <EOL> order = Order ( name = '<STR_LIT>' ) <EOL> order . save ( ) <EOL> tag = Tag ( name = '<STR_LIT>' , content_object = order ) <EOL> tag . save ( ) <EOL> data = { <EOL> '<STR_LIT>' : <NUM_LIT:3> , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : True , <EOL> } <EOL> res = self . client . post ( '<STR_LIT>' . format ( order . id ) , data , follow = True ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( '<STR_LIT>' , res . context [ '<STR_LIT>' ] . forms [ <NUM_LIT:0> ] [ '<STR_LIT:name>' ] . value ( ) ) <EOL> self . assertEqual ( <NUM_LIT:1> , Tag . objects . count ( ) ) <EOL> def test_post2 ( self ) : <EOL> order = Order ( name = '<STR_LIT>' ) <EOL> order . save ( ) <EOL> tag = Tag ( name = '<STR_LIT>' , content_object = order ) <EOL> tag . save ( ) <EOL> data = { <EOL> '<STR_LIT>' : <NUM_LIT:3> , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : tag . id , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> res = self . client . post ( '<STR_LIT>' . format ( order . id ) , data , follow = True ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( <NUM_LIT:3> , Tag . objects . count ( ) ) <EOL> class ModelWithInlinesTests ( TestCase ) : <EOL> def test_create ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( <NUM_LIT:0> , Tag . objects . count ( ) ) <EOL> data = { <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:2>' , <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : D ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : <NUM_LIT:2> , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : True , <EOL> } <EOL> res = self . client . post ( '<STR_LIT>' , data , follow = True ) <EOL> self . assertTrue ( '<STR_LIT:object>' in res . context ) <EOL> self . assertTrue ( '<STR_LIT>' in res . context ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( <NUM_LIT:1> , Tag . objects . count ( ) ) <EOL> def test_named_create ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , res . context [ '<STR_LIT>' ] [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] , res . context [ '<STR_LIT>' ] [ <NUM_LIT:1> ] ) <EOL> def test_validation ( self ) : <EOL> data = { <EOL> '<STR_LIT>' : '<STR_LIT:2>' , <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : <NUM_LIT:2> , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : True , <EOL> } <EOL> res = self . client . post ( '<STR_LIT>' , data , follow = True ) <EOL> self . assertEqual ( len ( res . context [ '<STR_LIT>' ] . errors ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( res . context [ '<STR_LIT>' ] [ <NUM_LIT:0> ] . errors [ <NUM_LIT:0> ] ) , <NUM_LIT:2> ) <EOL> def test_update ( self ) : <EOL> order = Order ( name = '<STR_LIT>' ) <EOL> order . save ( ) <EOL> item_ids = [ ] <EOL> for i in range ( <NUM_LIT:2> ) : <EOL> item = Item ( name = '<STR_LIT>' % i , sku = str ( i ) * <NUM_LIT> , price = D ( '<STR_LIT>' ) , order = order , status = <NUM_LIT:0> ) <EOL> item . save ( ) <EOL> item_ids . append ( item . id ) <EOL> tag = Tag ( name = '<STR_LIT>' , content_object = order ) <EOL> tag . save ( ) <EOL> res = self . client . get ( '<STR_LIT>' . format ( order . id ) ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> order = Order . objects . get ( id = order . id ) <EOL> self . assertEqual ( <NUM_LIT:2> , order . items . count ( ) ) <EOL> self . assertEqual ( '<STR_LIT>' , order . items . all ( ) [ <NUM_LIT:0> ] . name ) <EOL> data = { <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:4>' , <EOL> '<STR_LIT>' : '<STR_LIT:2>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : D ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : item_ids [ <NUM_LIT:0> ] , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : D ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : item_ids [ <NUM_LIT:1> ] , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : D ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : <NUM_LIT:3> , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : tag . id , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> res = self . client . post ( '<STR_LIT>' . format ( order . id ) , data ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT> ) <EOL> order = Order . objects . get ( id = order . id ) <EOL> self . assertEqual ( <NUM_LIT:3> , order . items . count ( ) ) <EOL> self . assertEqual ( <NUM_LIT:2> , Tag . objects . count ( ) ) <EOL> self . assertEqual ( '<STR_LIT>' , order . items . all ( ) [ <NUM_LIT:0> ] . name ) <EOL> def test_parent_instance_saved_in_form_save ( self ) : <EOL> order = Order ( name = '<STR_LIT>' ) <EOL> order . save ( ) <EOL> data = { <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> res = self . client . post ( '<STR_LIT>' . format ( order . id ) , data ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT> ) <EOL> order = Order . objects . get ( id = order . id ) <EOL> self . assertTrue ( order . action_on_save ) <EOL> class CalendarViewTests ( TestCase ) : <EOL> def test_create ( self ) : <EOL> event = Event ( name = '<STR_LIT>' , date = datetime . date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> event . save ( ) <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> class SearchableListTests ( TestCase ) : <EOL> def setUp ( self ) : <EOL> order = Order ( name = '<STR_LIT>' ) <EOL> order . save ( ) <EOL> Item . objects . create ( sku = '<STR_LIT>' , name = '<STR_LIT>' , order = order , price = <NUM_LIT:0> , date_placed = datetime . date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> Item . objects . create ( sku = '<STR_LIT>' , name = '<STR_LIT>' , order = order , price = <NUM_LIT:0> , date_placed = datetime . date ( <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:1> ) ) <EOL> Item . objects . create ( sku = '<STR_LIT:C>' , name = '<STR_LIT:test>' , order = order , price = <NUM_LIT:0> , date_placed = datetime . date ( <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:1> ) ) <EOL> def test_search ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' , data = { '<STR_LIT:q>' : '<STR_LIT>' } ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( res . context [ '<STR_LIT>' ] ) ) <EOL> res = self . client . get ( '<STR_LIT>' , data = { '<STR_LIT:q>' : '<STR_LIT>' } ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( <NUM_LIT:0> , len ( res . context [ '<STR_LIT>' ] ) ) <EOL> res = self . client . get ( '<STR_LIT>' , data = { '<STR_LIT:q>' : '<STR_LIT>' } ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( res . context [ '<STR_LIT>' ] ) ) <EOL> res = self . client . get ( '<STR_LIT>' , data = { '<STR_LIT:q>' : '<STR_LIT>' } ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( <NUM_LIT:0> , len ( res . context [ '<STR_LIT>' ] ) ) <EOL> res = self . client . get ( '<STR_LIT>' , data = { '<STR_LIT:q>' : '<STR_LIT>' } ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( res . context [ '<STR_LIT>' ] ) ) <EOL> res = self . client . get ( '<STR_LIT>' , data = { '<STR_LIT:q>' : '<STR_LIT:test>' } ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( res . context [ '<STR_LIT>' ] ) ) <EOL> try : <EOL> self . assertRaises ( self . client . get ( '<STR_LIT>' , data = { '<STR_LIT:q>' : '<STR_LIT:test>' } ) ) <EOL> error = False <EOL> except ValueError : <EOL> error = True <EOL> self . assertTrue ( error ) <EOL> class SortableViewTest ( TestCase ) : <EOL> def setUp ( self ) : <EOL> order = Order ( name = '<STR_LIT>' ) <EOL> order . save ( ) <EOL> Item . objects . create ( sku = '<STR_LIT>' , name = '<STR_LIT>' , order = order , price = <NUM_LIT:0> ) <EOL> Item . objects . create ( sku = '<STR_LIT>' , name = '<STR_LIT>' , order = order , price = <NUM_LIT:0> ) <EOL> def test_sort ( self ) : <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertFalse ( res . context [ '<STR_LIT>' ] . is_sorted_by_name ( ) ) <EOL> asc_url = res . context [ '<STR_LIT>' ] . get_sort_query_by_name_asc ( ) <EOL> res = self . client . get ( '<STR_LIT>' % asc_url ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] [ <NUM_LIT:0> ] . name , '<STR_LIT>' ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] [ <NUM_LIT:1> ] . name , '<STR_LIT>' ) <EOL> self . assertTrue ( res . context [ '<STR_LIT>' ] . is_sorted_by_name ( ) ) <EOL> desc_url = res . context [ '<STR_LIT>' ] . get_sort_query_by_name_desc ( ) <EOL> res = self . client . get ( '<STR_LIT>' % desc_url ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] [ <NUM_LIT:0> ] . name , '<STR_LIT>' ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] [ <NUM_LIT:1> ] . name , '<STR_LIT>' ) <EOL> self . assertTrue ( res . context [ '<STR_LIT>' ] . is_sorted_by_name ( ) ) <EOL> sort_url = res . context [ '<STR_LIT>' ] . get_sort_query_by_name ( ) <EOL> res = self . client . get ( '<STR_LIT>' % sort_url ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] [ <NUM_LIT:0> ] . name , '<STR_LIT>' ) <EOL> sort_url = res . context [ '<STR_LIT>' ] . get_sort_query_by_name ( ) <EOL> res = self . client . get ( '<STR_LIT>' % sort_url ) <EOL> self . assertEqual ( res . context [ '<STR_LIT>' ] [ <NUM_LIT:0> ] . name , '<STR_LIT>' ) <EOL> self . assertRaises ( ImproperlyConfigured , lambda : self . client . get ( '<STR_LIT>' ) ) <EOL> res = self . client . get ( '<STR_LIT>' ) <EOL> self . assertIn ( '<STR_LIT>' , res . context [ '<STR_LIT>' ] . get_sort_query_by_by_name ( ) ) <EOL> self . assertIn ( '<STR_LIT>' , res . context [ '<STR_LIT>' ] . get_sort_query_by_by_sku ( ) ) </s>
