<s> from __future__ import unicode_literals <EOL> from django . utils import six <EOL> from djblets . webapi . errors import DOES_NOT_EXIST <EOL> from reviewboard . scmtools . core import PRE_CREATION <EOL> from reviewboard . webapi . resources import resources <EOL> from reviewboard . webapi . tests . base import BaseWebAPITestCase <EOL> from reviewboard . webapi . tests . mimetypes import original_file_mimetype <EOL> from reviewboard . webapi . tests . mixins import ( BasicTestsMetaclass , <EOL> ReviewRequestChildItemMixin ) <EOL> from reviewboard . webapi . tests . urls import get_original_file_url <EOL> @ six . add_metaclass ( BasicTestsMetaclass ) <EOL> class ResourceTests ( ReviewRequestChildItemMixin , BaseWebAPITestCase ) : <EOL> """<STR_LIT>""" <EOL> fixtures = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> sample_api_url = '<STR_LIT>' <EOL> resource = resources . original_file <EOL> basic_get_returns_json = False <EOL> def setup_review_request_child_test ( self , review_request ) : <EOL> if not review_request . repository : <EOL> repository = self . create_repository ( public = False , tool_name = '<STR_LIT>' ) <EOL> repository . users . add ( self . user ) <EOL> review_request . repository = repository <EOL> review_request . save ( ) <EOL> diffset = self . create_diffset ( review_request ) <EOL> filediff = self . create_filediff ( diffset ) <EOL> return ( get_original_file_url ( review_request , diffset , filediff ) , <EOL> original_file_mimetype ) <EOL> def setup_http_not_allowed_list_test ( self , user ) : <EOL> repository = self . create_repository ( tool_name = '<STR_LIT>' ) <EOL> review_request = self . create_review_request ( <EOL> repository = repository , <EOL> submitter = user , <EOL> publish = True ) <EOL> diffset = self . create_diffset ( review_request ) <EOL> filediff = self . create_filediff ( diffset ) <EOL> return get_original_file_url ( review_request , diffset , filediff ) <EOL> setup_http_not_allowed_item_test = setup_http_not_allowed_list_test <EOL> def compare_item ( self , data , filediff ) : <EOL> self . assertEqual ( data , '<STR_LIT>' ) <EOL> def setup_basic_get_test ( self , user , with_local_site , local_site_name ) : <EOL> repository = self . create_repository ( tool_name = '<STR_LIT>' ) <EOL> review_request = self . create_review_request ( <EOL> repository = repository , <EOL> with_local_site = with_local_site , <EOL> submitter = user , <EOL> publish = True ) <EOL> diffset = self . create_diffset ( review_request ) <EOL> filediff = self . create_filediff ( diffset ) <EOL> return ( get_original_file_url ( review_request , diffset , filediff , <EOL> local_site_name = local_site_name ) , <EOL> original_file_mimetype , <EOL> filediff ) <EOL> def test_with_new_file ( self ) : <EOL> """<STR_LIT>""" <EOL> repository = self . create_repository ( tool_name = '<STR_LIT>' ) <EOL> review_request = self . create_review_request ( <EOL> repository = repository , <EOL> submitter = self . user , <EOL> publish = True ) <EOL> diffset = self . create_diffset ( review_request ) <EOL> filediff = self . create_filediff ( diffset , source_revision = PRE_CREATION ) <EOL> rsp = self . api_get ( <EOL> get_original_file_url ( review_request , diffset , filediff ) , <EOL> expected_status = <NUM_LIT> ) <EOL> self . assertEqual ( rsp [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( rsp [ '<STR_LIT>' ] [ '<STR_LIT:code>' ] , DOES_NOT_EXIST . code ) <EOL> def test_with_draft_diff ( self ) : <EOL> """<STR_LIT>""" <EOL> repository = self . create_repository ( tool_name = '<STR_LIT>' ) <EOL> review_request = self . create_review_request ( <EOL> repository = repository , <EOL> submitter = self . user , <EOL> publish = True ) <EOL> diffset = self . create_diffset ( review_request , draft = True ) <EOL> filediff = self . create_filediff ( diffset ) <EOL> rsp = self . api_get ( <EOL> get_original_file_url ( review_request , diffset , filediff ) , <EOL> expected_status = <NUM_LIT> ) <EOL> self . assertEqual ( rsp [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( rsp [ '<STR_LIT>' ] [ '<STR_LIT:code>' ] , DOES_NOT_EXIST . code ) </s>
