本文整理汇总了Python中programytest.aiml_tests.client.TestClient类的典型用法代码示例。如果您正苦于以下问题:Python TestClient类的具体用法?Python TestClient怎么用?Python TestClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestClient类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_persistence
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
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
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
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
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: __init__
def __init__(self):
TestClient.__init__(self)
示例7: __init__
def __init__(self):
TestClient.__init__(self, debug=True)
示例8: __init__
def __init__(self, mock_scheduler=None):
self._mock_scheduler = mock_scheduler
TestClient.__init__(self)
示例9: setUp
def setUp(self):
client = TestClient()
self.context = client.create_client_context("testid")
示例10: setUp
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")