def test_tracker_store_from_string(default_domain): endpoints_path = "data/test_endpoints/custom_tracker_endpoints.yml" store_config = utils.read_endpoint_config(endpoints_path, "tracker_store") tracker_store = TrackerStore.find_tracker_store(default_domain, store_config) assert isinstance(tracker_store, ExampleTrackerStore)
def test_file_broker_from_config(): cfg = utils.read_endpoint_config( "data/test_endpoints/event_brokers/" "file_endpoint.yml", "event_broker") actual = broker.from_endpoint_config(cfg) assert isinstance(actual, FileProducer) assert actual.path == "rasa_event.log"
def test_tracker_store_from_invalid_string(default_domain): endpoints_path = "data/test_endpoints/custom_tracker_endpoints.yml" store_config = utils.read_endpoint_config(endpoints_path, "tracker_store") store_config.type = "any string" tracker_store = TrackerStore.find_tracker_store(default_domain, store_config) assert isinstance(tracker_store, InMemoryTrackerStore)
def test_tracker_store_from_invalid_module(default_domain): endpoints_path = "data/test_endpoints/custom_tracker_endpoints.yml" store_config = utils.read_endpoint_config(endpoints_path, "tracker_store") store_config.type = "a.module.which.cannot.be.found" tracker_store = TrackerStore.find_tracker_store(default_domain, store_config) assert isinstance(tracker_store, InMemoryTrackerStore)
def test_pika_broker_from_config(): cfg = utils.read_endpoint_config( 'data/test_endpoints/event_brokers/' 'pika_endpoint.yml', "event_broker") actual = broker.from_endpoint_config(cfg) assert isinstance(actual, PikaProducer) assert actual.host == "localhost" assert actual.credentials.username == "username" assert actual.queue == "queue"
def test_tracker_store_endpoint_config_loading(): cfg = utils.read_endpoint_config(DEFAULT_ENDPOINTS_FILE, "tracker_store") assert cfg == EndpointConfig.from_dict({ "type": "redis", "url": "localhost", "port": 6379, "db": 0, "password": "******", "timeout": 30000 })
def test_find_tracker_store(default_domain): store = utils.read_endpoint_config(DEFAULT_ENDPOINTS_FILE, "tracker_store") tracker_store = RedisTrackerStore(domain=default_domain, host="localhost", port=6379, db=0, password="******", record_exp=3000) assert isinstance( tracker_store, type(TrackerStore.find_tracker_store(default_domain, store)))
def test_kafka_broker_from_config(): endpoints_path = 'data/test_endpoints/event_brokers/' \ 'kafka_plaintext_endpoint.yml' cfg = utils.read_endpoint_config(endpoints_path, "event_broker") actual = KafkaProducer.from_endpoint_config(cfg) expected = KafkaProducer("localhost", "username", "password", topic="topic", security_protocol="SASL_PLAINTEXT") assert actual.host == expected.host assert actual.sasl_username == expected.sasl_username assert actual.sasl_password == expected.sasl_password assert actual.topic == expected.topic
def test_nlg_endpoint_config_loading(): cfg = utils.read_endpoint_config(DEFAULT_ENDPOINTS_FILE, "nlg") assert cfg == EndpointConfig.from_dict( {"url": "http://localhost:5055/nlg"})
def test_no_broker_in_config(): cfg = utils.read_endpoint_config(DEFAULT_ENDPOINTS_FILE, "event_broker") actual = broker.from_endpoint_config(cfg) assert actual is None