Skip to content

Commit 34d9664

Browse files
committed
fix: _empty_message should be an attribute or property not a function
1 parent 55d7d66 commit 34d9664

File tree

3 files changed

+6
-14
lines changed

3 files changed

+6
-14
lines changed

src/mastermind/ui/menu/data_menu.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from abc import abstractmethod
1+
from abc import ABC, abstractmethod
22
from typing import Any, Optional
33

44
from mastermind.ui.menu.base_menu import BaseMenu
55

66

7-
class DataDisplayMenu(BaseMenu):
7+
class DataDisplayMenu(BaseMenu, ABC):
88
"""
99
An abstract base class for menus that display data.
1010
@@ -19,7 +19,7 @@ def _print_content(self) -> None:
1919
if data is not None:
2020
self._render_data(data)
2121
else:
22-
print(self._empty_message())
22+
print(self._empty_message)
2323

2424
@abstractmethod
2525
def _fetch_data(self) -> Optional[Any]:

src/mastermind/ui/menu/game_history_menu.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class GameHistoryMenu(DataDisplayMenu):
1414

1515
name = "Game History"
1616
width = 25
17+
_empty_message = "No game history found."
1718

1819
def _fetch_data(self) -> Optional[pd.DataFrame]:
1920
"""
@@ -27,12 +28,6 @@ def _render_data(self, data: pd.DataFrame) -> None:
2728
"""
2829
render_dataframe(data)
2930

30-
def _empty_message(self) -> str:
31-
"""
32-
Returns the message to display when there is no game history.
33-
"""
34-
return "No game history found."
35-
3631
def display(self) -> None:
3732
"""
3833
Displays the game history menu and waits for user input to continue.

tests/ui/menu/test_data_menu.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class ConcreteDataDisplayMenu(DataDisplayMenu):
1010
name = "Data Menu"
1111
_fetch_data = None
1212
_render_data = None
13-
_empty_message = None
13+
_empty_message = "No data available"
1414

1515
def setUp(self):
1616
self.data_menu = self.ConcreteDataDisplayMenu()
@@ -26,11 +26,8 @@ def test_print_content_with_data(self, mock_render_data, mock_fetch_data):
2626

2727
@patch.object(ConcreteDataDisplayMenu, "_fetch_data", return_value=None)
2828
@patch.object(ConcreteDataDisplayMenu, "_render_data")
29-
@patch.object(
30-
ConcreteDataDisplayMenu, "_empty_message", return_value="No data available"
31-
)
3229
def test_print_content_without_data(
33-
self, mock_empty_message, mock_render_data, mock_fetch_data
30+
self, mock_render_data, mock_fetch_data
3431
):
3532
with patch("builtins.print") as mock_print:
3633
self.data_menu._print_content()

0 commit comments

Comments
 (0)