本文整理匯總了Python中ripe.atlas.tools.commands.probes.Command.get_aggregators方法的典型用法代碼示例。如果您正苦於以下問題:Python Command.get_aggregators方法的具體用法?Python Command.get_aggregators怎麽用?Python Command.get_aggregators使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ripe.atlas.tools.commands.probes.Command
的用法示例。
在下文中一共展示了Command.get_aggregators方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TestProbesCommand
# 需要導入模塊: from ripe.atlas.tools.commands.probes import Command [as 別名]
# 或者: from ripe.atlas.tools.commands.probes.Command import get_aggregators [as 別名]
#.........這裏部分代碼省略.........
"--country-code", "GR",
"--limit", "2"
])
old_stdout = sys.stdout
sys.stdout = mystdout = StringIO()
path = 'ripe.atlas.tools.commands.probes.ProbeRequest'
with mock.patch(path) as mock_get:
mock_get.return_value = FakeGen()
self.cmd.run()
self.assertEquals(mystdout.getvalue(), "1,2")
sys.stdout = old_stdout
def test_render_ids_only_with_aggr(self):
"""
User passed ids_only arg together with aggrement, testing rendiring
"""
self.cmd.init_args([
"--ids-only",
"--aggregate-by", "country_code"
])
old_stdout = sys.stdout
sys.stdout = mystdout = StringIO()
path = 'ripe.atlas.tools.commands.probes.ProbeRequest'
with mock.patch(path) as mock_get:
mock_get.return_value = FakeGen()
self.cmd.run()
self.assertEquals(mystdout.getvalue(), "1,2,3,4,5")
sys.stdout = old_stdout
def test_get_aggregators(self):
"""User passed --aggregate-by args"""
self.cmd.init_args([
"--aggregate-by", "asn_v4",
"--aggregate-by", "country_code",
"--aggregate-by", "prefix_v4"
])
expected_output = [
ValueKeyAggregator(key="asn_v4"),
ValueKeyAggregator(key="country_code"),
ValueKeyAggregator(key="prefix_v4")
]
output = self.cmd.get_aggregators()
for index, v in enumerate(output):
self.assertTrue(isinstance(v, ValueKeyAggregator))
self.assertEquals(
v.aggregation_keys,
expected_output[index].aggregation_keys
)
def test_render_without_aggregation(self):
"""Tests rendering of results without aggregation"""
self.cmd.init_args(["--limit", "4"])
old_stdout = sys.stdout
sys.stdout = mystdout = StringIO()
path = 'ripe.atlas.tools.commands.probes.ProbeRequest'
with mock.patch(path) as mock_get:
mock_get.return_value = FakeGen()
self.cmd.run()
expected_output = (
"We found the following probes with the given criteria:\n"
"ID ASNv4 ASNv6 CC Status \n"