# Path: google/api_core/rest_streaming.py
# class ResponseIterator:
#     def __init__(self, response: requests.Response, response_message_cls):
#     def cancel(self):
#     def _process_chunk(self, chunk: str):
#     def __next__(self):
#     def _grab(self):
#     def __iter__(self):


import datetime
import logging
import random
import time
import proto
import pytest
import requests
from typing import List
from unittest.mock import patch
from google.api_core import rest_streaming
from google.protobuf import duration_pb2
from google.protobuf import timestamp_pb2
    itr = rest_streaming.ResponseIterator(resp, Song)
    assert list(itr) == responses


@pytest.mark.parametrize("random_split", [True, False])
def test_next_escaped_characters_in_string(random_split):
    composer_with_relateds = Composer()
    relateds = ["Artist A", "Artist B"]
    composer_with_relateds.relateds = relateds

    responses = [
        Song(title='ti"tle\nfoo\tbar{}', composer=Composer(given_name="name\n\n\n")),
        Song(
            title='{"this is weird": "totally"}', composer=Composer(given_name="\\{}\\")
        ),
        Song(title='\\{"key": ["value",]}\\', composer=composer_with_relateds),
    ]
    resp = ResponseMock(
        responses=responses, random_split=random_split, response_cls=Song
    )
    itr = rest_streaming.ResponseIterator(resp, Song)
    assert list(itr) == responses


def test_next_not_array():
    with patch.object(
        ResponseMock, "iter_content", return_value=iter('{"hello": 0}')
    ) as mock_method:

        resp = ResponseMock(responses=[], response_cls=EchoResponse)

# Path: google/api_core/rest_streaming.py
# class ResponseIterator:
#     def __init__(self, response: requests.Response, response_message_cls):
#     def cancel(self):
#     def _process_chunk(self, chunk: str):
#     def __next__(self):
#     def _grab(self):
#     def __iter__(self):


# Path: tests/unit/test_rest_streaming.py
import datetime
import logging
import random
import time
import proto
import pytest
import requests
from typing import List
from unittest.mock import patch
from google.api_core import rest_streaming
from google.protobuf import duration_pb2
from google.protobuf import timestamp_pb2

    itr = rest_streaming.ResponseIterator(resp, Song)
    assert list(itr) == responses


@pytest.mark.parametrize("random_split", [True, False])
def test_next_escaped_characters_in_string(random_split):
    composer_with_relateds = Composer()
    relateds = ["Artist A", "Artist B"]
    composer_with_relateds.relateds = relateds

    responses = [
        Song(title='ti"tle\nfoo\tbar{}', composer=Composer(given_name="name\n\n\n")),
        Song(
            title='{"this is weird": "totally"}', composer=Composer(given_name="\\{}\\")
        ),
        Song(title='\\{"key": ["value",]}\\', composer=composer_with_relateds),
    ]
    resp = ResponseMock(
        responses=responses, random_split=random_split, response_cls=Song
    )
    itr = rest_streaming.ResponseIterator(resp, Song)
    assert list(itr) == responses


def test_next_not_array():
    with patch.object(
        ResponseMock, "iter_content", return_value=iter('{"hello": 0}')
    ) as mock_method:

        resp = ResponseMock(responses=[], response_cls=EchoResponse)

        itr = rest_streaming.ResponseIterator(resp, EchoResponse)