本文整理汇总了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)
示例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)