Skip to content

Commit

Permalink
refactor: Moved some definition of lists from list.py
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
jirihnidek committed Oct 4, 2024
1 parent 7de19cd commit a7cdd11
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 34 deletions.
7 changes: 6 additions & 1 deletion src/subscription_manager/cli_command/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -36,8 +35,14 @@


log = logging.getLogger(__name__)

MULTI_ENV = "multi_environment"

ENVIRONMENT_LIST = [
_("Name:"),
_("Description:"),
]


class EnvironmentsCommand(OrgCommand):
def __init__(self):
Expand Down
25 changes: 0 additions & 25 deletions src/subscription_manager/cli_command/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
6 changes: 5 additions & 1 deletion src/subscription_manager/cli_command/owners.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
8 changes: 7 additions & 1 deletion src/subscription_manager/cli_command/repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,6 +30,13 @@

log = logging.getLogger(__name__)

REPOS_LIST = [
_("Repo ID:"),
_("Repo Name:"),
_("Repo URL:"),
_("Enabled:"),
]


class ReposAddRemoveAction(argparse.Action):
"""
Expand Down
20 changes: 14 additions & 6 deletions test/test_printing_utils.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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,
}
Expand All @@ -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,
}
Expand All @@ -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,
}
Expand All @@ -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,
}
Expand All @@ -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,
}
Expand Down

0 comments on commit a7cdd11

Please sign in to comment.