def test_nluCall(self): nlu_config = BrainNluConfiguration() nlu_request = NluRequest(nlu_config) self.assertIsNotNone(nlu_request) self.assertIsInstance(nlu_request, NluRequest) with self.assertRaises(NotImplementedError): nlu_request.nluCall(None, "http://test_nlu.co.jp", "apikey", "Test")
def __init__(self, config): NluRequest.__init__(self, config) self._requests_api = requests self._status_code = '' self._latency = '' self._start_time = None self._end_time = None
def test_nlu_initiate(self): nlu_config = BrainNluConfiguration() nlu_config._classname = "programy.nlu.cotobadesignNlu.CotobadesignNlu" nlu = NluRequest.load_nlu(nlu_config) self.assertIsNotNone(nlu) self.assertIsInstance(nlu, CotobadesignNlu)
def test_nluCall(self): nlu_config = BrainNluConfiguration() nlu_config._classname = "programy.nlu.cotobadesignNlu.CotobadesignNlu" nlu = NluRequest.load_nlu(nlu_config) self.assertIsNotNone(nlu) self.assertIsInstance(nlu, CotobadesignNlu) response_data = '{"intents": [], "slots": []}' request_api = MockCotobadesignNluAPI(response=response_data) nlu.set_request_api(request_api) response = nlu.nluCall(None, "http://test.co.jp", "apikey", "Test") self.assertEqual(response, '{"intents": [], "slots": []}')
def test_nluCall_exception(self): nlu_config = BrainNluConfiguration() nlu_config._classname = "programy.nlu.cotobadesignNlu.CotobadesignNlu" nlu = NluRequest.load_nlu(nlu_config) self.assertIsNotNone(nlu) self.assertIsInstance(nlu, CotobadesignNlu) response_data = "" request_api = MockCotobadesignNluAPI(response=response_data, exception=True) nlu.set_request_api(request_api) response = nlu.nluCall(None, "http://test.co.jp", "apikey", "Test") self.assertIsNone(response)
def __init__(self, bot, configuration: BrainConfiguration): assert (bot is not None) assert (configuration is not None) self._bot = bot self._configuration = configuration self._binaries = BinariesManager(configuration.binaries) self._braintree = BraintreeManager(configuration.braintree) self._tokenizer = Tokenizer.load_tokenizer(configuration) self._denormal_collection = DenormalCollection() self._normal_collection = NormalCollection() self._gender_collection = GenderCollection() self._person_collection = PersonCollection() self._person2_collection = Person2Collection() self._rdf_collection = RDFCollection() self._sets_collection = SetCollection() self._maps_collection = MapCollection() self._properties_collection = PropertiesCollection() self._default_variables_collection = DefaultVariablesCollection() self._preprocessors = PreProcessorCollection() self._postprocessors = PostProcessorCollection() self._pattern_factory = None self._template_factory = None self._security = SecurityManager(configuration.security) self._oobhandler = OOBHandler(configuration.oob) self._regex_templates = RegexTemplatesCollection() self._dynamics_collection = DynamicsCollection() self._aiml_parser = self.load_aiml_parser() self._nlu_collection = NluCollection(bot.client, configuration.nlu) self._nlu = NluRequest.load_nlu(configuration.nlu) self._nlu_utterance = None self.load(self.configuration)
def __init__(self, bot, configuration: BrainConfiguration): assert (bot is not None) assert (configuration is not None) self._bot = bot self._configuration = configuration self._binaries = BinariesManager(configuration.binaries) self._braintree = BraintreeManager(configuration.braintree) self._tokenizer = Tokenizer.load_tokenizer(configuration) if configuration.debugfiles.save_errors_collection is True: errors_dict = {} else: errors_dict = None self._denormal_collection = DenormalCollection(errors_dict) self._normal_collection = NormalCollection(errors_dict) self._gender_collection = GenderCollection(errors_dict) self._person_collection = PersonCollection(errors_dict) self._person2_collection = Person2Collection(errors_dict) self._rdf_collection = RDFCollection(errors_dict) self._sets_collection = SetCollection(errors_dict) self._maps_collection = MapCollection(errors_dict) self._properties_collection = PropertiesCollection(errors_dict) self._default_variables_collection = DefaultVariablesCollection( errors_dict) self._botnames_collection = BotNamesCollection(errors_dict) self._preprocessors = PreProcessorCollection(errors_dict) self._postprocessors = PostProcessorCollection(errors_dict) self._pattern_factory = None self._template_factory = None self._security = SecurityManager(configuration.security) self._oobhandler = OOBHandler(configuration.oob) self._regex_templates = RegexTemplatesCollection(errors_dict) self._dynamics_collection = DynamicsCollection() self._aiml_parser = self.load_aiml_parser() self._nlu_collection = NluCollection(bot.client, configuration.nlu, errors_dict) self._nlu = NluRequest.load_nlu(configuration.nlu) self._nlu_utterance = None self.load(self.configuration) if configuration.debugfiles.save_errors_collection is True: storage_factory = self.bot.client.storage_factory if storage_factory.entity_storage_engine_available( StorageFactory.ERRORS_COLLECTION) is True: errors_collection_engine = storage_factory.entity_storage_engine( StorageFactory.ERRORS_COLLECTION) errors_collection_store = errors_collection_engine.errors_collection_store( ) errors_collection_store.save_errors_collection(errors_dict)
def __init__(self, config): NluRequest.__init__(self, config) self._requests_api = requests
def test_load_nlu_no_classname(self): nlu_config = BrainNluConfiguration() nlu_config._classname = None nlu = NluRequest.load_nlu(nlu_config) self.assertIsNone(nlu)
def test_load_nlu(self): nlu_config = BrainNluConfiguration() nlu = NluRequest.load_nlu(nlu_config) self.assertIsNotNone(nlu) self.assertIsInstance(nlu, NluRequest)
def test_nlu_initiate(self): nlu_config = BrainNluConfiguration() nlu_request = NluRequest(nlu_config) self.assertIsNotNone(nlu_request) self.assertIsInstance(nlu_request, NluRequest)