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

ui: fix journal parsing in ProgressView #2085

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
2 changes: 1 addition & 1 deletion subiquity/ui/views/installprogress.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def event_other(self, message: str, event_type: str) -> None:
#
# and we want to insert the event type between the colon and the
# event description
context, text = message.split(":")
context, text = message.split(":", maxsplit=1)
text = text.lstrip()
message = f"{context}: {event_type.upper()}: {text}"

Expand Down
27 changes: 27 additions & 0 deletions subiquity/ui/views/tests/test_installprogress.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest
from unittest import mock
from unittest.mock import patch

from subiquity.client.controllers.progress import ProgressController
from subiquity.common.types import ApplicationState
Expand Down Expand Up @@ -53,3 +54,29 @@ def test_error_disambiguation(self):
self.assertIsNone(btn)
btn = view_helpers.find_button_matching(view, "^Restart Installer$")
self.assertIsNotNone(btn)

@patch("subiquity.ui.views.installprogress.Columns")
@patch("subiquity.ui.views.installprogress.Text")
def test_event_other_formatting(self, text_mock, columns_mock):
"""Test formatting of the other_event function."""
view = self.make_view()
text_mock.return_value = "mock text"
view.event_other("MOCK CONTEXT: message", "mock")
text_mock.assert_called_with("MOCK CONTEXT: MOCK: message")
columns_mock.assert_called_with(
[
("pack", "mock text"),
],
dividechars=1,
)

@patch("subiquity.ui.views.installprogress.Text")
def test_event_other_robust_splitting(self, text_mock):
"""Test that messages containing a colon don't fail to split.

event_other uses str.split(":"), make sure it doesn't cause an
error if more than one colon is present in the message.
"""
view = self.make_view()
view.event_other("MOCK CONTEXT: bad keys: 1, 2, 3", "mock")
text_mock.assert_called_with("MOCK CONTEXT: MOCK: bad keys: 1, 2, 3")
Loading