#NEWLINE# def test_get_all_category_sort( self ) : #NEWLINE# #INDENT# cat1 = DataCategory ( name = 'Category1' , order = 2.0 , published = True ) #NEWLINE# cat1 . save ( ) #NEWLINE# c1 = DataConcept ( name = 'B' , published = True , category = cat1 , order = 1 ) #NEWLINE# c1 . save ( ) #NEWLINE# field1 = DataConceptField ( concept = c1 , field = self . name_field , order = 1 ) #NEWLINE# field1 . save ( ) #NEWLINE# c2 = DataConcept ( name = 'C' , published = True , category = cat1 , order = 2 ) #NEWLINE# c2 . save ( ) #NEWLINE# field2 = DataConceptField ( concept = c2 , field = self . name_field , order = 1 ) #NEWLINE# field2 . save ( ) #NEWLINE# c3 = DataConcept ( name = 'A' , published = True , category = cat1 , order = 3 ) #NEWLINE# c3 . save ( ) #NEWLINE# field3 = DataConceptField ( concept = c3 , field = self . name_field , order = 1 ) #NEWLINE# field3 . save ( ) #NEWLINE# response = self . client . get ( '/api/concepts/' , HTTP_ACCEPT = 'application/json' ) #NEWLINE# self . assertEqual ( response . status_code , codes . ok ) #NEWLINE# self . assertEqual ( len ( json . loads ( response . content ) ) , 5 ) #NEWLINE# names = [ concept . get ( 'name' , '' ) for concept in json . loads ( response . content ) ] #NEWLINE# self . assertEqual ( names , [ 'Title' , 'Name' , 'B' , 'C' , 'A' ] ) #NEWLINE# response = self . client . get ( '/api/concepts/' , { #NEWLINE# #INDENT# 'order' : 'desc' , #NEWLINE# #UNINDENT# } , HTTP_ACCEPT = 'application/json' ) #NEWLINE# self . assertEqual ( response . status_code , codes . ok ) #NEWLINE# self . assertEqual ( len ( json . loads ( response . content ) ) , 5 ) #NEWLINE# names = [ concept . get ( 'name' , '' ) for concept in json . loads ( response . content ) ] #NEWLINE# self . assertEqual ( names , [ 'B' , 'C' , 'A' , 'Title' , 'Name' ] ) #NEWLINE# response = self . client . get ( '/api/concepts/' , { #NEWLINE# #INDENT# 'sort' : 'name' , #NEWLINE# #UNINDENT# } , HTTP_ACCEPT = 'application/json' ) #NEWLINE# self . assertEqual ( response . status_code , codes . ok ) #NEWLINE# self . assertEqual ( len ( json . loads ( response . content ) ) , 5 ) #NEWLINE# names = [ concept . get ( 'name' , '' ) for concept in json . loads ( response . content ) ] #NEWLINE# self . assertEqual ( names , [ 'Name' , 'Title' , 'A' , 'B' , 'C' ] ) #NEWLINE# response = self . client . get ( '/api/concepts/' , { #NEWLINE# #INDENT# 'sort' : 'name' , #NEWLINE# 'order' : 'desc' , #NEWLINE# #UNINDENT# } , HTTP_ACCEPT = 'application/json' ) #NEWLINE# self . assertEqual ( response . status_code , codes . ok ) #NEWLINE# self . assertEqual ( len ( json . loads ( response . content ) ) , 5 ) #NEWLINE# names = [ concept . get ( 'name' , '' ) for concept in json . loads ( response . content ) ] #NEWLINE# self . assertEqual ( names , [ 'C' , 'B' , 'A' , 'Title' , 'Name' ] ) #NEWLINE# c1 . delete ( ) #NEWLINE# c2 . delete ( ) #NEWLINE# c3 . delete ( ) #NEWLINE# field1 . delete ( ) #NEWLINE# field2 . delete ( ) #NEWLINE# field3 . delete ( ) #NEWLINE# cat1 . delete ( )