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


Python KeenClient.generate_image_beacon方法代码示例

本文整理汇总了Python中keen.client.KeenClient.generate_image_beacon方法的典型用法代码示例。如果您正苦于以下问题:Python KeenClient.generate_image_beacon方法的具体用法?Python KeenClient.generate_image_beacon怎么用?Python KeenClient.generate_image_beacon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在keen.client.KeenClient的用法示例。


在下文中一共展示了KeenClient.generate_image_beacon方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_generate_image_beacon

# 需要导入模块: from keen.client import KeenClient [as 别名]
# 或者: from keen.client.KeenClient import generate_image_beacon [as 别名]
    def test_generate_image_beacon(self):
        keen.project_id = "5004ded1163d66114f000000"
        api_key = "2e79c6ec1d0145be8891bf668599c79a"
        keen.write_key = scoped_keys.encrypt(api_key, {"allowed_operations": ["write"]})

        event_collection = "python_test hello!?"
        event_data = {"a": "b"}
        data = self.base64_encode(json.dumps(event_data))

        # module level should work
        url = keen.generate_image_beacon(event_collection, event_data)
        expected = "https://api.keen.io/3.0/projects/{0}/events/{1}?api_key={2}&data={3}".format(
            keen.project_id, self.url_escape(event_collection), keen.write_key.decode(sys.getdefaultencoding()), data
        )
        self.assert_equal(expected, url)

        # so should instance level
        client = KeenClient(keen.project_id, write_key=keen.write_key, read_key=None)
        url = client.generate_image_beacon(event_collection, event_data)
        self.assert_equal(expected, url)

        # make sure URL works
        response = requests.get(url)
        self.assert_equal(200, response.status_code)
        self.assert_equal(b"GIF89a\x01\x00\x01\x00\x80\x01\x00\xff\xff\xff\x00\x00\x00!\xf9\x04\x01\n\x00\x01\x00,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02L\x01\x00;",
                          response.content)
开发者ID:ChrisNolan1992,项目名称:KeenClient-Python,代码行数:28,代码来源:client_tests.py

示例2: test_generate_image_beacon

# 需要导入模块: from keen.client import KeenClient [as 别名]
# 或者: from keen.client.KeenClient import generate_image_beacon [as 别名]
    def test_generate_image_beacon(self, post):
        event_collection = "python_test hello!?"
        event_data = {"a": "b"}
        data = self.base64_encode(json.dumps(event_data))

        # module level should work
        url = keen.generate_image_beacon(event_collection, event_data)
        expected = "https://api.keen.io/3.0/projects/{0}/events/{1}?api_key={2}&data={3}".format(
            keen.project_id, self.url_escape(event_collection), keen.write_key.decode(sys.getdefaultencoding()), data
        )
        self.assert_equal(expected, url)

        # so should instance level
        client = KeenClient(keen.project_id, write_key=keen.write_key, read_key=None)
        url = client.generate_image_beacon(event_collection, event_data)
        self.assert_equal(expected, url)
开发者ID:isotoma,项目名称:KeenClient-Python,代码行数:18,代码来源:client_tests.py


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