def test_update_config_to_version5(self):
        default_subscription = yarss2.yarss_config.get_fresh_subscription_config()
        # Create 2 feeds
        test_feeds = common.get_default_rssfeeds(2)
        # Create 3 subscriptions
        test_subscriptions = common.get_default_subscriptions(2)

        # Replace field last_update with last_match
        self.config.config["rssfeeds"] = test_feeds
        self.config.config["subscriptions"] = test_subscriptions
        self.config.config["cookies"] = {"0": {
            "active": True,
            "value": [["uid", "175728"], ["pass", "3421d1a00b48397a874454626decec04"]],
            "site": "bitmetv.org",
            "key": "0"}}

        test_subscriptions["0"]["add_torrents_in_paused_state"] = True
        test_subscriptions["1"]["add_torrents_in_paused_state"] = False

        # Call the function that makes the changes
        self.config._verify_config()

        # Test changes for "add_torrents_in_paused_state_to_GeneralSubsConf"
        self.assertEquals(test_subscriptions["0"]["add_torrents_in_paused_state"], GeneralSubsConf.ENABLED)
        self.assertEquals(test_subscriptions["1"]["add_torrents_in_paused_state"], GeneralSubsConf.DISABLED)

        # Test changes for "change_value_from_list_to_dict"
        values = self.config.config["cookies"]["0"]["value"]
        self.assertTrue(type(values) is dict)
        self.assertTrue(values.has_key("uid"))
        self.assertEquals(values["uid"], "175728")
        self.assertTrue(values.has_key("pass"))
        self.assertEquals(values["pass"], "3421d1a00b48397a874454626decec04")
    def test_verify_config(self):
        default_subscription = yarss2.yarss_config.get_fresh_subscription_config()
        test_feeds = common.get_default_rssfeeds(2)
        test_subscriptions = common.get_default_subscriptions(3)
        test_subscriptions["0"]["rssfeed_key"] = "0"
        test_subscriptions["1"]["rssfeed_key"] = "0"
        test_subscriptions["0"]["name"] = True # Wrong type

        del test_subscriptions["0"]["regex_include"]
        del test_subscriptions["1"]["key"]
        del test_subscriptions["2"]["rssfeed_key"]

        self.config.config["rssfeeds"] = test_feeds
        self.config.config["subscriptions"] = test_subscriptions
        self.config._verify_config()

        # Should have the key reinserted
        self.assertEquals(test_subscriptions["1"]["key"], "1")
        # Name should be default value
        self.assertEquals(test_subscriptions["0"]["name"], default_subscription["name"])
        # regex_include should be reinserted with the default value
        self.assertTrue(test_subscriptions["0"].has_key("regex_include"))
        # The rssfeed_key should be the dummy
        self.assertEquals(test_subscriptions["2"]["rssfeed_key"], yarss2.yarss_config.DUMMY_RSSFEED_KEY)
        # The dummy should now exist in rssfeeds dict
        self.assertTrue(test_feeds.has_key(yarss2.yarss_config.DUMMY_RSSFEED_KEY))
    def test_update_config_to_version4(self):
        # default_subscription = yarss2.yarss_config.get_fresh_subscription_config()
        # Create 2 feeds
        test_feeds = common.get_default_rssfeeds(2)
        # Create 3 subscriptions
        test_subscriptions = common.get_default_subscriptions(2)

        last_match_value = test_subscriptions["0"]["last_match"]
        # Old config had last_update instead of last_match
        test_subscriptions["0"]["last_update"] = test_subscriptions["0"][
            "last_match"]
        del test_subscriptions["0"]["last_match"]

        # Replace field last_update with last_match
        self.config.config["rssfeeds"] = test_feeds
        self.config.config["subscriptions"] = test_subscriptions

        # Call the function that makes the changes
        self.config._verify_config()

        # Test that last_update was replaced with last_match
        self.assertTrue("last_match" in test_subscriptions["0"])
        self.assertFalse("last_update" in test_subscriptions["0"])
        self.assertEquals(test_subscriptions["0"]["last_match"],
                          last_match_value)
    def test_verify_config(self):
        default_subscription = yarss2.yarss_config.get_fresh_subscription_config(
        )
        test_feeds = common.get_default_rssfeeds(2)
        test_subscriptions = common.get_default_subscriptions(3)
        test_subscriptions["0"]["rssfeed_key"] = "0"
        test_subscriptions["1"]["rssfeed_key"] = "0"
        test_subscriptions["0"]["name"] = True  # Wrong type

        del test_subscriptions["0"]["regex_include"]
        del test_subscriptions["1"]["key"]
        del test_subscriptions["2"]["rssfeed_key"]

        email_conf = yarss2.yarss_config.get_fresh_email_config()
        del email_conf["default_email_to_address"]

        self.config.config["rssfeeds"] = test_feeds
        self.config.config["subscriptions"] = test_subscriptions
        self.config.config["email_configurations"] = email_conf
        self.config._verify_config()

        # Should have the key reinserted
        self.assertEquals(test_subscriptions["1"]["key"], "1")
        # Name should be default value
        self.assertEquals(test_subscriptions["0"]["name"],
                          default_subscription["name"])
        # regex_include should be reinserted with the default value
        self.assertTrue("regex_include" in test_subscriptions["0"])
        # The rssfeed_key should be the dummy
        self.assertEquals(test_subscriptions["2"]["rssfeed_key"],
                          yarss2.yarss_config.DUMMY_RSSFEED_KEY)
        # The dummy should now exist in rssfeeds dict
        self.assertTrue(yarss2.yarss_config.DUMMY_RSSFEED_KEY in test_feeds)
        self.assertTrue("default_email_to_address" in
                        self.config.config["email_configurations"])
    def setUp(self):
        self.rssfeeds = get_default_rssfeeds(5)
        self.rssfeeds["0"]["update_interval"] = 1
        self.rssfeeds["1"]["update_interval"] = 3
        self.rssfeeds["2"]["update_interval"] = 10
        self.rssfeeds["3"]["update_interval"] = 30
        self.rssfeeds["4"]["update_interval"] = 120

        self.config = common.get_empty_test_config()
        self.config.set_config({"rssfeeds": self.rssfeeds, "email_configurations": {"send_email_on_torrent_events": False} })
