from rasa.core import run

CREDENTIALS_FILE = "examples/moodbot/credentials.yml"


def test_create_http_input_channels():
    channels = run.create_http_input_channels(None, CREDENTIALS_FILE)
    assert len(channels) == 7

    # ensure correct order
    assert {c.name() for c in channels} == {
        "twilio",
        "slack",
        "telegram",
        "mattermost",
        "facebook",
        "webexteams",
        "rocketchat",
    }


def test_create_single_input_channels():
    channels = run.create_http_input_channels("facebook", CREDENTIALS_FILE)
    assert len(channels) == 1
    assert channels[0].name() == "facebook"


def test_create_single_input_channels_by_class():
    channels = run.create_http_input_channels(
        "rasa.core.channels.channel.RestInput", CREDENTIALS_FILE
    )
    assert len(channels) == 1
    assert channels[0].name() == "rest"


def test_create_single_input_channels_by_class_wo_credentials():
    channels = run.create_http_input_channels(
        "rasa.core.channels.channel.RestInput", credentials_file=None
    )

    assert len(channels) == 1
    assert channels[0].name() == "rest"

@@ -1,8 +1,22 @@
+import pytest%0A
 from ras
@@ -32,16 +32,94 @@
 port run
+, interpreter, policies, domain%0Afrom rasa.core.utils import AvailableEndpoints
 %0A%0ACREDEN
@@ -1173,32 +1173,32 @@
 (channels) == 1%0A
-
     assert chann
@@ -1201,28 +1201,1215 @@
 hannels%5B0%5D.name() == %22rest%22%0A
+%0A%0Aasync def test_load_agent_on_start_with_good_model_file(%0A    trained_rasa_model, rasa_server, loop,%0A):%0A    agent = await run.load_agent_on_start(%0A        trained_rasa_model, AvailableEndpoints(), None, rasa_server, loop,%0A    )%0A%0A    assert isinstance(agent.interpreter, interpreter.RasaNLUInterpreter)%0A    assert isinstance(agent.policy_ensemble, policies.PolicyEnsemble)%0A    assert isinstance(agent.domain, domain.Domain)%0A%0A%0Aasync def test_load_agent_on_start_with_bad_model_file(%0A    tmpdir, rasa_server, loop,%0A):%0A    from pathlib import Path%0A%0A    fake_model = Path(tmpdir) / %22fake_model.tar.gz%22%0A    fake_model.touch()%0A    fake_model_path = str(fake_model)%0A%0A    with pytest.warns(UserWarning) as warnings:%0A        agent = await run.load_agent_on_start(%0A            fake_model_path, AvailableEndpoints(), None, rasa_server, loop,%0A        )%0A        assert any(%0A            %22fake_model.tar.gz' could not be loaded%22 in str(w.message) for w in warnings%0A        )%0A    %0A    # Fallback agent was loaded even if model was unusable%0A    assert isinstance(agent.interpreter, interpreter.RegexInterpreter)%0A    assert agent.policy_ensemble is None%0A    assert isinstance(agent.domain, domain.Domain)%0A

add unit tests for load_agent_on_start