import hmac

import pytest
import tornado.web

from ..meeseeksbox.core import Authenticator, Config, WebHookHandler

commands = {}

config = Config(
    integration_id=100,
    key=None,
    personal_account_token="foo",
    personal_account_name="bar",
    forward_staging_url="",
    webhook_secret="foo",
)

auth = Authenticator(
    config.integration_id, config.key, config.personal_account_token, config.personal_account_name
)

application = tornado.web.Application(
    [
        (
            r"/",
            WebHookHandler,
            {
                "actions": commands,
                "config": config,
                "auth": auth,
            },
        ),
    ]
)


@pytest.fixture
def app():
    return application


@pytest.mark.gen_test
def test_get(http_client, base_url):
    response = yield http_client.fetch(base_url)
    assert response.code == 200


@pytest.mark.gen_test
def test_post(http_client, base_url):
    body = "{}"
    secret = config.webhook_secret
    assert secret is not None
    sig = "sha1=" + hmac.new(secret.encode("utf8"), body.encode("utf8"), "sha1").hexdigest()
    headers = {"X-Hub-Signature": sig}
    response = yield http_client.fetch(base_url, method="POST", body=body, headers=headers)
    assert response.code == 200

@@ -732,38 +732,22 @@
 ation%0A%0A%0A
-@pytest.mark.gen_test%0A
+async 
 def test
@@ -756,32 +756,29 @@
 et(http_
-client, base_url
+server_client
 ):%0A    r
@@ -783,35 +783,42 @@
  response = 
-yield
+await
  http_
+server_
 client.fetch
@@ -818,24 +818,19 @@
 t.fetch(
-base_url
+%22/%22
 )%0A    as
@@ -861,30 +861,14 @@
 0%0A%0A%0A
-@pytest.mark.gen_test%0A
+async 
 def 
@@ -886,24 +886,21 @@
 ttp_
-client, base_url
+server_client
 ):%0A 
@@ -1130,19 +1130,26 @@
 e = 
-yield
+await
  http_
+server_
 clie
@@ -1161,16 +1161,11 @@
 tch(
-base_url
+%22/%22
 , me

fix tests