<s> import json <EOL> from django . contrib . auth . models import User <EOL> from django . test import TestCase <EOL> from restlib2 . http import codes <EOL> from . base import TransactionBaseTestCase <EOL> class PreviewResourceProcessorTestCase ( TransactionBaseTestCase ) : <EOL> def test_no_processor ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' , <EOL> HTTP_ACCEPT = '<STR_LIT:application/json>' ) <EOL> self . assertEqual ( response . status_code , codes . ok ) <EOL> content = json . loads ( response . content ) <EOL> self . assertEqual ( len ( content [ '<STR_LIT>' ] ) , <NUM_LIT:6> ) <EOL> response = self . client . get ( '<STR_LIT>' , <EOL> HTTP_ACCEPT = '<STR_LIT:application/json>' ) <EOL> self . assertEqual ( response . status_code , codes . ok ) <EOL> content = json . loads ( response . content ) <EOL> self . assertEqual ( len ( content [ '<STR_LIT>' ] ) , <NUM_LIT:6> ) <EOL> response = self . client . get ( '<STR_LIT>' , <EOL> HTTP_ACCEPT = '<STR_LIT:application/json>' ) <EOL> self . assertEqual ( response . status_code , codes . ok ) <EOL> content = json . loads ( response . content ) <EOL> self . assertEqual ( len ( content [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> class PreviewResourceTestCase ( TestCase ) : <EOL> def test_delete ( self ) : <EOL> self . client . get ( '<STR_LIT>' ) <EOL> response = self . client . delete ( '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_code , codes . ok ) <EOL> self . assertTrue ( '<STR_LIT>' in json . loads ( response . content ) ) <EOL> def test_get ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' , <EOL> HTTP_ACCEPT = '<STR_LIT:application/json>' ) <EOL> self . assertEqual ( response . status_code , codes . ok ) <EOL> self . assertEqual ( response [ '<STR_LIT:Content-Type>' ] , '<STR_LIT:application/json>' ) <EOL> self . assertEqual ( json . loads ( response . content ) , { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : None , <EOL> } ) <EOL> def test_get_invalid ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' , <EOL> HTTP_ACCEPT = '<STR_LIT:application/json>' ) <EOL> self . assertEqual ( response . status_code , codes . not_found ) <EOL> def test_get_page ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' , <EOL> HTTP_ACCEPT = '<STR_LIT:application/json>' ) <EOL> self . assertEqual ( response . status_code , codes . ok ) <EOL> self . assertEqual ( response [ '<STR_LIT:Content-Type>' ] , '<STR_LIT:application/json>' ) <EOL> self . assertEqual ( json . loads ( response . content ) , { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:20> , <EOL> '<STR_LIT>' : <NUM_LIT:7> , <EOL> } ) <EOL> def test_get_page_range_equal ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' , <EOL> HTTP_ACCEPT = '<STR_LIT:application/json>' ) <EOL> self . assertEqual ( response . status_code , codes . ok ) <EOL> self . assertEqual ( response [ '<STR_LIT:Content-Type>' ] , '<STR_LIT:application/json>' ) <EOL> self . assertEqual ( json . loads ( response . content ) , { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:20> , <EOL> '<STR_LIT>' : <NUM_LIT:3> , <EOL> } ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] , ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) ) <EOL> def test_get_page_range ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' , <EOL> HTTP_ACCEPT = '<STR_LIT:application/json>' ) <EOL> self . assertEqual ( response . status_code , codes . ok ) <EOL> self . assertEqual ( response [ '<STR_LIT:Content-Type>' ] , '<STR_LIT:application/json>' ) <EOL> self . assertEqual ( json . loads ( response . content ) , { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:100> , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> } ) <EOL> def test_get_limit ( self ) : <EOL> response = self . client . get ( '<STR_LIT>' , <EOL> HTTP_ACCEPT = '<STR_LIT:application/json>' ) <EOL> self . assertEqual ( response . status_code , codes . ok ) <EOL> self . assertEqual ( response [ '<STR_LIT:Content-Type>' ] , '<STR_LIT:application/json>' ) <EOL> self . assertEqual ( json . loads ( response . content ) , { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:1000> , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> } ) <EOL> def test_get_with_user ( self ) : <EOL> self . user = User . objects . create_user ( username = '<STR_LIT:test>' , password = '<STR_LIT:test>' ) <EOL> self . client . login ( username = '<STR_LIT:test>' , password = '<STR_LIT:test>' ) <EOL> response = self . client . get ( '<STR_LIT>' , <EOL> HTTP_ACCEPT = '<STR_LIT:application/json>' ) <EOL> self . assertEqual ( response . status_code , codes . ok ) <EOL> self . assertEqual ( response [ '<STR_LIT:Content-Type>' ] , '<STR_LIT:application/json>' ) <EOL> self . assertEqual ( json . loads ( response . content ) , { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : None , <EOL> } ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] , ( <EOL> '<STR_LIT>' <EOL> ) ) </s>
