# Path: firebase_admin/_sseclient.py
# class KeepAuthSession(transport.requests.AuthorizedSession):
# class _EventBuffer:
# class SSEClient:
# class Event:
#     def __init__(self, credential):
#     def rebuild_auth(self, prepared_request, response):
#     def __init__(self):
#     def append(self, char):
#     def truncate(self):
#     def is_end_of_field(self):
#     def buffer_string(self):
#     def __init__(self, url, session, retry=3000, **kwargs):
#     def close(self):
#     def _connect(self):
#     def __iter__(self):
#     def __next__(self):
#     def next(self):
#     def __init__(self, data='', event_type='message', event_id=None, retry=None):
#     def parse(cls, raw):
# 
# Path: tests/testutils.py
# def resource_filename(filename):
# def resource(filename):
# def cleanup_apps():
# def run_without_project_id(func):
# def new_monkeypatch():
#     def __init__(self, status, response):
#     def status(self):
#     def headers(self):
#     def data(self):
#     def __init__(self, status, response):
#     def __call__(self, *args, **kwargs): # pylint: disable=arguments-differ
#     def __init__(self, error):
#     def __call__(self, *args, **kwargs): # pylint: disable=arguments-differ
#     def refresh(self, request):
#     def __init__(self):
#     def get_credential(self):
#     def __init__(self, responses, statuses, recorder):
#     def send(self, request, **kwargs): # pylint: disable=arguments-differ
#     def __init__(self, data, status, recorder):
#     def status(self):
#     def data(self):
# class MockResponse(transport.Response):
# class MockRequest(transport.Request):
# class MockFailedRequest(transport.Request):
# class MockGoogleCredential(credentials.Credentials):
# class MockCredential(firebase_admin.credentials.Base):
# class MockMultiRequestAdapter(adapters.HTTPAdapter):
# class MockAdapter(MockMultiRequestAdapter):


import io
import json
import requests
from firebase_admin import _sseclient
from tests import testutils
        payload += 'event: put\ndata: {"path":"/bar","data":"testevent2"}\r\r'
        payload += 'event: put\ndata: {"path":"/baz","data":"testevent3"}\r\n\r\n'
        recorder = []
        sseclient = self.init_sse(payload, recorder)
        event = next(sseclient)
        event_payload = json.loads(event.data)
        assert event_payload["data"] == "testevent1"
        assert event_payload["path"] == "/foo"
        event = next(sseclient)
        event_payload = json.loads(event.data)
        assert event_payload["data"] == "testevent2"
        assert event_payload["path"] == "/bar"
        event = next(sseclient)
        event_payload = json.loads(event.data)
        assert event_payload["data"] == "testevent3"
        assert event_payload["path"] == "/baz"
        assert len(recorder) == 1


class TestEvent:
    """Test cases for server-side events"""

    def test_normal(self):
        data = 'event: put\ndata: {"path":"/","data":"testdata"}'
        event = _sseclient.Event.parse(data)
        assert event.event_type == "put"
        assert event.data == '{"path":"/","data":"testdata"}'

    def test_all_fields(self):
        data = 'event: put\ndata: {"path":"/","data":"testdata"}\nretry: 5000\nid: abcd'

# Path: firebase_admin/_sseclient.py
# class KeepAuthSession(transport.requests.AuthorizedSession):
# class _EventBuffer:
# class SSEClient:
# class Event:
#     def __init__(self, credential):
#     def rebuild_auth(self, prepared_request, response):
#     def __init__(self):
#     def append(self, char):
#     def truncate(self):
#     def is_end_of_field(self):
#     def buffer_string(self):
#     def __init__(self, url, session, retry=3000, **kwargs):
#     def close(self):
#     def _connect(self):
#     def __iter__(self):
#     def __next__(self):
#     def next(self):
#     def __init__(self, data='', event_type='message', event_id=None, retry=None):
#     def parse(cls, raw):
# 
# Path: tests/testutils.py
# def resource_filename(filename):
# def resource(filename):
# def cleanup_apps():
# def run_without_project_id(func):
# def new_monkeypatch():
#     def __init__(self, status, response):
#     def status(self):
#     def headers(self):
#     def data(self):
#     def __init__(self, status, response):
#     def __call__(self, *args, **kwargs): # pylint: disable=arguments-differ
#     def __init__(self, error):
#     def __call__(self, *args, **kwargs): # pylint: disable=arguments-differ
#     def refresh(self, request):
#     def __init__(self):
#     def get_credential(self):
#     def __init__(self, responses, statuses, recorder):
#     def send(self, request, **kwargs): # pylint: disable=arguments-differ
#     def __init__(self, data, status, recorder):
#     def status(self):
#     def data(self):
# class MockResponse(transport.Response):
# class MockRequest(transport.Request):
# class MockFailedRequest(transport.Request):
# class MockGoogleCredential(credentials.Credentials):
# class MockCredential(firebase_admin.credentials.Base):
# class MockMultiRequestAdapter(adapters.HTTPAdapter):
# class MockAdapter(MockMultiRequestAdapter):


# Path: tests/test_sseclient.py
import io
import json
import requests
from firebase_admin import _sseclient
from tests import testutils

        payload += 'event: put\ndata: {"path":"/bar","data":"testevent2"}\r\r'
        payload += 'event: put\ndata: {"path":"/baz","data":"testevent3"}\r\n\r\n'
        recorder = []
        sseclient = self.init_sse(payload, recorder)
        event = next(sseclient)
        event_payload = json.loads(event.data)
        assert event_payload["data"] == "testevent1"
        assert event_payload["path"] == "/foo"
        event = next(sseclient)
        event_payload = json.loads(event.data)
        assert event_payload["data"] == "testevent2"
        assert event_payload["path"] == "/bar"
        event = next(sseclient)
        event_payload = json.loads(event.data)
        assert event_payload["data"] == "testevent3"
        assert event_payload["path"] == "/baz"
        assert len(recorder) == 1


class TestEvent:
    """Test cases for server-side events"""

    def test_normal(self):
        data = 'event: put\ndata: {"path":"/","data":"testdata"}'
        event = _sseclient.Event.parse(data)
        assert event.event_type == "put"
        assert event.data == '{"path":"/","data":"testdata"}'

    def test_all_fields(self):
        data = 'event: put\ndata: {"path":"/","data":"testdata"}\nretry: 5000\nid: abcd'

        event = _sseclient.Event.parse(data)