Beispiel #1
0
 def test_get_default_response_nothing(self):
     config = ServiceConfiguration.from_data("generic", "test", "category")
     service = Service(config)
     client = TestClient()
     client_context = client.create_client_context("testuser")
     self.assertEqual("Service failed to return valid response",
                      service._get_default_response(client_context))
Beispiel #2
0
 def test_init_empty_config(self):
     config = ServiceConfiguration.from_data("generic", "test", "category")
     service = Service(config)
     self.assertIsNotNone(service)
     self.assertEqual(service.configuration, config)
     self.assertEquals([], service.patterns())
     self.assertIsNone(service.get_default_aiml_file())
Beispiel #3
0
    def test_load_default_aiml_by_class(self):
        config = ServiceConfiguration.from_data("generic", "test", "category")
        service = Service(config)
        self.assertIsNotNone(service)

        mock_aiml_parser = Mock()
        mock_aiml_parser.parse_from_file.return_value = True
        self.assertTrue(service.load_default_aiml(mock_aiml_parser))
Beispiel #4
0
 def test_get_default_response_default_srai(self):
     config = ServiceConfiguration.from_data(
         "generic", "test", "category", default_srai="TEST SERVICE FAILURE")
     service = Service(config)
     client = TestClient()
     client_context = client.create_client_context("testuser")
     self.assertEqual("Default srai response",
                      service._get_default_response(client_context))
Beispiel #5
0
 def test_get_default_response_default_response(self):
     config = ServiceConfiguration.from_data(
         "generic",
         "test",
         "category",
         default_response="This is the default response")
     service = Service(config)
     client = TestClient()
     client_context = client.create_client_context("testuser")
     self.assertEqual("This is the default response",
                      service._get_default_response(client_context))
Beispiel #6
0
 def test_init_defined_config(self):
     config = ServiceConfiguration.from_data(
         "generic",
         "test",
         "category",
         service_class="testclass",
         default_response="default response",
         default_srai="default srai",
         storage="file",
         default_aiml="default.aiml")
     service = Service(config)
     self.assertIsNotNone(service)
     self.assertEqual(service.configuration, config)
     self.assertEqual("test", service.name)
     self.assertEqual("category", service.category)
     self.assertEquals([], service.patterns())
     client = TestClient()
     self.assertIsNone(service.get_default_aiml_file())