#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys
import unittest.mock
from pathlib import Path
from unittest.mock import MagicMock

sys.path.insert(0, str(Path(__file__).parent))

# Mock system packages not available in dev/CI environments.
sys.modules['notify2'] = MagicMock()

# PyQt5 needs proper base classes to avoid metaclass conflicts.
_qt_core = MagicMock()
_qt_gui = MagicMock()
_qt_widgets = MagicMock()


class _MockQSystemTrayIcon:
    ActivationReason = MagicMock()
    Trigger = MagicMock()

    def __init__(self, *args, **kwargs):
        pass

    def setIcon(self, *a):
        pass

    def setToolTip(self, *a):
        pass

    def setContextMenu(self, *a):
        pass

    def activated(self):
        pass

    def show(self):
        pass


_qt_widgets.QSystemTrayIcon = _MockQSystemTrayIcon
_qt_widgets.QApplication = MagicMock()
_qt_widgets.QMenu = MagicMock()
_qt_widgets.QMessageBox = MagicMock()

_pyqt5 = MagicMock()
_pyqt5.QtCore = _qt_core
_pyqt5.QtGui = _qt_gui
_pyqt5.QtWidgets = _qt_widgets

sys.modules['PyQt5'] = _pyqt5
sys.modules['PyQt5.QtCore'] = _qt_core
sys.modules['PyQt5.QtGui'] = _qt_gui
sys.modules['PyQt5.QtWidgets'] = _qt_widgets

from shared import MOCK_OS_INFO, MOCK_STATIC_PATHS  # noqa: E402

unittest.mock.patch('sun.sys_info.get_os_info', return_value=MOCK_OS_INFO).start()
unittest.mock.patch('sun.sys_info.get_static_paths', return_value=MOCK_STATIC_PATHS).start()
