Skip to content
Merged
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
18 changes: 12 additions & 6 deletions airflow-core/tests/unit/cli/commands/test_cheat_sheet_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# under the License.
from __future__ import annotations

import re
from unittest import mock

from airflow.cli import cli_parser
Expand Down Expand Up @@ -72,20 +73,25 @@ def noop():
]

ALL_COMMANDS = """\
airflow cmd_b | Help text D
airflow cmd_b | Help text D
"""

SECTION_A = """\
airflow cmd_a cmd_b | Help text B
airflow cmd_a cmd_c | Help text C
airflow cmd_a cmd_b | Help text B
airflow cmd_a cmd_c | Help text C
"""

SECTION_E = """\
airflow cmd_e cmd_f | Help text F
airflow cmd_e cmd_g | Help text G
airflow cmd_e cmd_f | Help text F
airflow cmd_e cmd_g | Help text G
"""


def normalize_spaces(text: str) -> str:
"""Collapse runs of spaces so assertions do not depend on the rich version's exact column padding."""
return re.sub(r" +", " ", text)


class TestCheatSheetCommand:
@classmethod
def setup_class(cls):
Expand All @@ -96,7 +102,7 @@ def test_should_display_index(self, stdout_capture):
with stdout_capture as temp_stdout:
args = self.parser.parse_args(["cheat-sheet"])
args.func(args)
output = temp_stdout.getvalue()
output = normalize_spaces(temp_stdout.getvalue())
assert ALL_COMMANDS in output
assert SECTION_A in output
assert SECTION_E in output