本文整理汇总了Python中gauged.Gauged.keys方法的典型用法代码示例。如果您正苦于以下问题:Python Gauged.keys方法的具体用法?Python Gauged.keys怎么用?Python Gauged.keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gauged.Gauged
的用法示例。
在下文中一共展示了Gauged.keys方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_context_defaults
# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import keys [as 别名]
def test_context_defaults(self):
gauged = Gauged(self.driver, resolution=1000, block_size=10000)
with gauged.writer as writer:
writer.add('bar', 123, timestamp=10000)
writer.add('foo', 456, timestamp=20000)
self.assertEqual(gauged.keys(), ['bar', 'foo'])
gauged = Gauged(self.driver, resolution=1000, block_size=10000,
defaults={'limit': 1})
self.assertEqual(gauged.keys(), ['bar'])
示例2: test_gauge
# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import keys [as 别名]
def test_gauge(self):
gauged = Gauged(self.driver, block_size=50000, gauge_nan=Gauged.IGNORE)
self.assertEqual(gauged.value('foobar'), None)
with gauged.writer as writer:
writer.add('foobar', 200, timestamp=23000)
self.assertEqual(gauged.value('foobar'), 200)
self.assertEqual(gauged.value('foobar', timestamp=22000), None)
with gauged.writer as writer:
writer.add({'foobar': 300, 'invalid': 'nan'}, timestamp=50000)
self.assertEqual(gauged.value('foobar'), 300)
self.assertEqual(gauged.value('foobar', 30000), 200)
timestamp = datetime.datetime(
1970, 1, 1) + datetime.timedelta(seconds=60)
self.assertEqual(gauged.value('foobar', timestamp), 300)
with gauged.writer as writer:
writer.add({'foobar': 350}, timestamp=90000)
writer.add('foobar', 100, timestamp=120000)
writer.add('bar', 150, timestamp=130000)
self.assertItemsEqual(gauged.keys(), ['foobar', 'bar'])
self.assertEqual(gauged.value('foobar'), 100)
with gauged.writer as writer:
writer.add('foobar', 500, timestamp=150000)
self.assertEqual(gauged.value('foobar'), 500)
with gauged.writer as writer:
writer.add('foobar', 1500, timestamp=10000, namespace=1)
self.assertEqual(gauged.value('foobar', namespace=1), 1500)
self.assertEqual(gauged.value('foobar'), 500)
with gauged.writer as writer:
writer.clear_from(100000)
self.assertEqual(gauged.value('foobar'), 350)
with self.assertRaises(GaugedDateRangeError):
self.assertEqual(
gauged.value('foobar', timestamp=-10000000000000), None)
示例3: test_no_data
# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import keys [as 别名]
def test_no_data(self):
gauged = Gauged(self.driver)
self.assertEqual(len(gauged.namespaces()), 0)
self.assertEqual(len(gauged.value_series('foo')), 0)
self.assertEqual(len(gauged.aggregate_series('foo', Gauged.SUM)), 0)
self.assertEqual(gauged.value('foo'), None)
self.assertEqual(gauged.aggregate('foo', Gauged.SUM), None)
self.assertEqual(len(gauged.keys()), 0)
stats = gauged.statistics()
for attr in ['data_points', 'byte_count']:
self.assertEqual(getattr(stats, attr), 0)
示例4: test_keys
# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import keys [as 别名]
def test_keys(self):
gauged = Gauged(self.driver)
with gauged.writer as writer:
writer.add('foobar', 1, timestamp=1000)
writer.add('foobaz', 1, timestamp=1000)
writer.add('bar', 1, timestamp=1000, namespace=1)
self.assertListEqual(gauged.keys(), ['foobar', 'foobaz'])
self.assertListEqual(gauged.keys(prefix='bar'), [])
self.assertListEqual(gauged.keys(namespace=1), ['bar'])
self.assertListEqual(gauged.keys(namespace=1, prefix='bar'), ['bar'])
self.assertListEqual(gauged.keys(limit=1), ['foobar'])
self.assertListEqual(gauged.keys(limit=1, offset=1), ['foobaz'])
示例5: test_gauged_init_store
# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import keys [as 别名]
def test_gauged_init_store(self):
gauged = Gauged('sqlite+foo://')
self.assertEqual(len(gauged.metadata()), 0)
with self.assertRaises(GaugedSchemaError):
gauged.keys()