# Path: google/cloud/ndb/_batch.py
# def get_batch(batch_cls, options=None):
#     def idler(batch):
#         def idle():
# 
# Path: google/cloud/ndb/_eventloop.py
# class EventLoop(object):
#     def __init__(self):
#     def clear(self):
#     def insort_event_right(self, event):
#     def call_soon(self, callback, *args, **kwargs):
#     def queue_call(self, delay, callback, *args, **kwargs):
#     def queue_rpc(self, rpc, callback):
#         def rpc_callback(rpc):
#     def add_idle(self, callback, *args, **kwargs):
#     def run_idle(self):
#     def _run_current(self):
#     def run0(self):
#     def run1(self):
#     def run(self):
# def get_event_loop():
# def add_idle(callback, *args, **kwargs):
# def call_soon(callback, *args, **kwargs):
# def queue_call(delay, callback, *args, **kwargs):
# def queue_rpc(future, rpc):
# def run():
# def run1():


import pytest
from google.cloud.ndb import _batch
from google.cloud.ndb import _eventloop
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.




@pytest.mark.usefixtures("in_context")
class Test_get_batch:
    def test_it(self):
        options = {"foo": "bar"}
        batch = _batch.get_batch(MockBatch, options)
        assert batch.options is options
        assert not batch.idle_called

        different_options = {"food": "barn"}
        assert _batch.get_batch(MockBatch, different_options) is not batch

        assert _batch.get_batch(MockBatch) is not batch

        assert _batch.get_batch(MockBatch, options) is batch

        batch._full = True
        batch2 = _batch.get_batch(MockBatch, options)
        assert batch2 is not batch
        assert not batch2.idle_called


# Path: google/cloud/ndb/_batch.py
# def get_batch(batch_cls, options=None):
#     def idler(batch):
#         def idle():
# 
# Path: google/cloud/ndb/_eventloop.py
# class EventLoop(object):
#     def __init__(self):
#     def clear(self):
#     def insort_event_right(self, event):
#     def call_soon(self, callback, *args, **kwargs):
#     def queue_call(self, delay, callback, *args, **kwargs):
#     def queue_rpc(self, rpc, callback):
#         def rpc_callback(rpc):
#     def add_idle(self, callback, *args, **kwargs):
#     def run_idle(self):
#     def _run_current(self):
#     def run0(self):
#     def run1(self):
#     def run(self):
# def get_event_loop():
# def add_idle(callback, *args, **kwargs):
# def call_soon(callback, *args, **kwargs):
# def queue_call(delay, callback, *args, **kwargs):
# def queue_rpc(future, rpc):
# def run():
# def run1():


# Path: tests/unit/test__batch.py
import pytest
from google.cloud.ndb import _batch
from google.cloud.ndb import _eventloop

#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.




@pytest.mark.usefixtures("in_context")
class Test_get_batch:
    def test_it(self):
        options = {"foo": "bar"}
        batch = _batch.get_batch(MockBatch, options)
        assert batch.options is options
        assert not batch.idle_called

        different_options = {"food": "barn"}
        assert _batch.get_batch(MockBatch, different_options) is not batch

        assert _batch.get_batch(MockBatch) is not batch

        assert _batch.get_batch(MockBatch, options) is batch

        batch._full = True
        batch2 = _batch.get_batch(MockBatch, options)
        assert batch2 is not batch
        assert not batch2.idle_called


        _eventloop.run()