#NEWLINE# def test_create_category( self ) : #NEWLINE# #INDENT# url = reverse ( 'category-list' ) #NEWLINE# data = { #NEWLINE# #INDENT# 'name' : 'cell-phones' , #NEWLINE# 'code' : 'cp' , #NEWLINE# #UNINDENT# } #NEWLINE# response = self . client . post ( url , data , format = 'json' ) #NEWLINE# self . assertEqual ( response . status_code , status . HTTP_201_CREATED ) #NEWLINE# self . assertEqual ( response . data [ 'name' ] , 'cell-phones' ) #NEWLINE# self . assertEqual ( Category . objects . count ( ) , 2 ) #NEWLINE# category = Category . objects . get ( pk = response . data [ 'id' ] ) #NEWLINE# self . assertEqual ( category . name , 'cell-phones' ) #NEWLINE# self . assertEqual ( category . code , 'cp' ) #NEWLINE# self . assertIsNone ( category . parent )