<s> from __future__ import unicode_literals <EOL> from django . utils import six <EOL> from reviewboard . hostingsvcs . service import ( get_hosting_services , <EOL> get_hosting_service ) <EOL> from reviewboard . webapi . resources import resources <EOL> from reviewboard . webapi . tests . base import BaseWebAPITestCase <EOL> from reviewboard . webapi . tests . mimetypes import ( hosting_service_item_mimetype , <EOL> hosting_service_list_mimetype ) <EOL> from reviewboard . webapi . tests . mixins import BasicTestsMetaclass <EOL> from reviewboard . webapi . tests . urls import ( get_hosting_service_item_url , <EOL> get_hosting_service_list_url ) <EOL> def _compare_item ( self , item_rsp , hosting_service ) : <EOL> self . assertEqual ( item_rsp [ '<STR_LIT:id>' ] , hosting_service . id ) <EOL> self . assertEqual ( item_rsp [ '<STR_LIT:name>' ] , hosting_service . name ) <EOL> self . assertEqual ( item_rsp [ '<STR_LIT>' ] , <EOL> hosting_service . needs_authorization ) <EOL> self . assertEqual ( item_rsp [ '<STR_LIT>' ] , <EOL> hosting_service . supports_bug_trackers ) <EOL> self . assertEqual ( item_rsp [ '<STR_LIT>' ] , <EOL> hosting_service . supports_repositories ) <EOL> self . assertEqual ( item_rsp [ '<STR_LIT>' ] , <EOL> hosting_service . supports_two_factor_auth ) <EOL> self . assertEqual ( item_rsp [ '<STR_LIT>' ] , <EOL> hosting_service . supported_scmtools ) <EOL> url_base = '<STR_LIT>' <EOL> if '<STR_LIT>' in item_rsp [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] : <EOL> url_base += '<STR_LIT>' <EOL> url_base += '<STR_LIT>' <EOL> accounts_url = url_base + ( '<STR_LIT>' <EOL> % hosting_service . id ) <EOL> self . assertIn ( '<STR_LIT>' , item_rsp [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( item_rsp [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] , accounts_url ) <EOL> accounts_url = url_base + ( '<STR_LIT>' <EOL> % hosting_service . id ) <EOL> self . assertIn ( '<STR_LIT>' , item_rsp [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( item_rsp [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] , accounts_url ) <EOL> @ six . add_metaclass ( BasicTestsMetaclass ) <EOL> class ResourceListTests ( BaseWebAPITestCase ) : <EOL> """<STR_LIT>""" <EOL> fixtures = [ '<STR_LIT>' ] <EOL> sample_api_url = '<STR_LIT>' <EOL> resource = resources . hosting_service <EOL> compare_item = _compare_item <EOL> def setup_http_not_allowed_list_test ( self , user ) : <EOL> return get_hosting_service_list_url ( ) <EOL> def setup_basic_get_test ( self , user , with_local_site , local_site_name , <EOL> populate_items ) : <EOL> return ( get_hosting_service_list_url ( local_site_name ) , <EOL> hosting_service_list_mimetype , <EOL> get_hosting_services ( ) ) <EOL> @ six . add_metaclass ( BasicTestsMetaclass ) <EOL> class ResourceItemTests ( BaseWebAPITestCase ) : <EOL> """<STR_LIT>""" <EOL> fixtures = [ '<STR_LIT>' ] <EOL> sample_api_url = '<STR_LIT>' <EOL> resource = resources . hosting_service <EOL> compare_item = _compare_item <EOL> def setup_http_not_allowed_item_test ( self , user ) : <EOL> hosting_service = get_hosting_service ( '<STR_LIT>' ) <EOL> return get_hosting_service_item_url ( hosting_service ) <EOL> def setup_basic_get_test ( self , user , with_local_site , local_site_name ) : <EOL> hosting_service = get_hosting_service ( '<STR_LIT>' ) <EOL> return ( get_hosting_service_item_url ( hosting_service , local_site_name ) , <EOL> hosting_service_item_mimetype , <EOL> hosting_service ) </s>
