Skip to content

Commit

Permalink
Refactor test_dbus-opendtu.py to use register_services instead of reg…
Browse files Browse the repository at this point in the history
…ister_service
  • Loading branch information
0x7878 committed Nov 14, 2024
1 parent f531c41 commit 5790d95
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions test_dbus-opendtu.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
sys.modules['gi.repository'] = MagicMock()
sys.modules['dbus.mainloop.glib'] = MagicMock()

from dbus_opendtu import register_service # pylint: disable=E0401,C0413 # noqa: E402
from dbus_opendtu import register_services # pylint: disable=E0401,C0413 # noqa: E402


class TestRegisterService(unittest.TestCase):
""" Test cases for the register_service function """

@patch('dbus_opendtu.config', {'DEFAULT': {'DTU': 'opendtu'}})
@patch('dbus_opendtu.DbusService')
@patch('dbus_opendtu.get_config_value')
def test_register_service(self, mock_get_config_value, mock_dbus_service):
Expand All @@ -34,7 +33,7 @@ def get_config_value_side_effect(key, *args, **kwargs):
mock_dbus_service_instance = mock_dbus_service.return_value
mock_dbus_service_instance.get_number_of_inverters.return_value = 1

register_service()
register_services({'DEFAULT': {'DTU': 'opendtu'}})

# Add assertions to verify the behavior
mock_dbus_service.assert_called_once()
Expand Down

0 comments on commit 5790d95

Please sign in to comment.