Example #1
0
def test_remote_action_factory_module_import():
    instantiated_actions = action_factory_by_name("remote")(
            ["random_name", "utter_test"], None,
            ["utter_test"])
    assert len(instantiated_actions) == 2
    assert isinstance(instantiated_actions[0], RemoteAction)
    assert isinstance(instantiated_actions[1], RemoteAction)
def test_remote_action_factory_module_import():
    instantiated_actions = action_factory_by_name("remote")(
        ["action_listen", "random_name", "utter_test"], ["utter_test"])
    assert len(instantiated_actions) == 3
    assert isinstance(instantiated_actions[0], ActionListen)
    assert isinstance(instantiated_actions[1], RemoteAction)
    assert isinstance(instantiated_actions[2], RemoteAction)
Example #3
0
def test_local_action_factory_module_import():
    instantiated_actions = action_factory_by_name("local")(
        ["rasa_core.actions.action.ActionRestart", "utter_test"], None,
        ["utter_test"])
    assert len(instantiated_actions) == 2
    assert isinstance(instantiated_actions[0], ActionRestart)
    assert isinstance(instantiated_actions[1], UtterAction)
Example #4
0
def test_remote_action_factory_preferes_action_names():
    instantiated_actions = action_factory_by_name("remote")(
        ["my_module.ActionTest", "utter_test"], ["action_test", "utter_test"],
        ["utter_test"])
    assert len(instantiated_actions) == 2
    assert instantiated_actions[0].name() == "action_test"
    assert instantiated_actions[1].name() == "utter_test"
Example #5
0
 def instantiate_actions(factory_name, action_classes, action_names,
                         templates):
     action_factory = action_factory_by_name(factory_name)
     custom_actions = action_factory(action_classes, action_names, templates)
     actions = Domain.DEFAULT_ACTIONS[:] + custom_actions
     ensure_action_name_uniqueness(actions)
     return actions
Example #6
0
 def instantiate_actions(factory_name, action_classes, action_names,
                         templates):
     action_factory = action_factory_by_name(factory_name)
     custom_actions = action_factory(action_classes, action_names, templates)
     actions = Domain.DEFAULT_ACTIONS[:] + custom_actions
     ensure_action_name_uniqueness(actions)
     return actions
Example #7
0
def test_local_action_factory_module_import():
    instantiated_actions = action_factory_by_name("local")(
            ["rasa_core.actions.action.ActionRestart",
             "utter_test"], None, ["utter_test"])
    assert len(instantiated_actions) == 2
    assert isinstance(instantiated_actions[0], ActionRestart)
    assert isinstance(instantiated_actions[1], UtterAction)
def test_local_action_factory_module_import():
    instantiated_actions = action_factory_by_name("local")([
        "action_listen", "rasa_core.actions.action.ActionListen", "utter_test"
    ], ["utter_test"])
    assert len(instantiated_actions) == 3
    assert isinstance(instantiated_actions[0], ActionListen)
    assert isinstance(instantiated_actions[1], ActionListen)
    assert isinstance(instantiated_actions[2], UtterAction)
Example #9
0
def test_remote_action_factory_preferes_action_names():
    instantiated_actions = action_factory_by_name("remote")(
            ["my_module.ActionTest", "utter_test"],
            ["action_test", "utter_test"],
            ["utter_test"])
    assert len(instantiated_actions) == 2
    assert instantiated_actions[0].name() == "action_test"
    assert instantiated_actions[1].name() == "utter_test"
Example #10
0
def test_local_action_factory_module_import():
    instantiated_actions = action_factory_by_name("local")(
            ["action_listen", "examples.concerts.actions.ActionSearchConcerts",
             "utter_test"], ["utter_test"])
    assert len(instantiated_actions) == 3
    assert isinstance(instantiated_actions[0], ActionListen)
    assert isinstance(instantiated_actions[1], ActionSearchConcerts)
    assert isinstance(instantiated_actions[2], UtterAction)
def test_local_action_factory_module_import_fails_on_invalid():
    with pytest.raises(ValueError):
        action_factory_by_name("local")(["random_name"], ["utter_test"])

    with pytest.raises(ValueError):
        action_factory_by_name("local")(["utter_default"], ["utter_test"])

    with pytest.raises(ValueError):
        action_factory_by_name("local")(["examples.UnavailableClass"],
                                        ["utter_test"])

    with pytest.raises(ValueError):
        action_factory_by_name("local")(["nonexistant.UnavailableClass"],
                                        ["utter_test"])
Example #12
0
def test_local_action_factory_module_import_fails_on_invalid():
    with pytest.raises(ValueError):
        action_factory_by_name("local")(["random_name"], None, ["utter_test"])

    with pytest.raises(ValueError):
        action_factory_by_name("local")(["utter_default"], None, ["utter_test"])

    with pytest.raises(ValueError):
        action_factory_by_name("local")(["examples.UnavailableClass"],
                                        None,
                                        ["utter_test"])

    with pytest.raises(ValueError):
        action_factory_by_name("local")(["nonexistant.UnavailableClass"],
                                        None,
                                        ["utter_test"])
def test_action_factories():
    assert action_factory_by_name("local") is not None
    assert action_factory_by_name("remote") is not None
    with pytest.raises(Exception):
        action_factory_by_name("unknown_name")
Example #14
0
def test_local_action_factory_fails_on_duplicated_actions():
    with pytest.raises(ValueError):
        action_factory_by_name("local")([
            "action_listen", "rasa_core.actions.action.ActionListen",
            "utter_test"
        ], ["utter_test"])
Example #15
0
def test_action_factories():
    assert action_factory_by_name("local") is not None
    assert action_factory_by_name("remote") is not None
    with pytest.raises(Exception):
        action_factory_by_name("unknown_name")
Example #16
0
 def instantiate_actions(facotry_name, action_names, templates):
     default_actions = [a.name() for a in Domain.DEFAULT_ACTIONS]
     action_factory = action_factory_by_name(facotry_name)
     return action_factory(default_actions + action_names, templates)
Example #17
0
def test_remote_action_factory_fails_on_duplicated_actions():
    with pytest.raises(ValueError):
        action_factory_by_name("remote")(
            ["action_listen", "random_name", "random_name"], ["utter_test"])