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

about_popup: Terminal size added in about popup. #1539

Closed
wants to merge 4 commits into from
Closed
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
24 changes: 22 additions & 2 deletions tests/ui_tools/test_popups.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def mock_external_classes(self, mocker: MockerFixture) -> None:
maximum_footlinks=3,
exit_confirmation_enabled=False,
transparency_enabled=False,
terminal_size=(80, 24),
)

@pytest.mark.parametrize(
Expand Down Expand Up @@ -259,13 +260,31 @@ def test_feature_level_content(
maximum_footlinks=3,
exit_confirmation_enabled=False,
transparency_enabled=False,
terminal_size=(80, 24),
)

assert len(about_view.feature_level_content) == (
1 if server_feature_level else 0
)

def test_categories(self) -> None:
def test_categories(self, mocker: MockerFixture) -> None:
mocker.Mock()
self.about_view = AboutView(
self.controller,
"About",
zt_version=ZT_VERSION,
server_version=MINIMUM_SUPPORTED_SERVER_VERSION[0],
server_feature_level=MINIMUM_SUPPORTED_SERVER_VERSION[1],
theme_name="zt_dark",
color_depth=256,
notify_enabled=False,
autohide_enabled=False,
maximum_footlinks=3,
exit_confirmation_enabled=False,
transparency_enabled=False,
terminal_size=(80, 24),
)
Comment on lines +271 to +286
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new code is not necessary:

  • please look up what mocker/mock/Mock() is used for, if you intend to use it :)
  • self.about_view is set automatically in the first function (fixture) of this test class, which is used automatically every time, so this is duplicated each time.


categories = [
widget.text
for widget in self.about_view.log
Expand Down Expand Up @@ -299,7 +318,8 @@ def test_copied_content(self) -> None:

#### Detected Environment
Platform: WSL
Python: [Python version]"""
Python: [Python version]
Current terminal size: 80 columns x 24 rows"""
assert self.about_view.copy_info == expected_output


Expand Down
2 changes: 2 additions & 0 deletions zulipterminal/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ def popup_with_message(self, text: str, width: int) -> None:
self.show_pop_up(NoticeView(self, text, width, "NOTICE"), "area:error")

def show_about(self) -> None:
terminal_size = self.loop.screen.get_cols_rows()
self.show_pop_up(
AboutView(
self,
Expand All @@ -315,6 +316,7 @@ def show_about(self) -> None:
maximum_footlinks=self.maximum_footlinks,
exit_confirmation_enabled=self.exit_confirmation,
transparency_enabled=self.transparency_enabled,
terminal_size=terminal_size,
),
"area:help",
)
Expand Down
11 changes: 9 additions & 2 deletions zulipterminal/ui_tools/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,7 @@ def __init__(
notify_enabled: bool,
exit_confirmation_enabled: bool,
transparency_enabled: bool,
terminal_size: Tuple[int, int],
) -> None:
self.feature_level_content = (
[("Feature level", str(server_feature_level))]
Expand Down Expand Up @@ -1119,7 +1120,14 @@ def __init__(
),
(
"Detected Environment",
[("Platform", PLATFORM), ("Python", detected_python_in_full())],
[
("Platform", PLATFORM),
("Python", detected_python_in_full()),
(
"Current terminal size",
f"{terminal_size[0]} columns x {terminal_size[1]} rows",
),
],
),
]

Expand All @@ -1137,7 +1145,6 @@ def __init__(

popup_width, column_widths = self.calculate_table_widths(contents, len(title))
widgets = self.make_table_with_categories(contents, column_widths)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check your PRs for these unrelated changes.

super().__init__(controller, widgets, "ABOUT", popup_width, title)

def keypress(self, size: urwid_Size, key: str) -> str:
Expand Down
Loading