<s> from __future__ import unicode_literals <EOL> from django . utils import six <EOL> from reviewboard . webapi . resources import resources <EOL> from reviewboard . webapi . tests . base import BaseWebAPITestCase <EOL> from reviewboard . webapi . tests . mimetypes import filediff_comment_list_mimetype <EOL> from reviewboard . webapi . tests . mixins import ( BasicTestsMetaclass , <EOL> ReviewRequestChildListMixin ) <EOL> from reviewboard . webapi . tests . urls import get_filediff_comment_list_url <EOL> @ six . add_metaclass ( BasicTestsMetaclass ) <EOL> class ResourceListTests ( ReviewRequestChildListMixin , BaseWebAPITestCase ) : <EOL> """<STR_LIT>""" <EOL> fixtures = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> sample_api_url = '<STR_LIT>' <EOL> resource = resources . filediff_comment <EOL> def setup_review_request_child_test ( self , review_request ) : <EOL> if not review_request . repository_id : <EOL> review_request . repository = self . create_repository ( ) <EOL> review_request . save ( ) <EOL> diffset = self . create_diffset ( review_request ) <EOL> filediff = self . create_filediff ( diffset ) <EOL> self . create_review ( review_request , publish = True ) <EOL> return ( get_filediff_comment_list_url ( filediff ) , <EOL> filediff_comment_list_mimetype ) <EOL> def setup_http_not_allowed_list_test ( self , user ) : <EOL> review_request = self . create_review_request ( create_repository = True , <EOL> submitter = user , <EOL> publish = True ) <EOL> diffset = self . create_diffset ( review_request ) <EOL> filediff = self . create_filediff ( diffset ) <EOL> return get_filediff_comment_list_url ( filediff ) <EOL> def compare_item ( self , item_rsp , filediff ) : <EOL> self . assertEqual ( item_rsp [ '<STR_LIT:id>' ] , filediff . pk ) <EOL> self . assertEqual ( item_rsp [ '<STR_LIT:text>' ] , filediff . text ) <EOL> def setup_basic_get_test ( self , user , with_local_site , local_site_name , <EOL> populate_items ) : <EOL> review_request = self . create_review_request ( <EOL> create_repository = True , <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> if populate_items : <EOL> review = self . create_review ( review_request , publish = True ) <EOL> items = [ <EOL> self . create_diff_comment ( review , filediff ) , <EOL> ] <EOL> else : <EOL> items = [ ] <EOL> return ( get_filediff_comment_list_url ( filediff , local_site_name ) , <EOL> filediff_comment_list_mimetype , <EOL> items ) <EOL> def test_get_as_anonymous ( self ) : <EOL> """<STR_LIT>""" <EOL> diff_comment_text = '<STR_LIT>' <EOL> review_request = self . create_review_request ( create_repository = True , <EOL> publish = True ) <EOL> diffset = self . create_diffset ( review_request ) <EOL> filediff = self . create_filediff ( diffset ) <EOL> review = self . create_review ( review_request , publish = True ) <EOL> comment = self . create_diff_comment ( review , filediff , <EOL> text = diff_comment_text ) <EOL> self . client . logout ( ) <EOL> rsp = self . api_get ( get_filediff_comment_list_url ( filediff ) , <EOL> expected_mimetype = filediff_comment_list_mimetype ) <EOL> self . assertEqual ( rsp [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( len ( rsp [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( rsp [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT:text>' ] , comment . text ) <EOL> def test_get_with_line ( self ) : <EOL> """<STR_LIT>""" <EOL> diff_comment_text = '<STR_LIT>' <EOL> diff_comment_line = <NUM_LIT:10> <EOL> review_request = self . create_review_request ( create_repository = True , <EOL> publish = True ) <EOL> diffset = self . create_diffset ( review_request ) <EOL> filediff = self . create_filediff ( diffset ) <EOL> review = self . create_review ( review_request , publish = True ) <EOL> self . create_diff_comment ( review , filediff , <EOL> text = diff_comment_text , <EOL> first_line = diff_comment_line ) <EOL> self . create_diff_comment ( review , filediff , <EOL> first_line = diff_comment_line + <NUM_LIT:1> ) <EOL> rsp = self . api_get ( get_filediff_comment_list_url ( filediff ) , { <EOL> '<STR_LIT>' : diff_comment_line , <EOL> } , expected_mimetype = filediff_comment_list_mimetype ) <EOL> self . assertEqual ( rsp [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( len ( rsp [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( rsp [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT:text>' ] , diff_comment_text ) <EOL> self . assertEqual ( rsp [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , <EOL> diff_comment_line ) <EOL> ResourceItemTests = None </s>
