# edited by glg
import unittest
from unittest.mock import patch

from pypos.modules.dashboard.services.dashboard_config_service import DashboardConfigService


class DashboardConfigAutoSyncProbeIntervalTests(unittest.TestCase):
    @patch(
        "pypos.modules.dashboard.services.dashboard_config_service.read_app_settings",
        return_value={"auto_sync_probe_interval_seconds": 5},
    )
    def test_probe_interval_memiliki_guard_minimum(self, _mock_read):
        svc = DashboardConfigService()
        self.assertEqual(svc.get_auto_sync_probe_interval_seconds(), 15)

    @patch(
        "pypos.modules.dashboard.services.dashboard_config_service.read_app_settings",
        return_value={"auto_sync_probe_interval_seconds": 75},
    )
    def test_probe_interval_mengikuti_setting_valid(self, _mock_read):
        svc = DashboardConfigService()
        self.assertEqual(svc.get_auto_sync_probe_interval_seconds(), 75)

    @patch(
        "pypos.modules.dashboard.services.dashboard_config_service.read_app_settings",
        return_value={"auto_sync_notify_reminder_minutes": 0},
    )
    def test_notify_reminder_memiliki_guard_minimum(self, _mock_read):
        svc = DashboardConfigService()
        self.assertEqual(svc.get_auto_sync_notify_reminder_minutes(), 1)

    @patch(
        "pypos.modules.dashboard.services.dashboard_config_service.read_app_settings",
        return_value={"auto_sync_notify_reminder_minutes": 10},
    )
    def test_notify_reminder_mengikuti_setting_valid(self, _mock_read):
        svc = DashboardConfigService()
        self.assertEqual(svc.get_auto_sync_notify_reminder_minutes(), 10)


if __name__ == "__main__":
    unittest.main()