Exemplo n.º 6
0
    def setUp(self):
        self.rssfeeds = get_default_rssfeeds(5)
        self.rssfeeds["0"]["update_interval"] = 1
        self.rssfeeds["1"]["update_interval"] = 3
        self.rssfeeds["2"]["update_interval"] = 10
        self.rssfeeds["3"]["update_interval"] = 30
        self.rssfeeds["4"]["update_interval"] = 120

        self.config = common.get_empty_test_config()
        self.config.set_config({
            "rssfeeds": self.rssfeeds,
            "email_configurations": {
                "send_email_on_torrent_events": False
            }
        })
    def test_update_config_to_version5(self):
        # default_subscription = yarss2.yarss_config.get_fresh_subscription_config()
        # Create 2 feeds
        test_feeds = common.get_default_rssfeeds(2)
        # Create 3 subscriptions
        test_subscriptions = common.get_default_subscriptions(2)

        # Replace field last_update with last_match
        self.config.config["rssfeeds"] = test_feeds
        self.config.config["subscriptions"] = test_subscriptions
        self.config.config["cookies"] = {
            "0": {
                "active":
                True,
                "value": [["uid", "175728"],
                          ["pass", "3421d1a00b48397a874454626decec04"]],
                "site":
                "bitmetv.org",
                "key":
                "0"
            }
        }

        test_subscriptions["0"]["add_torrents_in_paused_state"] = True
        test_subscriptions["1"]["add_torrents_in_paused_state"] = False

        # Call the function that makes the changes
        self.config._verify_config()

        # Test changes for "add_torrents_in_paused_state_to_GeneralSubsConf"
        self.assertEquals(
            test_subscriptions["0"]["add_torrents_in_paused_state"],
            GeneralSubsConf.ENABLED)
        self.assertEquals(
            test_subscriptions["1"]["add_torrents_in_paused_state"],
            GeneralSubsConf.DISABLED)

        # Test changes for "change_value_from_list_to_dict"
        values = self.config.config["cookies"]["0"]["value"]
        self.assertTrue(type(values) is dict)
        self.assertTrue("uid" in values)
        self.assertEquals(values["uid"], "175728")
        self.assertTrue("pass" in values)
        self.assertEquals(values["pass"], "3421d1a00b48397a874454626decec04")
    def test_update_config_to_version4(self):
        default_subscription = yarss2.yarss_config.get_fresh_subscription_config()
        # Create 2 feeds
        test_feeds = common.get_default_rssfeeds(2)
        # Create 3 subscriptions
        test_subscriptions = common.get_default_subscriptions(2)

        last_match_value = test_subscriptions["0"]["last_match"]
        # Old config had last_update instead of last_match
        test_subscriptions["0"]["last_update"] = test_subscriptions["0"]["last_match"]
        del test_subscriptions["0"]["last_match"]

        # Replace field last_update with last_match
        self.config.config["rssfeeds"] = test_feeds
        self.config.config["subscriptions"] = test_subscriptions

        # Call the function that makes the changes
        self.config._verify_config()

        # Test that last_update was replaced with last_match
        self.assertTrue(test_subscriptions["0"].has_key("last_match"))
        self.assertFalse(test_subscriptions["0"].has_key("last_update"))
        self.assertEquals(test_subscriptions["0"]["last_match"], last_match_value)