# 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 interactive(zfun):
#     def wrapper(fun):
#         @wraps(fun)
#         def wrapping(self, *a, **kw):
#             self.hub.add_task(partial(zfun, self, *a, **kw))
#             self.thread.start()
#             fun(self, *a, **kw)
#         return wrapping
#     return wrapper


import os.path
import time
import ssl
import socket
        import zorro.http
        import zorro.http
        import zorro.http
    import unittest
from socketserver import BaseServer
from http.server import HTTPServer, BaseHTTPRequestHandler
from .base import Test, interactive

    def do_GET(self):
        self.send_response(200)
        self.send_header('Content-Length', '5')
        self.end_headers()
        self.wfile.write(b'HELLO')
        self.wfile.flush()

    def do_POST(self):
        self.send_response(200)
        self.send_header('Content-Length', str(len(BIGDATA)))
        self.end_headers()
        self.wfile.write(BIGDATA)
        self.wfile.flush()

    def do_FETCH(self):
        self.send_response(200)
        self.send_header('Transfer-Encoding', 'chunked')
        self.end_headers()
        self.wfile.write(b'5\r\nHELLO\r\n0\r\n\r\n')
        self.wfile.flush()


class Simple(Test):

    def do_request(self):
        self.z.sleep(0.1)
        cli = self.z.http.HTTPSClient('localhost', 9997)
        self.got_value = cli.request('/').body


# 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 interactive(zfun):
#     def wrapper(fun):
#         @wraps(fun)
#         def wrapping(self, *a, **kw):
#             self.hub.add_task(partial(zfun, self, *a, **kw))
#             self.thread.start()
#             fun(self, *a, **kw)
#         return wrapping
#     return wrapper


# Path: tests/test_https.py
import os.path
import time
import ssl
import socket
        import zorro.http
        import zorro.http
        import zorro.http
    import unittest
from socketserver import BaseServer
from http.server import HTTPServer, BaseHTTPRequestHandler
from .base import Test, interactive


    def do_GET(self):
        self.send_response(200)
        self.send_header('Content-Length', '5')
        self.end_headers()
        self.wfile.write(b'HELLO')
        self.wfile.flush()

    def do_POST(self):
        self.send_response(200)
        self.send_header('Content-Length', str(len(BIGDATA)))
        self.end_headers()
        self.wfile.write(BIGDATA)
        self.wfile.flush()

    def do_FETCH(self):
        self.send_response(200)
        self.send_header('Transfer-Encoding', 'chunked')
        self.end_headers()
        self.wfile.write(b'5\r\nHELLO\r\n0\r\n\r\n')
        self.wfile.flush()


class Simple(Test):

    def do_request(self):
        self.z.sleep(0.1)
        cli = self.z.http.HTTPSClient('localhost', 9997)
        self.got_value = cli.request('/').body


    @interactive(do_request)