# Path: tests/base.py
# class Test(unittest.TestCase):
#     test_timeout = 1
# 
#     def setUp(self):
#         import zorro
#         from zorro import zmq
#         self.z = zorro
#         self.hub = self.z.Hub()
#         self.thread = threading.Thread(target=self.hub.run)
# 
#     def tearDown(self):
#         if not self.hub.stopping:
#             self.hub.stop()
#         self.thread.join(self.test_timeout)
#         if self.thread.is_alive():
#             try:
#                 if not getattr(self, 'should_timeout', False):
#                     raise AssertionError("test timed out")
#             finally:
#                 self.hub.crash()
#                 self.thread.join()
#         for key in list(sys.modules.keys()):
#             if key == 'zorro' or key.startswith('zorro.'):
#                 del sys.modules[key]
# 
# def passive(zfun):
#     @wraps(zfun)
#     def wrapping(self, *a, **kw):
#         exc = []
#         def catch():
#             try:
#                 zfun(self, *a, **kw)
#             except BaseException as e:
#                 exc.append(e)
#         self.hub.add_task(catch)
#         self.thread.start()
#         try:
#             self.thread.join(self.test_timeout)
#         finally:
#             if exc:
#                 raise exc[0]
#     return wrapping


import socket
        import zorro.mongodb
    import unittest
from functools import partial
from .base import Test, passive
# -*- coding: utf-8 -*-



class Mongodb(Test):

    def setUp(self):
        super().setUp()
        self.m = zorro.mongodb.Connection()
        self.c = self.m['test']['test_collection']

    def query_data(self, *args, **kw):
        lst = list(self.c.query(*args, **kw))
        for i in lst: i.pop('_id')
        return lst


class Simple(Mongodb):


# Path: tests/base.py
# class Test(unittest.TestCase):
#     test_timeout = 1
# 
#     def setUp(self):
#         import zorro
#         from zorro import zmq
#         self.z = zorro
#         self.hub = self.z.Hub()
#         self.thread = threading.Thread(target=self.hub.run)
# 
#     def tearDown(self):
#         if not self.hub.stopping:
#             self.hub.stop()
#         self.thread.join(self.test_timeout)
#         if self.thread.is_alive():
#             try:
#                 if not getattr(self, 'should_timeout', False):
#                     raise AssertionError("test timed out")
#             finally:
#                 self.hub.crash()
#                 self.thread.join()
#         for key in list(sys.modules.keys()):
#             if key == 'zorro' or key.startswith('zorro.'):
#                 del sys.modules[key]
# 
# def passive(zfun):
#     @wraps(zfun)
#     def wrapping(self, *a, **kw):
#         exc = []
#         def catch():
#             try:
#                 zfun(self, *a, **kw)
#             except BaseException as e:
#                 exc.append(e)
#         self.hub.add_task(catch)
#         self.thread.start()
#         try:
#             self.thread.join(self.test_timeout)
#         finally:
#             if exc:
#                 raise exc[0]
#     return wrapping


# Path: tests/test_mongodb.py
import socket
        import zorro.mongodb
    import unittest
from functools import partial
from .base import Test, passive

# -*- coding: utf-8 -*-



class Mongodb(Test):

    def setUp(self):
        super().setUp()
        self.m = zorro.mongodb.Connection()
        self.c = self.m['test']['test_collection']

    def query_data(self, *args, **kw):
        lst = list(self.c.query(*args, **kw))
        for i in lst: i.pop('_id')
        return lst


class Simple(Mongodb):


    @passive