<s> from __future__ import unicode_literals <EOL> from django . http import SimpleCookie <EOL> from django . utils import six <EOL> from djblets . webapi . errors import NOT_LOGGED_IN <EOL> from reviewboard . webapi . resources import resources <EOL> from reviewboard . webapi . tests . base import BaseWebAPITestCase <EOL> from reviewboard . webapi . tests . mimetypes import session_mimetype <EOL> from reviewboard . webapi . tests . mixins import BasicTestsMetaclass <EOL> from reviewboard . webapi . tests . urls import get_session_url <EOL> @ six . add_metaclass ( BasicTestsMetaclass ) <EOL> class ResourceTests ( BaseWebAPITestCase ) : <EOL> """<STR_LIT>""" <EOL> fixtures = [ '<STR_LIT>' ] <EOL> sample_api_url = '<STR_LIT>' <EOL> resource = resources . session <EOL> def setup_http_not_allowed_list_test ( self , user ) : <EOL> return get_session_url ( ) <EOL> def setup_http_not_allowed_item_test ( self , user ) : <EOL> return get_session_url ( ) <EOL> def compare_item ( self , item_rsp , user ) : <EOL> self . assertTrue ( item_rsp [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( item_rsp [ '<STR_LIT>' ] [ '<STR_LIT:user>' ] [ '<STR_LIT:title>' ] , user . username ) <EOL> self . assertEqual ( item_rsp [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] , <EOL> item_rsp [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( item_rsp [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def setup_basic_get_test ( self , user , with_local_site , local_site_name ) : <EOL> return ( get_session_url ( local_site_name ) , <EOL> session_mimetype , <EOL> user ) <EOL> def test_get_with_anonymous_user ( self ) : <EOL> """<STR_LIT>""" <EOL> self . client . logout ( ) <EOL> rsp = self . api_get ( get_session_url ( ) , <EOL> expected_mimetype = session_mimetype ) <EOL> self . assertEqual ( rsp [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertIn ( '<STR_LIT>' , rsp ) <EOL> self . assertFalse ( rsp [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) <EOL> def setup_basic_delete_test ( self , user , with_local_site , local_site_name ) : <EOL> return ( get_session_url ( local_site_name ) , <EOL> session_mimetype ) <EOL> def check_delete_result ( self , user , * args ) : <EOL> pass <EOL> def test_delete_not_owner ( self ) : <EOL> """<STR_LIT>""" <EOL> self . load_fixtures ( self . basic_delete_fixtures ) <EOL> url , cb_args = self . setup_basic_delete_test ( self . user , False , None ) <EOL> self . client . logout ( ) <EOL> self . client . cookies = SimpleCookie ( ) <EOL> rsp = self . api_delete ( url , expected_status = <NUM_LIT> ) <EOL> self . assertEqual ( rsp [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( rsp [ '<STR_LIT>' ] [ '<STR_LIT:code>' ] , NOT_LOGGED_IN . code ) </s>
