def test_handle_remove_notifications_no_args(self, sys_stderr, sys_exit):
        sys_exit.side_effect = SystemExit()

        with self.assertRaises(SystemExit):
            handle_remove_notification(self.options, self.session, [])

        self.session.deleteNotification.assert_not_called()
Beispiel #2
0
    def test_handle_remove_notification_bogus(self, stderr):
        expected = """Usage: %s remove-notification [options] <notification_id> [<notification_id> ...]
(Specify the --help global option for a list of other help options)

%s: error: All notification ids has to be integers
""" % (self.progname, self.progname)
        with self.assertRaises(SystemExit) as ex:
            handle_remove_notification(self.options, self.session, ['bogus'])
        self.assertExitCode(ex, 2)
        self.assert_console_message(stderr, expected)
        self.session.deleteNotification.assert_not_called()
Beispiel #3
0
    def test_handle_remove_notification_not_quiet(self, stdout,
                                                  activate_session_mock):
        self.options.quiet = False
        expected = "Notification 1 successfully removed.\n" \
                   "Notification 3 successfully removed.\n" \
                   "Notification 5 successfully removed.\n"
        handle_remove_notification(self.options, self.session, ['1', '3', '5'])

        self.session.deleteNotification.assert_has_calls(
            [mock.call(1), mock.call(3),
             mock.call(5)])

        activate_session_mock.assert_called_once_with(self.session,
                                                      self.options)
        actual = stdout.getvalue()
        print(actual)
        self.assertMultiLineEqual(actual, expected)
    def test_handle_remove_notification(self, activate_session_mock):
        handle_remove_notification(self.options, self.session, ['1', '3', '5'])

        self.session.deleteNotification.assert_has_calls([mock.call(1), mock.call(3), mock.call(5)])