Exemple #1
0
    def test_internet_is_ok_after_first_check(self):
        # Given
        connection_handler = ConnectionHandler(*fake_params)

        # When
        connection_handler.update()

        # Then
        self.assertTrue(connection_handler.internet_ok)
    def test_internet_is_ok_after_first_check(self):
        # Given
        connection_handler = ConnectionHandler(*fake_params)

        # When
        connection_handler.update()

        # Then
        self.assertTrue(connection_handler.internet_ok)
    def test_have_internet_again(self):
        # Given
        connection_handler = ConnectionHandler(*fake_params)
        connection_handler.internet_ok = False

        # When
        connection_handler.update()

        # Then
        self.assertTrue(connection_handler.internet_ok)
    def test_when_no_internet(self):
        # Given
        connection_handler = ConnectionHandler(*fake_params)
        connection_handler.check_internet_call = MagicMock(side_effect=Exception('HTTP Error'))

        # When
        connection_handler.update()

        # Then
        self.assertFalse(connection_handler.internet_ok)
Exemple #5
0
    def test_have_internet_again(self):
        # Given
        connection_handler = ConnectionHandler(*fake_params)
        connection_handler.internet_ok = False

        # When
        connection_handler.update()

        # Then
        self.assertTrue(connection_handler.internet_ok)
Exemple #6
0
 def __init__(self, parent=None):
     super(SystemTray, self).__init__(parent)
     self.tray_icon_menu = QMenu(self)
     self.tray_icon = QSystemTrayIcon(self)
     self.tray_icon.setContextMenu(self.tray_icon_menu)
     self.icon_management = IconManagement(self.tray_icon)
     self.connection_handler = ConnectionHandler(FREQUENCY_CHECK_MS,
                                                 TIME_OUT_CALL_S, self)
     self.connection_handler.value_changed.connect(self.internet_connection)
     self.connection_handler.start()
Exemple #7
0
    def test_when_no_internet(self):
        # Given
        connection_handler = ConnectionHandler(*fake_params)
        connection_handler.check_internet_call = MagicMock(
            side_effect=Exception('HTTP Error'))

        # When
        connection_handler.update()

        # Then
        self.assertFalse(connection_handler.internet_ok)
Exemple #8
0
class SystemTray(QWidget):
    def __init__(self, parent=None):
        super(SystemTray, self).__init__(parent)
        self.tray_icon_menu = QMenu(self)
        self.tray_icon = QSystemTrayIcon(self)
        self.tray_icon.setContextMenu(self.tray_icon_menu)
        self.icon_management = IconManagement(self.tray_icon)
        self.connection_handler = ConnectionHandler(FREQUENCY_CHECK_MS,
                                                    TIME_OUT_CALL_S, self)
        self.connection_handler.value_changed.connect(self.internet_connection)
        self.connection_handler.start()

    def add_action(self, name, triggered_action):
        action = QAction(QCoreApplication.translate(trad_context, name),
                         self,
                         triggered=triggered_action)
        self.tray_icon_menu.addAction(action)

    def add_separator(self):
        self.tray_icon_menu.addSeparator()

    def show(self):
        super(SystemTray, self).show()
        self.tray_icon.show()

    @pyqtSlot()
    def event_started(self):
        self.icon_management.start()

    @pyqtSlot()
    def event_finished(self):
        self.icon_management.stop()

    @pyqtSlot(Exception)
    def conductor_problem(self, e):
        self.notify("Demerio", "There was a problem : %s" % (e, ))
        self.icon_management.conductor_problem()

    @pyqtSlot(bool)
    def internet_connection(self, internet_is_ok):
        if not internet_is_ok:
            self.notify("Demerio", "Internet connection is lost")
        self.icon_management.internet_is_ok(internet_is_ok)

    def notify(self, title, message):
        self.tray_icon.showMessage(title, message, BAR_NOTIFICATION_TIME)
Exemple #9
0
 def __init__(self, parent=None):
     super(SystemTray, self).__init__(parent)
     self.tray_icon_menu = QMenu(self)
     self.tray_icon = QSystemTrayIcon(self)
     self.tray_icon.setContextMenu(self.tray_icon_menu)
     self.icon_management = IconManagement(self.tray_icon)
     self.connection_handler = ConnectionHandler(FREQUENCY_CHECK_MS, TIME_OUT_CALL_S, self)
     self.connection_handler.value_changed.connect(self.internet_connection)
     self.connection_handler.start()
Exemple #10
0
class SystemTray(QWidget):

    def __init__(self, parent=None):
        super(SystemTray, self).__init__(parent)
        self.tray_icon_menu = QMenu(self)
        self.tray_icon = QSystemTrayIcon(self)
        self.tray_icon.setContextMenu(self.tray_icon_menu)
        self.icon_management = IconManagement(self.tray_icon)
        self.connection_handler = ConnectionHandler(FREQUENCY_CHECK_MS, TIME_OUT_CALL_S, self)
        self.connection_handler.value_changed.connect(self.internet_connection)
        self.connection_handler.start()

    def add_action(self, name, triggered_action):
        action = QAction(QCoreApplication.translate(trad_context, name), self, triggered = triggered_action)
        self.tray_icon_menu.addAction(action)

    def add_separator(self):
        self.tray_icon_menu.addSeparator()

    def show(self):
        super(SystemTray, self).show()
        self.tray_icon.show()

    @pyqtSlot()
    def event_started(self):
        self.icon_management.start()

    @pyqtSlot()
    def event_finished(self):
        self.icon_management.stop()

    @pyqtSlot(Exception)
    def conductor_problem(self, e):
        self.notify("Demerio", "There was a problem : %s" % (e,))
        self.icon_management.conductor_problem()

    @pyqtSlot(bool)
    def internet_connection(self, internet_is_ok):
        if not internet_is_ok:
            self.notify("Demerio", "Internet connection is lost")
        self.icon_management.internet_is_ok(internet_is_ok)

    def notify(self, title, message):
        self.tray_icon.showMessage(title, message, BAR_NOTIFICATION_TIME)
Exemple #11
0
    def test_internet_is_None_by_default(self):
        # Given
        connection_handler = ConnectionHandler(*fake_params)

        # Then
        self.assertIsNone(connection_handler.internet_ok)