From a7cdd1114394912d9e9dc03231feef7be53b8af7 Mon Sep 17 00:00:00 2001 From: Jiri Hnidek Date: Fri, 4 Oct 2024 14:41:30 +0200 Subject: [PATCH] refactor: Moved some definition of lists from list.py * Card ID: CCT-734 * cli_command/list.py contained several definitions of lists not related to list command. These definitions were moved to right Python modules. One list was renamed, because it is used only for testing ATM. --- .../cli_command/environments.py | 7 +++++- src/subscription_manager/cli_command/list.py | 25 ------------------- .../cli_command/owners.py | 6 ++++- src/subscription_manager/cli_command/repos.py | 8 +++++- test/test_printing_utils.py | 20 ++++++++++----- 5 files changed, 32 insertions(+), 34 deletions(-) diff --git a/src/subscription_manager/cli_command/environments.py b/src/subscription_manager/cli_command/environments.py index ec645e46be..4d58e66fa5 100644 --- a/src/subscription_manager/cli_command/environments.py +++ b/src/subscription_manager/cli_command/environments.py @@ -26,7 +26,6 @@ ERR_NOT_REGISTERED_MSG, ) from subscription_manager.cli_command.org import OrgCommand -from subscription_manager.cli_command.list import ENVIRONMENT_LIST from subscription_manager.i18n import ugettext as _ from subscription_manager.i18n import ungettext from subscription_manager.printing_utils import columnize, echo_columnize_callback @@ -36,8 +35,14 @@ log = logging.getLogger(__name__) + MULTI_ENV = "multi_environment" +ENVIRONMENT_LIST = [ + _("Name:"), + _("Description:"), +] + class EnvironmentsCommand(OrgCommand): def __init__(self): diff --git a/src/subscription_manager/cli_command/list.py b/src/subscription_manager/cli_command/list.py index 1b934259da..efc17ff7d9 100644 --- a/src/subscription_manager/cli_command/list.py +++ b/src/subscription_manager/cli_command/list.py @@ -32,31 +32,6 @@ _("Arch:"), ] -AVAILABLE_SUBS_MATCH_COLUMNS = [ - _("Subscription Name:"), - _("Provides:"), - _("SKU:"), - _("Contract:"), - _("Service Level:"), -] - -REPOS_LIST = [ - _("Repo ID:"), - _("Repo Name:"), - _("Repo URL:"), - _("Enabled:"), -] - -ENVIRONMENT_LIST = [ - _("Name:"), - _("Description:"), -] - -ORG_LIST = [ - _("Name:"), - _("Key:"), -] - log = logging.getLogger(__name__) diff --git a/src/subscription_manager/cli_command/owners.py b/src/subscription_manager/cli_command/owners.py index 43a64210dd..1b3c69b75f 100644 --- a/src/subscription_manager/cli_command/owners.py +++ b/src/subscription_manager/cli_command/owners.py @@ -21,13 +21,17 @@ from subscription_manager.cli import system_exit from subscription_manager.cli_command.cli import handle_exception -from subscription_manager.cli_command.list import ORG_LIST from subscription_manager.cli_command.user_pass import UserPassCommand from subscription_manager.i18n import ugettext as _ from subscription_manager.printing_utils import columnize, echo_columnize_callback log = logging.getLogger(__name__) +ORG_LIST = [ + _("Name:"), + _("Key:"), +] + class OwnersCommand(UserPassCommand): def __init__(self): diff --git a/src/subscription_manager/cli_command/repos.py b/src/subscription_manager/cli_command/repos.py index fc87e5e0d0..45cd46455e 100644 --- a/src/subscription_manager/cli_command/repos.py +++ b/src/subscription_manager/cli_command/repos.py @@ -21,7 +21,6 @@ from subscription_manager.action_client import ProfileActionClient, ActionClient from subscription_manager.cli_command.cli import CliCommand -from subscription_manager.cli_command.list import REPOS_LIST from subscription_manager.i18n import ugettext as _ from subscription_manager.packageprofilelib import PackageProfileActionInvoker from subscription_manager.printing_utils import columnize, echo_columnize_callback @@ -31,6 +30,13 @@ log = logging.getLogger(__name__) +REPOS_LIST = [ + _("Repo ID:"), + _("Repo Name:"), + _("Repo URL:"), + _("Enabled:"), +] + class ReposAddRemoveAction(argparse.Action): """ diff --git a/test/test_printing_utils.py b/test/test_printing_utils.py index 69e02cff8c..2e208faccf 100644 --- a/test/test_printing_utils.py +++ b/test/test_printing_utils.py @@ -1,6 +1,5 @@ import unittest -from subscription_manager.cli_command.list import AVAILABLE_SUBS_MATCH_COLUMNS from subscription_manager.cli_command import status from subscription_manager.printing_utils import ( format_name, @@ -16,6 +15,15 @@ from unittest.mock import patch, Mock +TEST_COLUMNS = [ + "Subscription Name:", + "Provides:", + "SKU:", + "Contract:", + "Service Level:", +] + + class TestFormatName(unittest.TestCase): def setUp(self): self.indent = 1 @@ -66,7 +74,7 @@ def test_highlight_by_filter_string(self): args = ["Super Test Subscription"] kwargs = { "filter_string": "Super*", - "match_columns": AVAILABLE_SUBS_MATCH_COLUMNS, + "match_columns": TEST_COLUMNS, "caption": "Subscription Name:", "is_atty": True, } @@ -79,7 +87,7 @@ def test_highlight_by_filter_string_single(self): args = ["Super Test Subscription"] kwargs = { "filter_string": "*Subscriptio?", - "match_columns": AVAILABLE_SUBS_MATCH_COLUMNS, + "match_columns": TEST_COLUMNS, "caption": "Subscription Name:", "is_atty": True, } @@ -92,7 +100,7 @@ def test_highlight_by_filter_string_all(self): args = ["Super Test Subscription"] kwargs = { "filter_string": "*", - "match_columns": AVAILABLE_SUBS_MATCH_COLUMNS, + "match_columns": TEST_COLUMNS, "caption": "Subscription Name:", "is_atty": True, } @@ -103,7 +111,7 @@ def test_highlight_by_filter_string_exact(self): args = ["Premium"] kwargs = { "filter_string": "Premium", - "match_columns": AVAILABLE_SUBS_MATCH_COLUMNS, + "match_columns": TEST_COLUMNS, "caption": "Service Level:", "is_atty": True, } @@ -114,7 +122,7 @@ def test_highlight_by_filter_string_list_row(self): args = ["Awesome-os-stacked"] kwargs = { "filter_string": "Awesome*", - "match_columns": AVAILABLE_SUBS_MATCH_COLUMNS, + "match_columns": TEST_COLUMNS, "caption": "Subscription Name:", "is_atty": True, }