def _instrument_iid_service(self, app, status=200, payload='True'): iid_service = instance_id._get_iid_service(app) recorder = [] iid_service._client.session.mount( instance_id._IID_SERVICE_URL, testutils.MockAdapter(payload, status, recorder)) return iid_service, recorder
def _instrument_provider_mgt(client, status, payload): recorder = [] provider_manager = client._provider_manager provider_manager.http_client.session.mount( _auth_providers.ProviderConfigClient.PROVIDER_CONFIG_URL, testutils.MockAdapter(payload, status, recorder)) return recorder
def _instrument_user_mgt(client, status, payload): recorder = [] user_manager = client._user_manager user_manager.http_client.session.mount( _user_mgt.UserManager.ID_TOOLKIT_URL, testutils.MockAdapter(payload, status, recorder)) return recorder
def _instrument_tenant_mgt(app, status, payload): service = tenant_mgt._get_tenant_mgt_service(app) recorder = [] service.client.session.mount( tenant_mgt._TenantManagementService.TENANT_MGT_URL, testutils.MockAdapter(payload, status, recorder)) return service, recorder
def _instrument_user_manager(app, status, payload): auth_service = auth._get_auth_service(app) user_manager = auth_service.user_manager recorder = [] user_manager._session.mount( _user_mgt.ID_TOOLKIT_URL, testutils.MockAdapter(payload, status, recorder)) return user_manager, recorder
def _instrument_user_manager(app, status, payload): client = auth._get_client(app) user_manager = client._user_manager recorder = [] user_manager.http_client.session.mount( _token_gen.TokenGenerator.ID_TOOLKIT_URL, testutils.MockAdapter(payload, status, recorder)) return user_manager, recorder
def _instrument_user_manager(app, status, payload): client = auth._get_client(app) user_manager = client._user_manager recorder = [] user_manager.http_client.session.mount( TOKEN_MGT_URLS['ID_TOOLKIT'], testutils.MockAdapter(payload, status, recorder)) return user_manager, recorder
def _instrument_provider_mgt(app, status, payload): client = auth._get_client(app) provider_manager = client._provider_manager recorder = [] provider_manager.http_client.session.mount( USER_MGT_URLS['ID_TOOLKIT'], testutils.MockAdapter(payload, status, recorder)) return recorder
def _instrument_session(self, app): client = auth._get_client(app) request = client._token_verifier.request recorder = [] request.session.mount( 'https://', testutils.MockAdapter(MOCK_PUBLIC_CERTS, 200, recorder)) return recorder
def test_send(self): self.fcm_service._client.session.mount( 'https://fcm.googleapis.com', testutils.MockAdapter(json.dumps({'name': 'message-id'}), 200, self.recorder)) msg = messaging.Message(topic='foo') messaging.send(msg) assert len(self.recorder) == 1 assert self.recorder[0]._extra_kwargs['timeout'] == 4
def _instrument_iid_service(self, app=None, status=200, payload=_DEFAULT_RESPONSE): if not app: app = firebase_admin.get_app() fcm_service = messaging._get_messaging_service(app) recorder = [] fcm_service._client.session.mount( 'https://iid.googleapis.com', testutils.MockAdapter(payload, status, recorder)) return fcm_service, recorder
def test_topic_management_timeout(self): self.fcm_service._client.session.mount( 'https://iid.googleapis.com', testutils.MockAdapter( json.dumps({'results': [{}, { 'error': 'error_reason' }]}), 200, self.recorder)) messaging.subscribe_to_topic(['1'], 'a') assert len(self.recorder) == 1 assert self.recorder[0]._extra_kwargs['timeout'] == 4
def _instrument(client, payload, status=200): recorder = [] adapter = testutils.MockAdapter(payload, status, recorder) client.session.mount(_TEST_URL, adapter) return recorder