2017-02-12 11:26:31 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
#
|
|
|
|
|
# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
|
|
|
|
|
# the additional special exception to link portions of this program with the OpenSSL library.
|
|
|
|
|
# See LICENSE for more details.
|
|
|
|
|
#
|
|
|
|
|
|
2017-02-12 11:26:31 +00:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
2013-05-23 01:43:00 +01:00
|
|
|
from twisted.trial import unittest
|
2014-09-03 18:18:29 +01:00
|
|
|
|
2013-05-23 01:43:00 +01:00
|
|
|
import deluge.error
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ErrorTestCase(unittest.TestCase):
|
2016-11-04 18:03:08 +00:00
|
|
|
def setUp(self): # NOQA: N803
|
2013-05-23 01:43:00 +01:00
|
|
|
pass
|
|
|
|
|
|
2016-11-04 18:03:08 +00:00
|
|
|
def tearDown(self): # NOQA: N803
|
2013-05-23 01:43:00 +01:00
|
|
|
pass
|
|
|
|
|
|
2014-09-19 19:10:09 +01:00
|
|
|
def test_deluge_error(self):
|
2016-11-03 21:26:46 +00:00
|
|
|
msg = 'Some message'
|
2013-05-23 01:43:00 +01:00
|
|
|
e = deluge.error.DelugeError(msg)
|
2017-03-19 22:14:40 +00:00
|
|
|
self.assertEqual(str(e), msg)
|
2016-12-01 19:04:18 +00:00
|
|
|
from twisted.internet.defer import DebugInfo
|
|
|
|
|
del DebugInfo.__del__ # Hides all errors
|
2017-03-19 22:14:40 +00:00
|
|
|
self.assertEqual(e._args, (msg,))
|
|
|
|
|
self.assertEqual(e._kwargs, {})
|
2013-05-23 01:43:00 +01:00
|
|
|
|
2014-09-19 19:10:09 +01:00
|
|
|
def test_incompatible_client(self):
|
2016-11-03 21:26:46 +00:00
|
|
|
version = '1.3.6'
|
2013-05-23 01:43:00 +01:00
|
|
|
e = deluge.error.IncompatibleClient(version)
|
2017-03-19 22:14:40 +00:00
|
|
|
self.assertEqual(str(e), 'Your deluge client is not compatible with the daemon. \
|
2016-11-03 21:26:46 +00:00
|
|
|
Please upgrade your client to %s' % version)
|
2013-05-23 01:43:00 +01:00
|
|
|
|
2014-09-19 19:10:09 +01:00
|
|
|
def test_not_authorized_error(self):
|
2013-05-23 01:43:00 +01:00
|
|
|
current_level = 5
|
|
|
|
|
required_level = 10
|
|
|
|
|
e = deluge.error.NotAuthorizedError(current_level, required_level)
|
2017-03-19 22:14:40 +00:00
|
|
|
self.assertEqual(str(e), 'Auth level too low: %d < %d' % (current_level, required_level))
|
2013-05-23 01:43:00 +01:00
|
|
|
|
2014-09-19 19:10:09 +01:00
|
|
|
def test_bad_login_error(self):
|
2016-11-03 21:26:46 +00:00
|
|
|
message = 'Login failed'
|
|
|
|
|
username = 'deluge'
|
2013-05-23 01:43:00 +01:00
|
|
|
e = deluge.error.BadLoginError(message, username)
|
2017-03-19 22:14:40 +00:00
|
|
|
self.assertEqual(str(e), message)
|