def ask_for_action(self, action_name, action_endpoint): if action_name not in self.agent.domain.action_names: logger.warning("action not found") return None defaults = {a.name(): a for a in action.default_actions()} if action_name in defaults and action_name not in self.agent.domain.user_actions: return defaults.get(action_name) elif action_name.startswith("utter_"): return UtterAction(action_name) else: return RemoteAction(action_name, action_endpoint)
def test_interactive_domain_persistence(mock_endpoint, tmpdir): # Test method interactive._write_domain_to_file tracker_dump = "data/test_trackers/tracker_moodbot.json" tracker_json = utils.read_json_file(tracker_dump) events = tracker_json.get("events", []) domain_path = tmpdir.join("interactive_domain_save.yml").strpath url = '{}/domain'.format(mock_endpoint.url) httpretty.register_uri(httpretty.GET, url, body='{}') httpretty.enable() interactive._write_domain_to_file(domain_path, events, mock_endpoint) httpretty.disable() saved_domain = utils.read_yaml_file(domain_path) for default_action in default_actions(): assert default_action.name() not in saved_domain["actions"]
async def test_interactive_domain_persistence(mock_endpoint, tmpdir): # Test method interactive._write_domain_to_file tracker_dump = "data/test_trackers/tracker_moodbot.json" tracker_json = utils.read_json_file(tracker_dump) events = tracker_json.get("events", []) domain_path = tmpdir.join("interactive_domain_save.yml").strpath url = '{}/domain'.format(mock_endpoint.url) with aioresponses() as mocked: mocked.get(url, payload={}) await interactive._write_domain_to_file(domain_path, events, mock_endpoint) saved_domain = utils.read_yaml_file(domain_path) for default_action in default_actions(): assert default_action.name() not in saved_domain["actions"]