From fc4afb7e4d865e50b9bbbb3abfb39d3a4718bd08 Mon Sep 17 00:00:00 2001 From: Viktor Bukharov Date: Mon, 16 Oct 2023 15:27:34 +0800 Subject: [PATCH] Remove redundant fields from capabilities --- docs/usage/commands.rst | 3 --- selvpcclient/commands/__init__.py | 3 --- selvpcclient/commands/capabilities.py | 39 --------------------------- tests/cli/test_capabilities.py | 34 ----------------------- tests/util/answers.py | 35 ------------------------ 5 files changed, 114 deletions(-) diff --git a/docs/usage/commands.rst b/docs/usage/commands.rst index 0fc2d7f..787d48b 100644 --- a/docs/usage/commands.rst +++ b/docs/usage/commands.rst @@ -3,10 +3,7 @@ Show capabilities .. code-block:: console $ selvpc capabilities show regions - $ selvpc capabilities show licenses - $ selvpc capabilities show traffic $ selvpc capabilities show resources - $ selvpc capabilities show subnets Manage customization ~~~~~~~~~~~~~~~~~~~~ diff --git a/selvpcclient/commands/__init__.py b/selvpcclient/commands/__init__.py index 47b416b..1e72148 100644 --- a/selvpcclient/commands/__init__.py +++ b/selvpcclient/commands/__init__.py @@ -3,11 +3,8 @@ role, subnet, token, user, vrrp) commands = { - 'capabilities show licenses': capabilities.Licenses, 'capabilities show regions': capabilities.Regions, 'capabilities show resources': capabilities.Resources, - 'capabilities show subnets': capabilities.Subnets, - 'capabilities show traffic': capabilities.Traffic, 'customization update': customization.Update, 'customization show': customization.Show, diff --git a/selvpcclient/commands/capabilities.py b/selvpcclient/commands/capabilities.py index a937e26..9661a62 100644 --- a/selvpcclient/commands/capabilities.py +++ b/selvpcclient/commands/capabilities.py @@ -1,21 +1,7 @@ from selvpcclient.base import ListCommand -from selvpcclient.formatters import join_by_key from selvpcclient.util import handle_http_error -class Licenses(ListCommand): - """Show available license values""" - - columns = ['type', 'availability'] - _formatters = {"availability": join_by_key("availability")} - sorting_support = True - - @handle_http_error - def take_action(self, parsed_args): - result = self.app.context["client"].capabilities.get() - return self.setup_columns(result.licenses, parsed_args) - - class Regions(ListCommand): """Show available region values""" @@ -57,28 +43,3 @@ class Resources(ListCommand): def take_action(self, parsed_args): result = self.app.context["client"].capabilities.get() return self.setup_columns(result.resources, parsed_args) - - -class Subnets(ListCommand): - """Show available subnet values""" - - columns = ['type', 'prefix_length', 'availability'] - _formatters = {"availability": join_by_key("availability")} - sorting_support = True - - @handle_http_error - def take_action(self, parsed_args): - result = self.app.context["client"].capabilities.get() - return self.setup_columns(result.subnets, parsed_args) - - -class Traffic(ListCommand): - """Show available traffic values""" - - columns = ['granularity', 'timespan'] - sorting_support = True - - @handle_http_error - def take_action(self, parsed_args): - result = self.app.context["client"].capabilities.get() - return self.setup_columns(result.traffic["granularities"], parsed_args) diff --git a/tests/cli/test_capabilities.py b/tests/cli/test_capabilities.py index dada649..a7fd154 100644 --- a/tests/cli/test_capabilities.py +++ b/tests/cli/test_capabilities.py @@ -2,17 +2,6 @@ from tests.util import answers -def test_capabilities_show_licenses(): - count_of_licenses = 1 - client = make_client(return_value=answers.CAPABILITIES_LIST) - args = ['capabilities show licenses'] - - licenses = run_cmd(args, client, json_output=True) - - assert len(licenses) == count_of_licenses - assert licenses[0]['type'] == 'license_windows_2012_standard' - - def test_capabilities_show_regions(): count_of_zones = 3 client = make_client(return_value=answers.CAPABILITIES_LIST) @@ -31,26 +20,3 @@ def test_capabilities_show_resources(): resources = run_cmd(args, client, json_output=True) assert len(resources) == count_of_resources - - -def test_capabilities_show_subnets(): - count_of_subnets = 1 - client = make_client(return_value=answers.CAPABILITIES_LIST) - args = ['capabilities show subnets'] - - subnets = run_cmd(args, client, json_output=True) - - assert len(subnets) == count_of_subnets - assert subnets[0]['type'] == 'ipv4' - assert subnets[0]['prefix_length'] == '29' - assert 'availability' in subnets[0] - - -def test_capabilities_show_traffic(): - count_of_granularities = 3 - client = make_client(return_value=answers.CAPABILITIES_LIST) - args = ['capabilities show traffic'] - - traffic = run_cmd(args, client, json_output=True) - - assert len(traffic) == count_of_granularities diff --git a/tests/util/answers.py b/tests/util/answers.py index 0a6e50c..64778f1 100644 --- a/tests/util/answers.py +++ b/tests/util/answers.py @@ -668,15 +668,6 @@ CAPABILITIES_LIST = { "capabilities": { - "licenses": [ - { - "availability": [ - "ru-1", - "ru-2" - ], - "type": "license_windows_2012_standard" - } - ], "regions": [ { "description": "Moscow", @@ -776,32 +767,6 @@ "unbillable": True, } ], - "subnets": [ - { - "availability": [ - "ru-1", - "ru-2" - ], - "prefix_length": "29", - "type": "ipv4" - } - ], - "traffic": { - "granularities": [ - { - "granularity": 3600, - "timespan": 96 - }, - { - "granularity": 1, - "timespan": 32 - }, - { - "granularity": 86400, - "timespan": 1825 - } - ] - } } }