Esempio n. 1
0
    def test_replace(self, mock_backoff, mock_Notification, mock_init, mock_NotifierServer):
        mock_NotifierServer.return_value.__iter__.return_value = iter(
            [
                mock.Mock(
                    id="app_id",
                    urgency=protocol.URGENCY_NORMAL,
                    app_name="app_name",
                    summary="summary-1",
                    body="body-1",
                    category="cat-1",
                )
            ]
        )

        gtk.gtk_notification_driver("hub")

        mock_backoff.assert_called_once_with(300, 30, 5)
        mock_NotifierServer.assert_called_once_with("hub", None, True)
        mock_init.assert_called_once_with("app_name")
        mock_Notification.assert_has_calls(
            [
                mock.call("Starting", "app_name is starting up"),
                mock.call().set_category("network"),
                mock.call().set_urgency(protocol.URGENCY_LOW),
                mock.call().show(),
                mock.call().update("summary-1", "body-1"),
                mock.call().set_category("cat-1"),
                mock.call().set_urgency(protocol.URGENCY_NORMAL),
                mock.call().show(),
            ]
        )
Esempio n. 2
0
    def test_retry(self, mock_backoff, mock_Notification, mock_init, mock_NotifierServer):
        mock_NotifierServer.return_value.__iter__.side_effect = [
            iter(
                [
                    mock.Mock(
                        id="notify-1",
                        urgency=protocol.URGENCY_LOW,
                        app_name="application-1",
                        summary="summary-1",
                        body="body-1",
                        category="cat-1",
                    )
                ]
            ),
            iter(
                [
                    mock.Mock(
                        id="notify-2",
                        urgency=protocol.URGENCY_NORMAL,
                        app_name="application-2",
                        summary="summary-2",
                        body="body-2",
                        category=None,
                    )
                ]
            ),
            iter(
                [
                    mock.Mock(
                        id="notify-3",
                        urgency=protocol.URGENCY_CRITICAL,
                        app_name="application-3",
                        summary="summary-3",
                        body="body-3",
                        category="cat-3",
                    )
                ]
            ),
        ]

        gtk.gtk_notification_driver("hub")

        mock_backoff.assert_called_once_with(300, 30, 5)
        mock_NotifierServer.assert_called_once_with("hub", None, True)
        mock_init.assert_called_once_with("app_name")
        mock_Notification.assert_has_calls(
            [
                mock.call("Starting", "app_name is starting up"),
                mock.call().set_category("network"),
                mock.call().set_urgency(protocol.URGENCY_LOW),
                mock.call().show(),
                mock.call("summary-1", "body-1"),
                mock.call().set_category("cat-1"),
                mock.call().set_urgency(protocol.URGENCY_LOW),
                mock.call().show(),
                mock.call("summary-2", "body-2"),
                mock.call().set_category(""),
                mock.call().set_urgency(protocol.URGENCY_NORMAL),
                mock.call().show(),
                mock.call("summary-3", "body-3"),
                mock.call().set_category("cat-3"),
                mock.call().set_urgency(protocol.URGENCY_CRITICAL),
                mock.call().show(),
            ]
        )