# Path: google/cloud/ndb/exceptions.py
# class Error(Exception):
# class ContextError(Error):
# class BadValueError(Error):
# class BadArgumentError(Error):
# class BadRequestError(Error):
# class Rollback(Error):
# class BadQueryError(Error):
# class BadFilterError(Error):
# class NoLongerImplementedError(NotImplementedError):
# class Cancelled(Error):
# class NestedRetryException(Error):
#     def __init__(self):
#     def __init__(self, filter):
#     def __init__(self):
# 
# 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 collections
    import mock
import grpc
import pytest
    from unittest import mock
from google.cloud.ndb import exceptions
from google.cloud.ndb import _eventloop
        callback = mock.Mock(__name__="callback")
        loop = self._make_one()
        loop.queue_call(5, callback)
        assert loop.run1() is True
        time.sleep.assert_called_once_with(5)
        callback.assert_not_called()

    @mock.patch("google.cloud.ndb._eventloop.time")
    def test_run(self, time):
        time.time.return_value = 0

        def mock_sleep(seconds):
            time.time.return_value += seconds

        time.sleep = mock_sleep
        idler = mock.Mock(__name__="idler")
        idler.return_value = None
        runnow = mock.Mock(__name__="runnow")
        runlater = mock.Mock(__name__="runlater")
        loop = self._make_one()
        loop.add_idle(idler)
        loop.call_soon(runnow)
        loop.queue_call(5, runlater)
        loop.run()
        idler.assert_called_once_with()
        runnow.assert_called_once_with()
        runlater.assert_called_once_with()


def test_get_event_loop(context):

# Path: google/cloud/ndb/exceptions.py
# class Error(Exception):
# class ContextError(Error):
# class BadValueError(Error):
# class BadArgumentError(Error):
# class BadRequestError(Error):
# class Rollback(Error):
# class BadQueryError(Error):
# class BadFilterError(Error):
# class NoLongerImplementedError(NotImplementedError):
# class Cancelled(Error):
# class NestedRetryException(Error):
#     def __init__(self):
#     def __init__(self, filter):
#     def __init__(self):
# 
# 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__eventloop.py
import collections
    import mock
import grpc
import pytest
    from unittest import mock
from google.cloud.ndb import exceptions
from google.cloud.ndb import _eventloop

        callback = mock.Mock(__name__="callback")
        loop = self._make_one()
        loop.queue_call(5, callback)
        assert loop.run1() is True
        time.sleep.assert_called_once_with(5)
        callback.assert_not_called()

    @mock.patch("google.cloud.ndb._eventloop.time")
    def test_run(self, time):
        time.time.return_value = 0

        def mock_sleep(seconds):
            time.time.return_value += seconds

        time.sleep = mock_sleep
        idler = mock.Mock(__name__="idler")
        idler.return_value = None
        runnow = mock.Mock(__name__="runnow")
        runlater = mock.Mock(__name__="runlater")
        loop = self._make_one()
        loop.add_idle(idler)
        loop.call_soon(runnow)
        loop.queue_call(5, runlater)
        loop.run()
        idler.assert_called_once_with()
        runnow.assert_called_once_with()
        runlater.assert_called_once_with()


def test_get_event_loop(context):

    with pytest.raises(exceptions.ContextError):