<s> from tests import unittest <EOL> from mock import Mock <EOL> from ... . utils import MockHttpResource , setup_test_homeserver <EOL> from synapse . types import UserID <EOL> from twisted . internet import defer <EOL> PATH_PREFIX = "<STR_LIT>" <EOL> class V2AlphaRestTestCase ( unittest . TestCase ) : <EOL> @ defer . inlineCallbacks <EOL> def setUp ( self ) : <EOL> self . mock_resource = MockHttpResource ( prefix = PATH_PREFIX ) <EOL> hs = yield setup_test_homeserver ( <EOL> datastore = self . make_datastore_mock ( ) , <EOL> http_client = None , <EOL> resource_for_client = self . mock_resource , <EOL> resource_for_federation = self . mock_resource , <EOL> ) <EOL> def get_user_by_access_token ( token = None , allow_guest = False ) : <EOL> return { <EOL> "<STR_LIT:user>" : UserID . from_string ( self . USER_ID ) , <EOL> "<STR_LIT>" : <NUM_LIT:1> , <EOL> "<STR_LIT>" : False , <EOL> } <EOL> hs . get_auth ( ) . get_user_by_access_token = get_user_by_access_token <EOL> for r in self . TO_REGISTER : <EOL> r . register_servlets ( hs , self . mock_resource ) <EOL> def make_datastore_mock ( self ) : <EOL> store = Mock ( spec = [ <EOL> "<STR_LIT>" , <EOL> ] ) <EOL> store . get_app_service_by_token = Mock ( return_value = None ) <EOL> return store </s>
