# Path: sockjs/protocol.py
# ENCODING = "utf-8"
# STATE_NEW = 0
# STATE_OPEN = 1
# STATE_CLOSING = 2
# STATE_CLOSED = 3
# FRAME_OPEN = "o"
# FRAME_CLOSE = "c"
# FRAME_MESSAGE = "a"
# FRAME_MESSAGE_BLOB = "a1"
# FRAME_HEARTBEAT = "h"
# IFRAME_HTML = """<!DOCTYPE html>
# <html>
# <head>
# <meta http-equiv="X-UA-Compatible" content="IE=edge" />
# <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
#   <script src="%s"></script>
#   <script>
#     document.domain = document.domain;
#     SockJS.bootstrap_iframe();
#   </script>
# </head>
# <body>
#   <h2>Don't panic!</h2>
#   <p>This is a SockJS hidden iframe. It's used for cross domain magic.</p>
# </body>
# </html>
# """.strip()
# IFRAME_MD5 = hashlib.md5(IFRAME_HTML.encode()).hexdigest()
# ENCODING = "utf-8"
# MSG_OPEN = 1
# MSG_MESSAGE = 2
# MSG_CLOSE = 3
# MSG_CLOSED = 4
#     def dthandler(obj):
# def dumps(data):
# def close_frame(code, reason):
# def message_frame(message):
# def messages_frame(messages):
#     def tp(self):
# class SockjsMessage(collections.namedtuple("SockjsMessage", ["type", "data"])):


import asyncio
from aiohttp import web
from multidict import CIMultiDict
from sockjs import protocol




async def test_info(make_route, make_request):
    route = make_route()
    request = make_request("GET", "/sm/")

    response = await route.info(request)
    info = protocol.loads(response.body.decode("utf-8"))

    assert info["websocket"]
    assert info["cookie_needed"]


async def test_info_entropy(make_route, make_request):
    route = make_route()
    request = make_request("GET", "/sm/")

    response = await route.info(request)
    entropy1 = protocol.loads(response.body.decode("utf-8"))["entropy"]

    response = await route.info(request)

# Path: sockjs/protocol.py
# ENCODING = "utf-8"
# STATE_NEW = 0
# STATE_OPEN = 1
# STATE_CLOSING = 2
# STATE_CLOSED = 3
# FRAME_OPEN = "o"
# FRAME_CLOSE = "c"
# FRAME_MESSAGE = "a"
# FRAME_MESSAGE_BLOB = "a1"
# FRAME_HEARTBEAT = "h"
# IFRAME_HTML = """<!DOCTYPE html>
# <html>
# <head>
# <meta http-equiv="X-UA-Compatible" content="IE=edge" />
# <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
#   <script src="%s"></script>
#   <script>
#     document.domain = document.domain;
#     SockJS.bootstrap_iframe();
#   </script>
# </head>
# <body>
#   <h2>Don't panic!</h2>
#   <p>This is a SockJS hidden iframe. It's used for cross domain magic.</p>
# </body>
# </html>
# """.strip()
# IFRAME_MD5 = hashlib.md5(IFRAME_HTML.encode()).hexdigest()
# ENCODING = "utf-8"
# MSG_OPEN = 1
# MSG_MESSAGE = 2
# MSG_CLOSE = 3
# MSG_CLOSED = 4
#     def dthandler(obj):
# def dumps(data):
# def close_frame(code, reason):
# def message_frame(message):
# def messages_frame(messages):
#     def tp(self):
# class SockjsMessage(collections.namedtuple("SockjsMessage", ["type", "data"])):


# Path: tests/test_route.py
import asyncio
from aiohttp import web
from multidict import CIMultiDict
from sockjs import protocol





async def test_info(make_route, make_request):
    route = make_route()
    request = make_request("GET", "/sm/")

    response = await route.info(request)
    info = protocol.loads(response.body.decode("utf-8"))

    assert info["websocket"]
    assert info["cookie_needed"]


async def test_info_entropy(make_route, make_request):
    route = make_route()
    request = make_request("GET", "/sm/")

    response = await route.info(request)
    entropy1 = protocol.loads(response.body.decode("utf-8"))["entropy"]

    response = await route.info(request)

    entropy2 = protocol.loads(response.body.decode("utf-8"))["entropy"]