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


Python client.TestClient类代码示例

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

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

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

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

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

示例6: __init__

 def __init__(self):
     TestClient.__init__(self)
开发者ID:Freiza,项目名称:program-y,代码行数:2,代码来源:test_xml_aiml.py

示例7: __init__

 def __init__(self):
     TestClient.__init__(self, debug=True)
开发者ID:Freiza,项目名称:program-y,代码行数:2,代码来源:test_aiml.py

示例8: __init__

 def __init__(self, mock_scheduler=None):
     self._mock_scheduler = mock_scheduler
     TestClient.__init__(self)
开发者ID:Freiza,项目名称:program-y,代码行数:3,代码来源:test_scheduler.py

示例9: setUp

 def setUp(self):
     client = TestClient()
     self.context = client.create_client_context("testid")
开发者ID:Freiza,项目名称:program-y,代码行数:3,代码来源:test_geocode.py

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


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