本文整理汇总了Python中programytest.aiml_tests.client.TestClient.create_client_context方法的典型用法代码示例。如果您正苦于以下问题:Python TestClient.create_client_context方法的具体用法?Python TestClient.create_client_context怎么用?Python TestClient.create_client_context使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类programytest.aiml_tests.client.TestClient
的用法示例。
在下文中一共展示了TestClient.create_client_context方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_persistence
# 需要导入模块: from programytest.aiml_tests.client import TestClient [as 别名]
# 或者: from programytest.aiml_tests.client.TestClient import create_client_context [as 别名]
def test_persistence(self):
client = TestClient()
client_context = client.create_client_context("testid")
bot_config = BotConfiguration()
bot_config.conversations._type = "file"
bot_config.conversations._storage = BotConversationsFileStorageConfiguration("test")
bot_config.conversations._storage._dir = os.path.dirname(__file__)
bot_config.conversations._max_histories = 3
client_context.bot = Bot(bot_config)
filename = bot_config.conversations._storage._dir + os.sep + client_context.userid + ".convo"
if os.path.exists(filename):
os.remove(filename)
self.assertFalse(os.path.exists(filename))
conversation = client_context.bot.get_conversation(client_context)
conversation.properties['name'] = "fred"
client_context.bot.save_conversation(client_context.userid)
self.assertTrue(os.path.exists(filename))
test_bot2 = Bot(bot_config)
conversation2 = test_bot2.get_conversation(client_context)
self.assertIsNotNone(conversation2.property('name'))
self.assertEqual('fred', conversation2.property('name'))
self.assertTrue(os.path.exists(filename))
if os.path.exists(filename):
os.remove(filename)
self.assertFalse(os.path.exists(filename))
示例2: setUp
# 需要导入模块: from programytest.aiml_tests.client import TestClient [as 别名]
# 或者: from programytest.aiml_tests.client.TestClient import create_client_context [as 别名]
def setUp(self):
client = TestClient()
self.context = client.create_client_context("testid")
bot = unittest.mock.Mock()
self.context.bot = bot
self.context.brain = bot.brain
self.context.client.license_keys.load_license_key_data("""
METOFFICE_API_KEY=TESTKEY
""")
示例3: test_parse_response
# 需要导入模块: from programytest.aiml_tests.client import TestClient [as 别名]
# 或者: from programytest.aiml_tests.client.TestClient import create_client_context [as 别名]
def test_parse_response(self):
client = TestClient()
client_context = client.create_client_context("testid")
config = BrainServiceConfiguration("rest")
config._classname = "programy.testclass"
config._method = "GET"
config._host = "localhost"
config._port = 8080
config._url = "/api/v1.0/ask"
service = ProgramyRESTService(config, api=None)
self.assertEquals("Hello", service._parse_response('[{"response": {"answer": "Hello"}}]'))
示例4: test_format_get_url
# 需要导入模块: from programytest.aiml_tests.client import TestClient [as 别名]
# 或者: from programytest.aiml_tests.client.TestClient import create_client_context [as 别名]
def test_format_get_url(self):
client = TestClient()
client_context = client.create_client_context("testid")
config = BrainServiceConfiguration("rest")
config._classname = "programy.testclass"
config._method = "GET"
config._host = "localhost"
config._port = 8080
config._url = "/api/v1.0/ask"
service = ProgramyRESTService(config, api=None)
self.assertEquals("/api/v1.0/ask?question=Hello&userid=testid", service._format_get_url("/api/v1.0/ask", client_context, "Hello"))
示例5: test_persistence
# 需要导入模块: from programytest.aiml_tests.client import TestClient [as 别名]
# 或者: from programytest.aiml_tests.client.TestClient import create_client_context [as 别名]
def test_persistence(self):
storage_config = BotConversationsRedisStorageConfiguration("redis")
redis = ConversationRedisStorage(storage_config)
self.assertIsNotNone(redis)
client = TestClient()
client_context = client.create_client_context("testid")
conversation1 = Conversation(client_context)
conversation1.set_property("topic", "topic1")
redis.save_conversation(conversation1, client_context.userid)
conversation2 = Conversation(client_context)
redis.load_conversation(conversation2, client_context.userid)
self.assertIsNotNone(conversation2)
self.assertIsNotNone(conversation2.properties)
self.assertEquals(conversation1.properties, conversation2.properties)
示例6: setUp
# 需要导入模块: from programytest.aiml_tests.client import TestClient [as 别名]
# 或者: from programytest.aiml_tests.client.TestClient import create_client_context [as 别名]
def setUp(self):
client = TestClient()
self.context = client.create_client_context("testid")
示例7: setUp
# 需要导入模块: from programytest.aiml_tests.client import TestClient [as 别名]
# 或者: from programytest.aiml_tests.client.TestClient import create_client_context [as 别名]
def setUp(self):
client = TestClient()
self._client_context = client.create_client_context("testid")
self._client_context.client.license_keys.load_license_key_file(os.path.dirname(__file__)+ os.sep + "test.keys")