summaryrefslogtreecommitdiffstats
path: root/deluge/plugins/Stats/deluge_stats/tests/test_stats.py
diff options
context:
space:
mode:
Diffstat (limited to 'deluge/plugins/Stats/deluge_stats/tests/test_stats.py')
-rw-r--r--deluge/plugins/Stats/deluge_stats/tests/test_stats.py60
1 files changed, 28 insertions, 32 deletions
diff --git a/deluge/plugins/Stats/deluge_stats/tests/test_stats.py b/deluge/plugins/Stats/deluge_stats/tests/test_stats.py
index 3b581be..9c66ee1 100644
--- a/deluge/plugins/Stats/deluge_stats/tests/test_stats.py
+++ b/deluge/plugins/Stats/deluge_stats/tests/test_stats.py
@@ -1,19 +1,14 @@
-# -*- 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.
#
-from __future__ import print_function, unicode_literals
-
import pytest
+import pytest_twisted
from twisted.internet import defer
-from twisted.trial import unittest
import deluge.component as component
from deluge.common import fsize, fspeed
-from deluge.tests import common as tests_common
-from deluge.tests.basetest import BaseTestCase
from deluge.ui.client import client
@@ -26,42 +21,42 @@ def print_totals(totals):
print('down:', fsize(totals['total_download'] - totals['total_payload_download']))
-class StatsTestCase(BaseTestCase):
- def set_up(self):
+@pytest.mark.usefixtures('component')
+class TestStatsPlugin:
+ @pytest_twisted.async_yield_fixture(autouse=True)
+ async def set_up(self):
defer.setDebugging(True)
- tests_common.set_tmp_config_dir()
client.start_standalone()
client.core.enable_plugin('Stats')
- return component.start()
-
- def tear_down(self):
+ await component.start()
+ yield
client.stop_standalone()
- return component.shutdown()
+ await component.shutdown()
@defer.inlineCallbacks
def test_client_totals(self):
plugins = yield client.core.get_available_plugins()
if 'Stats' not in plugins:
- raise unittest.SkipTest('WebUi plugin not available for testing')
+ pytest.skip('Stats plugin not available for testing')
totals = yield client.stats.get_totals()
- self.assertEqual(totals['total_upload'], 0)
- self.assertEqual(totals['total_payload_upload'], 0)
- self.assertEqual(totals['total_payload_download'], 0)
- self.assertEqual(totals['total_download'], 0)
+ assert totals['total_upload'] == 0
+ assert totals['total_payload_upload'] == 0
+ assert totals['total_payload_download'] == 0
+ assert totals['total_download'] == 0
# print_totals(totals)
@defer.inlineCallbacks
def test_session_totals(self):
plugins = yield client.core.get_available_plugins()
if 'Stats' not in plugins:
- raise unittest.SkipTest('WebUi plugin not available for testing')
+ pytest.skip('Stats plugin not available for testing')
totals = yield client.stats.get_session_totals()
- self.assertEqual(totals['total_upload'], 0)
- self.assertEqual(totals['total_payload_upload'], 0)
- self.assertEqual(totals['total_payload_download'], 0)
- self.assertEqual(totals['total_download'], 0)
+ assert totals['total_upload'] == 0
+ assert totals['total_payload_upload'] == 0
+ assert totals['total_payload_download'] == 0
+ assert totals['total_download'] == 0
# print_totals(totals)
@pytest.mark.gtkui
@@ -72,16 +67,17 @@ class StatsTestCase(BaseTestCase):
Not strictly a unit test, but tests if calls do not fail...
"""
- from deluge.ui.gtkui.gtkui import DEFAULT_PREFS
- from deluge.ui.gtkui.preferences import Preferences
- from deluge.ui.gtkui.mainwindow import MainWindow
- from deluge.configmanager import ConfigManager
- from deluge.ui.gtkui.pluginmanager import PluginManager
- from deluge.ui.gtkui.torrentdetails import TorrentDetails
- from deluge.ui.gtkui.torrentview import TorrentView
from deluge_stats import graph, gtkui
- ConfigManager('gtkui.conf', defaults=DEFAULT_PREFS)
+ from deluge.configmanager import ConfigManager
+ from deluge.ui.gtk3.gtkui import DEFAULT_PREFS
+ from deluge.ui.gtk3.mainwindow import MainWindow
+ from deluge.ui.gtk3.pluginmanager import PluginManager
+ from deluge.ui.gtk3.preferences import Preferences
+ from deluge.ui.gtk3.torrentdetails import TorrentDetails
+ from deluge.ui.gtk3.torrentview import TorrentView
+
+ ConfigManager('gtk3ui.conf', defaults=DEFAULT_PREFS)
self.plugins = PluginManager()
MainWindow()
@@ -89,7 +85,7 @@ class StatsTestCase(BaseTestCase):
TorrentDetails()
Preferences()
- class FakeFile(object):
+ class FakeFile:
def __init__(self):
self.data = []