コード例 #1
0
ファイル: test_manager.py プロジェクト: wwfxuk/tk-core
    def test_prepare_engine(self):
        """
        Makes sure that prepare engine works.
        """
        mgr = ToolkitManager(_MockedShotgunUser(self.mockgun, "larry"))
        mgr.do_shotgun_config_lookup = False
        mgr.base_configuration = {
            "type": "path",
            "path": os.path.join(self.fixtures_root, "bootstrap_tests",
                                 "config")
        }

        def progress_cb(progress_value, message):
            self.assertLess(progress_cb.previous_progress, progress_value)
            progress_cb.previous_progress = progress_value
            if message.startswith("Checking"):
                progress_cb.nb_exists_locally += 1

        progress_cb.nb_exists_locally = 0
        progress_cb.previous_progress = -1

        mgr.progress_callback = progress_cb
        path, desc = mgr.prepare_engine("test_engine", self.project)
        self.assertEqual(desc.get_dict(), mgr.base_configuration)
        self.assertEqual(
            path, os.path.join(self.tank_temp, "unit_test_mock_sg", "p1",
                               "cfg"))
        self.assertEqual(progress_cb.nb_exists_locally, 3)
コード例 #2
0
    def test_prepare_engine(self):
        """
        Makes sure that prepare engine works.
        """
        mgr = ToolkitManager(_MockedShotgunUser(self.mockgun, "larry"))
        mgr.do_shotgun_config_lookup = False
        mgr.base_configuration = {
            "type": "path",
            "path": os.path.join(
                self.fixtures_root, "bootstrap_tests", "config"
            )
        }

        def progress_cb(progress_value, message):
            self.assertLess(progress_cb.previous_progress, progress_value)
            progress_cb.previous_progress = progress_value
            if message.startswith("Checking"):
                progress_cb.nb_exists_locally += 1

        progress_cb.nb_exists_locally = 0
        progress_cb.previous_progress = -1

        mgr.progress_callback = progress_cb
        path, desc = mgr.prepare_engine("test_engine", self.project)
        self.assertEqual(desc.get_dict(), mgr.base_configuration)
        self.assertEqual(path, os.path.join(self.tank_temp, "unit_test_mock_sg", "p1", "cfg"))
        self.assertEqual(progress_cb.nb_exists_locally, 3)
コード例 #3
0
ファイル: test_manager.py プロジェクト: papepipe/tk-core
    def test_serialization(self, _):
        """
        Ensures we're serializing the manager properly.
        """
        # Make sure nobody has added new parameters that need to be serialized.
        class_attrs = set(dir(ToolkitManager))
        instance_attrs = set(dir(ToolkitManager()))
        unserializable_attrs = set([
            "_sg_connection", "_sg_user", "_pre_engine_start_callback",
            "_progress_cb"
        ])
        # Through this operation, we're taking all the symbols that are defined from an instance,
        # we then remove everything that is defined also in the class, which means we're left
        # with what was added during __init__, and then we remove the parameters we know can't
        # be serialized. We're left with a small list of values that can be serialized.
        instance_data_members = instance_attrs - class_attrs - unserializable_attrs
        self.assertEqual(len(instance_data_members), 7)

        # Create a manager that hasn't been updated yet.
        clean_mgr = ToolkitManager()
        clean_settings = clean_mgr.extract_settings()

        # Now create one where we modify everything.
        modified_mgr = ToolkitManager()
        modified_mgr.bundle_cache_fallback_paths = ["/a/b/c"]
        modified_mgr.caching_policy = ToolkitManager.CACHE_FULL
        modified_mgr.pipeline_configuration = "Primary"
        modified_mgr.base_configuration = (
            "sgtk:descriptor:app_store?"
            "version=v0.18.91&name=tk-config-basic")
        modified_mgr.do_shotgun_config_lookup = False
        modified_mgr.plugin_id = "basic.default"
        modified_mgr.allow_config_overrides = False

        # Extract settings and make sure the implementation still stores dictionaries.
        modified_settings = modified_mgr.extract_settings()
        self.assertIsInstance(modified_settings, dict)

        # Make sure the unit test properly changes all the settings from their default values.
        for k, v in modified_settings.items():
            self.assertNotEqual(v, clean_settings[k])

        # Restore the settings from the manager.
        restored_mgr = ToolkitManager()
        restored_mgr.restore_settings(modified_settings)

        # Extract the settings back from the restored manager to make sure everything was written
        # back correctly.
        self.assertEqual(restored_mgr.extract_settings(), modified_settings)
コード例 #4
0
ファイル: test_manager.py プロジェクト: adriankrupa/tk-core
    def test_serialization(self, _):
        """
        Ensures we're serializing the manager properly.
        """
        # Make sure nobody has added new parameters that need to be serialized.
        class_attrs = set(dir(ToolkitManager))
        instance_attrs = set(dir(ToolkitManager()))
        unserializable_attrs = set(
            ["_sg_connection", "_sg_user", "_pre_engine_start_callback", "_progress_cb"]
        )
        # Through this operation, we're taking all the symbols that are defined from an instance,
        # we then remove everything that is defined also in the class, which means we're left
        # with what was added during __init__, and then we remove the parameters we know can't
        # be serialized. We're left with a small list of values that can be serialized.
        instance_data_members = instance_attrs - class_attrs - unserializable_attrs
        self.assertEqual(len(instance_data_members), 7)

        # Create a manager that hasn't been updated yet.
        clean_mgr = ToolkitManager()
        clean_settings = clean_mgr.extract_settings()

        # Now create one where we modify everything.
        modified_mgr = ToolkitManager()
        modified_mgr.bundle_cache_fallback_paths = ["/a/b/c"]
        modified_mgr.caching_policy = ToolkitManager.CACHE_FULL
        modified_mgr.pipeline_configuration = "Primary"
        modified_mgr.base_configuration = "sgtk:descriptor:app_store?"\
            "version=v0.18.91&name=tk-config-basic"
        modified_mgr.do_shotgun_config_lookup = False
        modified_mgr.plugin_id = "basic.default"
        modified_mgr.allow_config_overrides = False

        # Extract settings and make sure the implementation still stores dictionaries.
        modified_settings = modified_mgr.extract_settings()
        self.assertIsInstance(modified_settings, dict)

        # Make sure the unit test properly changes all the settings from their default values.
        for k, v in modified_settings.iteritems():
            self.assertNotEqual(v, clean_settings[k])

        # Restore the settings from the manager.
        restored_mgr = ToolkitManager()
        restored_mgr.restore_settings(modified_settings)

        # Extract the settings back from the restored manager to make sure everything was written
        # back correctly.
        self.assertEqual(restored_mgr.extract_settings(), modified_settings)