summaryrefslogtreecommitdiffstats
path: root/deluge/tests/test_sessionproxy.py
diff options
context:
space:
mode:
Diffstat (limited to 'deluge/tests/test_sessionproxy.py')
-rw-r--r--deluge/tests/test_sessionproxy.py56
1 files changed, 26 insertions, 30 deletions
diff --git a/deluge/tests/test_sessionproxy.py b/deluge/tests/test_sessionproxy.py
index 03f3cc27e..6fbbb248b 100644
--- a/deluge/tests/test_sessionproxy.py
+++ b/deluge/tests/test_sessionproxy.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2016 bendikro <bro.devel+deluge@gmail.com>
#
@@ -6,19 +5,16 @@
# the additional special exception to link portions of this program with the OpenSSL library.
# See LICENSE for more details.
#
-
-from __future__ import unicode_literals
-
+import pytest_twisted
from twisted.internet.defer import maybeDeferred, succeed
from twisted.internet.task import Clock
import deluge.component as component
import deluge.ui.sessionproxy
+from deluge.conftest import BaseTestCase
-from .basetest import BaseTestCase
-
-class Core(object):
+class Core:
def __init__(self):
self.reset()
@@ -91,7 +87,7 @@ class Core(object):
return succeed(ret)
-class Client(object):
+class Client:
def __init__(self):
self.core = Core()
@@ -105,7 +101,7 @@ class Client(object):
client = Client()
-class SessionProxyTestCase(BaseTestCase):
+class TestSessionProxy(BaseTestCase):
def set_up(self):
self.clock = Clock()
self.patch(deluge.ui.sessionproxy, 'time', self.clock.seconds)
@@ -127,38 +123,38 @@ class SessionProxyTestCase(BaseTestCase):
return component.deregister(self.sp)
def test_startup(self):
- self.assertEqual(client.core.torrents['a'], self.sp.torrents['a'][1])
+ assert client.core.torrents['a'] == self.sp.torrents['a'][1]
- def test_get_torrent_status_no_change(self):
- d = self.sp.get_torrent_status('a', [])
- d.addCallback(self.assertEqual, client.core.torrents['a'])
- return d
+ @pytest_twisted.ensureDeferred
+ async def test_get_torrent_status_no_change(self):
+ result = await self.sp.get_torrent_status('a', [])
+ assert result == client.core.torrents['a']
- def test_get_torrent_status_change_with_cache(self):
+ @pytest_twisted.ensureDeferred
+ async def test_get_torrent_status_change_with_cache(self):
client.core.torrents['a']['key1'] = 2
- d = self.sp.get_torrent_status('a', ['key1'])
- d.addCallback(self.assertEqual, {'key1': 1})
- return d
+ result = await self.sp.get_torrent_status('a', ['key1'])
+ assert result == {'key1': 1}
- def test_get_torrent_status_change_without_cache(self):
+ @pytest_twisted.ensureDeferred
+ async def test_get_torrent_status_change_without_cache(self):
client.core.torrents['a']['key1'] = 2
self.clock.advance(self.sp.cache_time + 0.1)
- d = self.sp.get_torrent_status('a', [])
- d.addCallback(self.assertEqual, client.core.torrents['a'])
- return d
+ result = await self.sp.get_torrent_status('a', [])
+ assert result == client.core.torrents['a']
- def test_get_torrent_status_key_not_updated(self):
+ @pytest_twisted.ensureDeferred
+ async def test_get_torrent_status_key_not_updated(self):
self.clock.advance(self.sp.cache_time + 0.1)
self.sp.get_torrent_status('a', ['key1'])
client.core.torrents['a']['key2'] = 99
- d = self.sp.get_torrent_status('a', ['key2'])
- d.addCallback(self.assertEqual, {'key2': 99})
- return d
+ result = await self.sp.get_torrent_status('a', ['key2'])
+ assert result == {'key2': 99}
- def test_get_torrents_status_key_not_updated(self):
+ @pytest_twisted.ensureDeferred
+ async def test_get_torrents_status_key_not_updated(self):
self.clock.advance(self.sp.cache_time + 0.1)
self.sp.get_torrents_status({'id': ['a']}, ['key1'])
client.core.torrents['a']['key2'] = 99
- d = self.sp.get_torrents_status({'id': ['a']}, ['key2'])
- d.addCallback(self.assertEqual, {'a': {'key2': 99}})
- return d
+ result = await self.sp.get_torrents_status({'id': ['a']}, ['key2'])
+ assert result == {'a': {'key2': 99}}