from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from httpretty import httpretty
from builtins import str

from rasa_core.channels import console
from tests import utilities
import json


def test_console_input():
    import rasa_core.channels.console

    # Overwrites the input() function and when someone else tries to read
    # something from the command line this function gets called.
    with utilities.mocked_cmd_input(rasa_core.channels.console,
                                    text="Test Input"):
        httpretty.register_uri(httpretty.POST,
                               'https://abc.defg/webhooks/rest/webhook',
                               body='')

        httpretty.enable()
        console.record_messages(
                server_url="https://abc.defg",
                max_message_limit=3)
        httpretty.disable()

        assert (httpretty.latest_requests[-1].path ==
                "/webhooks/rest/webhook?stream=true&token=")

        assert (json.loads(str(httpretty.latest_requests[-1].body)) ==
                {"message": "Test Input", "sender": "default"})

@@ -1068,31 +1068,12 @@
     
-assert (json.loads(str(
+b = 
 http
@@ -1106,29 +1106,57 @@
 body
-)) ==%0A               
+.decode(%22utf-8%22)%0A%0A        assert json.loads(b) ==
  %7B%22m
@@ -1198,10 +1198,9 @@
 efault%22%7D
-)
 %0A

decode httpretty body