def test_update_config_file_from_1_2_beta(self):
        tmp_dir = common.get_tmp_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_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 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_to_version5(self):
        config_file = "yarss2_v4.conf"
        filename = yarss2.util.common.get_resource(config_file, path="tests/data/")
        tmp_dir = common.get_tmp_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)
 def setUp(self):
     self.config = get_test_config()
     tf_reset_default_graph()
     # reset name generation on every test
     utils.INTERNAL_NAME = 1
     np.random.seed(1)  # Make it reproducible.
     self.logger = logging.getLogger(self.__class__.__name__)
    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.get_tmp_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(subscriptions[key].has_key("search"), "Field 'search still exists'")
            self.assertTrue(subscriptions[key].has_key("custom_text_lines"), "Field 'custom_text_lines' does not exist!")
Example #11
0
    def setUp(self):
        self.config = get_test_config()
        self.maxDiff = None
        tf.reset_default_graph()
        # reset name generation on every test
        utils.INTERNAL_NAME = 1
        np.random.seed(1)  # Make it reproducible.

        self.log = logging.getLogger("tf2onnx.unitest." + str(type(self)))
        if self.config.is_debug_mode:
            self.log.setLevel(logging.DEBUG)
        else:
            # suppress log info of tensorflow so that result of test can be seen much easier
            os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
            tf.logging.set_verbosity(tf.logging.WARN)
            self.log.setLevel(logging.INFO)
    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.get_tmp_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(self.config.config["subscriptions"][key].has_key("last_match"))
            self.assertFalse(self.config.config["subscriptions"][key].has_key("last_update"))
            self.assertEquals(self.config.config["subscriptions"][key]["last_match"], last_update_values[i])
    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.get_tmp_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(self.config.config["subscriptions"][key].has_key("download_location"), "Field 'download_location' does not exist!")

        for key in self.config.config["rssfeeds"]:
            self.assertTrue(self.config.config["rssfeeds"][key].has_key("obey_ttl"), "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!")
    def test_update_config_file_from_1_0(self):
        tmp_dir = common.get_tmp_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)
        self.assertEquals(self.config.config._Config__version["file"], 5)
Example #15
0
    def setUp(self):
        """Setup test."""
        # reset name generation on every test
        # suppress log info of tensorflow so that result of test can be seen much easier
        os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
        tf.logging.set_verbosity(tf.logging.WARN)

        self.config = get_test_config()

        tf2onnx.utils.INTERNAL_NAME = 1
        tf.reset_default_graph()
        arg = namedtuple("Arg",
                         "input inputs outputs verbose continue_on_error")
        self._args0 = arg(input="test",
                          inputs=[],
                          outputs=["output:0"],
                          verbose=False,
                          continue_on_error=False)
        self._args1 = arg(input="test",
                          inputs=["input:0"],
                          outputs=["output:0"],
                          verbose=False,
                          continue_on_error=False)
        self._args2 = arg(input="test",
                          inputs=["input1:0", "input2:0"],
                          outputs=["output:0"],
                          verbose=False,
                          continue_on_error=False)
        self._args3 = arg(input="test",
                          inputs=["input1:0", "input2:0", "prob:0"],
                          outputs=["output:0"],
                          verbose=False,
                          continue_on_error=False)
        self._args4 = arg(input="test",
                          inputs=["input1:0", "input2:0"],
                          outputs=["output1:0", "output2:0"],
                          verbose=False,
                          continue_on_error=False)
    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)
Example #17
0
def pytest_configure():
    config = get_test_config()
    logging.basicConfig(level=config.log_level)
    with logging.set_scope_level(logging.INFO) as logger:
        logger.info(config)
"""
Test module for the Fedex ShipService WSDL.
"""

import unittest

import sys
sys.path.insert(0, '..')
from fedex.services.track_service import FedexTrackRequest

# Common global config object for testing.
from common import get_test_config
CONFIG_OBJ = get_test_config()


class TrackServiceTests(unittest.TestCase):
    """
    These tests verify that the shipping service WSDL is in good shape.
    """
    def test_track(self):
        # Test shipment tracking. Query for a tracking number and make sure the
        # first (and hopefully only) result matches up.

        tracking_num = '781820562774'

        track = FedexTrackRequest(CONFIG_OBJ)

        # Track by Tracking Number
        track.SelectionDetails.PackageIdentifier.Type = 'TRACKING_NUMBER_OR_DOORTAG'
        track.SelectionDetails.PackageIdentifier.Value = tracking_num
Example #19
0
 def setUp(self):  # NOQA
     self.config = common.get_test_config()
 def setUp(self):
     self.config = common.get_test_config()
Example #21
0
"""
Test module for the Fedex ShipService WSDL.
"""
import unittest
from fedex.services.track_service import FedexTrackRequest
import common

# Common global config object for testing.
CONFIG_OBJ = common.get_test_config()


class TrackServiceTests(unittest.TestCase):
    """
    These tests verify that the shipping service WSDL is in good shape.
    """
    def test_track(self):
        """
        Test shipment tracking. Query for a tracking number and make sure the
        first (and hopefully only) result matches up.
        """
        track = FedexTrackRequest(CONFIG_OBJ)
        track.TrackPackageIdentifier.Type = 'TRACKING_NUMBER_OR_DOORTAG'
        track.TrackPackageIdentifier.Value = '798114182456'
        track.send_request()

        for match in track.response.TrackDetails:
            # This should be the same tracking number on the response that we
            # asked for in the request.
            self.assertEqual(match.TrackingNumber, tracking_num)
Example #22
0
"""
Test module for the Fedex ShipService WSDL.
"""
import unittest
from fedex.services.track_service import FedexTrackRequest
import common

# Common global config object for testing.
CONFIG_OBJ = common.get_test_config()

class TrackServiceTests(unittest.TestCase):
    """
    These tests verify that the shipping service WSDL is in good shape.
    """
    def test_track(self):
        """
        Test shipment tracking. Query for a tracking number and make sure the
        first (and hopefully only) result matches up.
        """
        track = FedexTrackRequest(CONFIG_OBJ)
        track.TrackPackageIdentifier.Type = 'TRACKING_NUMBER_OR_DOORTAG'
        track.TrackPackageIdentifier.Value = '798114182456'
        track.send_request()
            
        for match in track.response.TrackDetails:
            # This should be the same tracking number on the response that we
            # asked for in the request.
            self.assertEqual(match.TrackingNumber, tracking_num)
 def setUp(self):
     self.config = common.get_test_config(verify_config=False)
 def setUp(self):  # NOQA
     self.config = common.get_test_config(verify_config=False)
Example #25
0
def pytest_configure():
    print(get_test_config())