本文整理汇总了Python中ripe.atlas.tools.commands.probes.Command._clean_render_args方法的典型用法代码示例。如果您正苦于以下问题:Python Command._clean_render_args方法的具体用法?Python Command._clean_render_args怎么用?Python Command._clean_render_args使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ripe.atlas.tools.commands.probes.Command
的用法示例。
在下文中一共展示了Command._clean_render_args方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestProbesCommand
# 需要导入模块: from ripe.atlas.tools.commands.probes import Command [as 别名]
# 或者: from ripe.atlas.tools.commands.probes.Command import _clean_render_args [as 别名]
#.........这里部分代码省略.........
"COUNTRY_CODE: DE\n"
" ASN_V4: 3332\n"
" PREFIX_V4: 193.0/22\n"
" ID ASNv4 ASNv6 CC Status \n"
" 3 3332 None DE None \n"
" ASN_V4: 3333\n PREFIX_V4: 193.0/22\n"
" ID ASNv4 ASNv6 CC Status \n"
" 2 3333 None DE None \n"
"Total probes found: 4\n"
)
expected_set = set(expected_blob.split("\n"))
returned_set = set(mystdout.getvalue().split("\n"))
self.assertEquals(returned_set, expected_set)
sys.stdout = old_stdout
def test_render_with_aggregation_with_limit(self):
"""Tests rendering of results with aggregation with limit"""
self.cmd.init_args([
"--country-code", "GR", "--aggregate-by", "country_code",
"--aggregate-by", "asn_v4", "--aggregate-by", "prefix_v4",
"--limit", "1"
])
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"
"COUNTRY_CODE: GR\n"
" ASN_V4: 3333\n"
" PREFIX_V4: 193.0/22\n"
" ID ASNv4 ASNv6 CC Status \n"
" 1 3333 None GR None \n"
"Total probes found: 4\n"
)
self.assertEquals(mystdout.getvalue(), expected_output)
sys.stdout = old_stdout
def test_render_with_aggregation_with_max_per_aggr(self):
"""
Tests rendering of results with aggregation with max per aggr option
"""
self.cmd.init_args([
"--country-code", "GR", "--aggregate-by", "country_code",
"--aggregate-by", "asn_v4", "--aggregate-by", "prefix_v4",
"--max-per-aggregation", "1"
])
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_blob = (
"We found the following probes with the given criteria:\n"
"COUNTRY_CODE: NL\n"
" ASN_V4: 3333\n"
" PREFIX_V4: 193.0/22\n"
" ID ASNv4 ASNv6 CC Status \n"
" 4 3333 None NL None \n"
"COUNTRY_CODE: GR\n"
" ASN_V4: 3333\n"
" PREFIX_V4: 193.0/22\n"
" ID ASNv4 ASNv6 CC Status \n"
" 1 3333 None GR None \n"
"COUNTRY_CODE: DE\n"
" ASN_V4: 3332\n"
" PREFIX_V4: 193.0/22\n"
" ID ASNv4 ASNv6 CC Status \n"
" 3 3332 None DE None \n"
" ASN_V4: 3333\n"
" PREFIX_V4: 193.0/22\n"
" ID ASNv4 ASNv6 CC Status \n"
" 2 3333 None DE None \n"
"Total probes found: 4\n"
)
expected_set = set(expected_blob.split("\n"))
returned_set = set(mystdout.getvalue().split("\n"))
self.assertEquals(returned_set, expected_set)
sys.stdout = old_stdout
def test_render_args(self):
"""User passed max_per_aggr and additional fields args"""
self.cmd.init_args([
"--max-per-aggregation",
"3",
"--additional-fields",
"blaaaa, grrrrr"
])
self.assertEquals(
self.cmd._clean_render_args(),
{"max_per_aggr": 3, "additional_fields": ["blaaaa", "grrrrr"]}
)