Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant fields from capabilities #35

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions docs/usage/commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~~~~~~~~~~~~~~~~
Expand Down
3 changes: 0 additions & 3 deletions selvpcclient/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
39 changes: 0 additions & 39 deletions selvpcclient/commands/capabilities.py
Original file line number Diff line number Diff line change
@@ -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"""

Expand Down Expand Up @@ -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)
34 changes: 0 additions & 34 deletions tests/cli/test_capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
35 changes: 0 additions & 35 deletions tests/util/answers.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,15 +668,6 @@

CAPABILITIES_LIST = {
"capabilities": {
"licenses": [
{
"availability": [
"ru-1",
"ru-2"
],
"type": "license_windows_2012_standard"
}
],
"regions": [
{
"description": "Moscow",
Expand Down Expand Up @@ -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
}
]
}
}
}

Expand Down