def test_update_config_file_to_version3(self): config_file = "yarss2_v2.conf" filename = yarss2.util.common.get_resource(config_file, path="tests/data/") tmp_dir = common.set_tmp_config_dir() shutil.copy(filename, tmp_dir) self.config = common.get_test_config(config_filename=config_file, config_dir=tmp_dir, verify_config=False) # Call the function that makes the changes self.config.config.run_converter((2, 2), 3, self.config.update_config_to_version3) # Added field 'download_location' for key in self.config.config["subscriptions"]: self.assertTrue( "download_location" in self.config.config["subscriptions"][key], "Field 'download_location' does not exist!") for key in self.config.config["rssfeeds"]: self.assertTrue("obey_ttl" in self.config.config["rssfeeds"][key], "Field 'obey_ttl' does not exist!") for key in self.config.config["email_configurations"].keys(): self.assertTrue( not type(self.config.config["email_configurations"][key]) is str, "Field in str!") self.assertEquals(self.config.config._Config__version["file"], 3)
def test_update_config_file_from_1_2_beta(self): tmp_dir = common.set_tmp_config_dir() config_file = "yarss2_v1.2.beta.conf" filename = yarss2.util.common.get_resource(config_file, path="tests/data/") shutil.copy(filename, tmp_dir) self.config = common.get_test_config(config_filename=config_file, config_dir=tmp_dir, verify_config=False) self.assertEquals(self.config.config._Config__version["format"], 1) self.assertEquals(self.config.config._Config__version["file"], 2) # Verify that the old values are what we expect for key in self.config.config["cookies"].keys(): self.assertEquals( type(self.config.config["cookies"][key]["value"]), dict) # Update the config self.config._verify_config() config_dict = self.config.config.config config_file = "yarss2_v5.conf" filename = yarss2.util.common.get_resource(config_file, path="tests/data/") shutil.copy(filename, tmp_dir) self.config = common.get_test_config(config_filename=config_file, config_dir=tmp_dir, verify_config=False) config_dict_v5 = self.config.config.config # Verify that the 1.2 beta config equals the config updated from earlier versions self.assertTrue( yarss2.util.common.dicts_equals(config_dict_v5, config_dict))
def test_update_config_file_to_version6(self): config_file = "yarss2_v5.conf" filename = yarss2.util.common.get_resource(config_file, path="tests/data/") tmp_dir = common.set_tmp_config_dir() shutil.copy(filename, tmp_dir) self.config = common.get_test_config(config_filename=config_file, config_dir=tmp_dir, verify_config=False) # Call the function that makes the changes self.config.config.run_converter((5, 5), 6, self.config.update_config_to_version6) for key in self.config.config["subscriptions"].keys(): self.assertTrue( "ignore_timestamp" in self.config.config["subscriptions"][key]) self.assertFalse( self.config.config["subscriptions"][key]["ignore_timestamp"]) self.assertTrue( "label" in self.config.config["subscriptions"][key]) self.assertEquals( self.config.config["subscriptions"][key]["label"], "") # Test changes for "change_value_from_list_to_dict" for rssfeed in self.config.config["rssfeeds"].values(): self.assertTrue("user_agent" in rssfeed) self.assertEquals(rssfeed["user_agent"], "") self.assertEquals(self.config.config._Config__version["file"], 6)
def test_update_config_file_to_version4(self): config_file = "yarss2_v3.conf" filename = yarss2.util.common.get_resource(config_file, path="tests/data/") tmp_dir = common.set_tmp_config_dir() shutil.copy(filename, tmp_dir) self.config = common.get_test_config(config_filename=config_file, config_dir=tmp_dir, verify_config=False) subscription_keys = self.config.config["subscriptions"].keys() last_update_values = [ self.config.config["subscriptions"][key]["last_update"] for key in subscription_keys ] # Call the function that makes the changes self.config.config.run_converter((3, 3), 4, self.config.update_config_to_version4) for i, key in enumerate(subscription_keys): # Test changes for "replace_last_update_with_last_match" self.assertTrue( "last_match" in self.config.config["subscriptions"][key]) self.assertFalse( "last_update" in self.config.config["subscriptions"][key]) self.assertEquals( self.config.config["subscriptions"][key]["last_match"], last_update_values[i]) self.assertEquals(self.config.config._Config__version["file"], 4)
def setup_config(self): global config_setup config_setup = True config_dir = common.set_tmp_config_dir() core_config = deluge.config.Config( "core.conf", defaults=deluge.core.preferencesmanager.DEFAULT_PREFS, config_dir=config_dir) core_config.save()
def test_update_config_file_from_1_0(self): tmp_dir = common.set_tmp_config_dir() # Copy the yarss2_v1.conf file to test dir to avoid changes to the file. config_file = "yarss2_v1.conf" filename = yarss2.util.common.get_resource(config_file, path="tests/data/") shutil.copy(filename, tmp_dir) self.config = common.get_test_config(config_filename=config_file, config_dir=tmp_dir, verify_config=False) self.assertEquals(self.config.config._Config__version["format"], 1) self.assertEquals(self.config.config._Config__version["file"], 1) # Verify that the old values are what we expect for key in self.config.config["cookies"].keys(): self.assertEquals( type(self.config.config["cookies"][key]["value"]), list) # Update the config self.config._verify_config() for key in self.config.config["cookies"].keys(): self.assertEquals( type(self.config.config["cookies"][key]["value"]), dict) for key in self.config.config["subscriptions"].keys(): # last_update replaced with last_match self.assertFalse( "last_update" in self.config.config["subscriptions"][key]) self.assertTrue( "last_match" in self.config.config["subscriptions"][key]) # Add in paused state should be string self.assertEquals( type(self.config.config["subscriptions"][key] ["add_torrents_in_paused_state"]), unicode) self.assertTrue( "max_upload_slots" in self.config.config["subscriptions"][key]) self.assertTrue( "max_connections" in self.config.config["subscriptions"][key]) self.assertTrue( "max_upload_speed" in self.config.config["subscriptions"][key]) self.assertTrue("prioritize_first_last_pieces" in self.config.config["subscriptions"][key]) self.assertTrue( "auto_managed" in self.config.config["subscriptions"][key]) self.assertTrue("sequential_download" in self.config.config["subscriptions"][key]) # Test cookie type for cookie in self.config.config["cookies"].values(): self.assertEquals(type(cookie["value"]), dict) self.assertEquals(self.config.config._Config__version["format"], 1)
def test_update_config_file_to_version5(self): config_file = "yarss2_v4.conf" filename = yarss2.util.common.get_resource(config_file, path="tests/data/") tmp_dir = common.set_tmp_config_dir() shutil.copy(filename, tmp_dir) self.config = common.get_test_config(config_filename=config_file, config_dir=tmp_dir, verify_config=False) # Call the function that makes the changes self.config.config.run_converter((4, 4), 5, self.config.update_config_to_version5) # Test changes for "add_torrents_in_paused_state_to_GeneralSubsConf" self.assertEquals( self.config.config["subscriptions"]["0"] ["add_torrents_in_paused_state"], GeneralSubsConf.DISABLED) self.assertEquals( self.config.config["subscriptions"]["1"] ["add_torrents_in_paused_state"], GeneralSubsConf.ENABLED) for key in self.config.config["subscriptions"].keys(): # last_update replaced with last_match self.assertFalse( "last_update" in self.config.config["subscriptions"][key]) self.assertTrue( "last_match" in self.config.config["subscriptions"][key]) # Add in paused state should be unicode self.assertEquals( type(self.config.config["subscriptions"][key] ["add_torrents_in_paused_state"]), unicode) self.assertTrue( "max_upload_slots" in self.config.config["subscriptions"][key]) self.assertTrue( "max_connections" in self.config.config["subscriptions"][key]) self.assertTrue( "max_upload_speed" in self.config.config["subscriptions"][key]) self.assertTrue("prioritize_first_last_pieces" in self.config.config["subscriptions"][key]) self.assertTrue( "auto_managed" in self.config.config["subscriptions"][key]) self.assertTrue("sequential_download" in self.config.config["subscriptions"][key]) # Test changes for "change_value_from_list_to_dict" for cookie in self.config.config["cookies"].values(): self.assertEquals(type(cookie["value"]), dict) self.assertEquals(self.config.config._Config__version["file"], 5)
def test_update_config_file_to_version2(self): config_file = "yarss2_v1.conf" filename = yarss2.util.common.get_resource(config_file, path="tests/data/") tmp_dir = common.set_tmp_config_dir() shutil.copy(filename, tmp_dir) self.config = common.get_test_config(config_filename=config_file, config_dir=tmp_dir, verify_config=False) # Call the function that makes the changes self.config.config.run_converter((0, 1), 2, self.config.update_config_to_version2) # 1 - search field from subscription was removed # 2 - Added field 'custom_text_lines' subscriptions = self.config.config["subscriptions"] for key in subscriptions: self.assertFalse("search" in subscriptions[key], "Field 'search still exists'") self.assertTrue("custom_text_lines" in subscriptions[key], "Field 'custom_text_lines' does not exist!") self.assertEquals(self.config.config._Config__version["file"], 2)
def setUp(self): self.config_dir = common.set_tmp_config_dir()
import os from twisted.trial import unittest from deluge.ui.tracker_icons import TrackerIcons, TrackerIcon import common common.set_tmp_config_dir() icons = TrackerIcons() dirname = os.path.dirname(__file__) class TrackerIconsTestCase(unittest.TestCase): def test_get_deluge_png(self): # Deluge has a png favicon link icon = TrackerIcon(os.path.join(dirname, "deluge.png")) d = icons.get("deluge-torrent.org") d.addCallback(self.assertNotIdentical, None) d.addCallback(self.assertEquals, icon) return d def test_get_google_ico(self): # Google doesn't have any icon links # So instead we'll grab its favicon.ico icon = TrackerIcon(os.path.join(dirname, "google.ico")) d = icons.get("www.google.com") d.addCallback(self.assertNotIdentical, None) d.addCallback(self.assertEquals, icon) return d
def setUp(self): common.set_tmp_config_dir() self.rpcserver = RPCServer(listen=False) self.core = Core() d = component.start() return d
import tempfile import os import signal import common from twisted.trial import unittest from deluge.ui.client import client # Start a daemon to test with and wait a couple seconds to make sure it's started config_directory = common.set_tmp_config_dir() client.start_daemon(58847, config_directory) import time time.sleep(2) class ClientTestCase(unittest.TestCase): def test_connect_no_credentials(self): d = client.connect("localhost", 58847) d.addCallback(self.assertEquals, 10) def on_connect(result): self.addCleanup(client.disconnect) return result d.addCallback(on_connect) return d
def setUp(self): common.set_tmp_config_dir() self.rpcserver = RPCServer(listen=False) self.core = Core() return component.start().addCallback(self.startWebserver)
def setup_config(self): global config_setup config_setup = True config_dir = common.set_tmp_config_dir() core_config = deluge.config.Config("core.conf", defaults=deluge.core.preferencesmanager.DEFAULT_PREFS, config_dir=config_dir) core_config.save()