当前位置: 首页>>代码示例>>Python>>正文


Python TestClient.create_client_context方法代码示例

本文整理汇总了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))
开发者ID:Freiza,项目名称:program-y,代码行数:32,代码来源:test_file.py

示例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
        """)
开发者ID:Freiza,项目名称:program-y,代码行数:13,代码来源:test_weather.py

示例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"}}]'))
开发者ID:Freiza,项目名称:program-y,代码行数:15,代码来源:test_programy.py

示例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"))
开发者ID:Freiza,项目名称:program-y,代码行数:15,代码来源:test_programy.py

示例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)
开发者ID:Freiza,项目名称:program-y,代码行数:21,代码来源:test_redis.py

示例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")
开发者ID:Freiza,项目名称:program-y,代码行数:5,代码来源:test_geocode.py

示例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")
开发者ID:Freiza,项目名称:program-y,代码行数:6,代码来源:test_rest.py


注:本文中的programytest.aiml_tests.client.TestClient.create_client_context方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。