Exemplo n.º 1
0
def test_channel_inheritance():
    from rasa.core.channels import RestInput
    from rasa.core.channels.rasa_chat import RasaChatInput

    rasa_input = RasaChatInput("https://example.com")

    s = rasa.core.run.configure_app([RestInput(), rasa_input], port=5004)

    routes_list = utils.list_routes(s)
    assert routes_list["custom_webhook_RasaChatInput.health"].startswith(
        "/webhooks/rasa")
    assert routes_list["custom_webhook_RasaChatInput.receive"].startswith(
        "/webhooks/rasa/webhook")
Exemplo n.º 2
0
async def test_rasa_chat_input():
    from rasa.core.channels import RasaChatInput

    rasa_x_api_url = "https://rasa-x.com:5002"
    rasa_chat_input = RasaChatInput(rasa_x_api_url)
    public_key = "random_key123"
    jwt_algorithm = "RS256"
    with aioresponses() as mocked:
        mocked.get(
            rasa_x_api_url + "/version",
            payload={"keys": [{"key": public_key, "alg": jwt_algorithm}]},
            repeat=True,
            status=200,
        )
        await rasa_chat_input._fetch_public_key()
        assert rasa_chat_input.jwt_key == public_key
        assert rasa_chat_input.jwt_algorithm == jwt_algorithm
Exemplo n.º 3
0
def test_channel_inheritance():
    from rasa.core.channels import RestInput
    from rasa.core.channels import RasaChatInput
    from rasa.core.agent import Agent
    from rasa.core.interpreter import RegexInterpreter

    # load your trained agent
    agent = Agent.load(MODEL_PATH, interpreter=RegexInterpreter())

    rasa_input = RasaChatInput("https://example.com")

    s = agent.handle_channels([RestInput(), rasa_input], 5004)

    routes_list = utils.list_routes(s)
    assert routes_list.get("custom_webhook_RasaChatInput.health").startswith(
        "/webhooks/rasa")
    assert routes_list.get("custom_webhook_RasaChatInput.receive").startswith(
        "/webhooks/rasa/webhook")
Exemplo n.º 4
0
def test_has_user_permission_to_send_messages_to_conversation_without_permission(
        jwt: Dict, message: Dict):
    assert not RasaChatInput._has_user_permission_to_send_messages_to_conversation(
        jwt, message)