コード例 #1
0
    def test_storage_roots_get_local_storages(self):
        """Test the get_local_storages method."""

        single_root = StorageRoots.from_metadata(self._single_root_metadata)
        (single_root_lookup,
         unmapped_roots) = single_root.get_local_storages(self.mockgun)

        self.assertTrue("primary" in single_root_lookup)
        single_root_default = single_root_lookup["primary"]
        self.assertEqual(single_root_default["code"], "primary")
        self.assertEqual(single_root_default["type"], "LocalStorage")
        self.assertEqual(single_root_default["id"], 1)

        single_root_storage_paths = single_root.as_shotgun_paths["primary"]
        self.assertEqual(single_root_storage_paths,
                         ShotgunPath.from_shotgun_dict(single_root_default))
        self.assertEqual(unmapped_roots, [])

        multiple_roots = StorageRoots.from_metadata(
            self._multiple_roots_metadata)
        (multiple_root_lookup,
         unmapped_roots) = multiple_roots.get_local_storages(self.mockgun)

        self.assertTrue("work" in multiple_root_lookup)
        multiple_roots_default = multiple_root_lookup["work"]
        self.assertEqual(multiple_roots_default["code"], "work")
        self.assertEqual(multiple_roots_default["type"], "LocalStorage")
        self.assertEqual(multiple_roots_default["id"], 2)

        multiple_roots_storage_paths = multiple_roots.as_shotgun_paths["work"]
        self.assertEqual(multiple_roots_storage_paths,
                         ShotgunPath.from_shotgun_dict(multiple_roots_default))
        self.assertEqual(unmapped_roots, ["foobar"])
コード例 #2
0
    def test_storage_roots_get_local_storages(self):
        """Test the get_local_storages method."""

        single_root = StorageRoots.from_metadata(self._single_root_metadata)
        (single_root_lookup, unmapped_roots) = single_root.get_local_storages(self.mockgun)

        self.assertTrue("primary" in single_root_lookup)
        single_root_default = single_root_lookup["primary"]
        self.assertEqual(single_root_default["code"], "primary")
        self.assertEqual(single_root_default["type"], "LocalStorage")
        self.assertEqual(single_root_default["id"], 1)

        single_root_storage_paths = single_root.as_shotgun_paths["primary"]
        self.assertEqual(single_root_storage_paths, ShotgunPath.from_shotgun_dict(single_root_default))
        self.assertEqual(unmapped_roots, [])

        multiple_roots = StorageRoots.from_metadata(self._multiple_roots_metadata)
        (multiple_root_lookup, unmapped_roots) = multiple_roots.get_local_storages(self.mockgun)

        self.assertTrue("work" in multiple_root_lookup)
        multiple_roots_default = multiple_root_lookup["work"]
        self.assertEqual(multiple_roots_default["code"], "work")
        self.assertEqual(multiple_roots_default["type"], "LocalStorage")
        self.assertEqual(multiple_roots_default["id"], 2)

        multiple_roots_storage_paths = multiple_roots.as_shotgun_paths["work"]
        self.assertEqual(multiple_roots_storage_paths, ShotgunPath.from_shotgun_dict(multiple_roots_default))
        self.assertEqual(unmapped_roots, ["foobar"])
コード例 #3
0
    def test_storage_roots_default_path(self):
        """Test the default_path property."""

        single_root = StorageRoots.from_config(self._single_root_config_folder)
        single_root_default_path = ShotgunPath.from_shotgun_dict(
            self._single_root_metadata["primary"])
        self.assertTrue(single_root.default_path, single_root_default_path)

        multiple_roots = StorageRoots.from_config(
            self._multiple_roots_config_folder)
        multiple_roots_default_path = ShotgunPath.from_shotgun_dict(
            self._multiple_roots_metadata["work"])
        self.assertTrue(multiple_roots.default_path,
                        multiple_roots_default_path)

        no_roots = StorageRoots.from_config(self._no_roots_config_folder)
        self.assertEqual(no_roots.default_path, None)
コード例 #4
0
    def test_storage_roots_default_path(self):
        """Test the default_path property."""

        single_root = StorageRoots.from_config(self._single_root_config_folder)
        single_root_default_path = ShotgunPath.from_shotgun_dict(
            self._single_root_metadata["primary"])
        self.assertTrue(single_root.default_path, single_root_default_path)

        multiple_roots = StorageRoots.from_config(self._multiple_roots_config_folder)
        multiple_roots_default_path = ShotgunPath.from_shotgun_dict(
            self._multiple_roots_metadata["work"])
        self.assertTrue(multiple_roots.default_path, multiple_roots_default_path)

        empty_roots = StorageRoots.from_config(self._empty_roots_config_folder)
        self.assertEqual(empty_roots.default_path, None)

        no_roots = StorageRoots.from_config(self._no_roots_config_folder)
        self.assertEqual(no_roots.default_path, None)
コード例 #5
0
    def test_construction(self):
        """
        Tests get_cache_root
        """
        self.assertEqual(ShotgunPath.SHOTGUN_PATH_FIELDS,
                         ["windows_path", "linux_path", "mac_path"])

        sg = ShotgunPath.from_shotgun_dict({
            "windows_path": "C:\\temp",
            "mac_path": "/tmp",
            "linux_path": "/tmp2",
            "foo": "bar"
        })

        self.assertEqual(sg.windows, "C:\\temp")
        self.assertEqual(sg.macosx, "/tmp")
        self.assertEqual(sg.linux, "/tmp2")

        sg = ShotgunPath.from_shotgun_dict({
            "windows_path": "C:\\temp",
            "mac_path": None,
            "foo": "bar"
        })

        self.assertEqual(sg.windows, "C:\\temp")
        self.assertEqual(sg.macosx, None)
        self.assertEqual(sg.linux, None)

        sys_paths = ShotgunPath.from_system_dict({
            "win32": "C:\\temp",
            "darwin": "/tmp",
            "linux2": "/tmp2",
            "foo": "bar"
        })

        self.assertEqual(sys_paths.windows, "C:\\temp")
        self.assertEqual(sys_paths.macosx, "/tmp")
        self.assertEqual(sys_paths.linux, "/tmp2")

        sys_paths = ShotgunPath.from_system_dict({
            "win32": "C:\\temp",
            "darwin": None,
            "foo": "bar"
        })

        self.assertEqual(sys_paths.windows, "C:\\temp")
        self.assertEqual(sys_paths.macosx, None)
        self.assertEqual(sys_paths.linux, None)

        if sys.platform == "win32":
            curr = ShotgunPath.from_current_os_path("\\\\server\\mount\\path")
            self.assertEqual(curr.windows, "\\\\server\\mount\\path")
            self.assertEqual(curr.macosx, None)
            self.assertEqual(curr.linux, None)
            self.assertEqual(curr.current_os, curr.windows)

        if sys.platform == "linux2":
            curr = ShotgunPath.from_current_os_path("/tmp/foo/bar")
            self.assertEqual(curr.windows, None)
            self.assertEqual(curr.macosx, None)
            self.assertEqual(curr.linux, "/tmp/foo/bar")
            self.assertEqual(curr.current_os, curr.linux)

        if sys.platform == "darwin":
            curr = ShotgunPath.from_current_os_path("/tmp/foo/bar")
            self.assertEqual(curr.windows, None)
            self.assertEqual(curr.macosx, "/tmp/foo/bar")
            self.assertEqual(curr.linux, None)
            self.assertEqual(curr.current_os, curr.macosx)

        std_constructor = ShotgunPath("C:\\temp", "/tmp", "/tmp2")
        self.assertEqual(std_constructor.windows, "C:\\temp")
        self.assertEqual(std_constructor.macosx, "/tmp2")
        self.assertEqual(std_constructor.linux, "/tmp")
コード例 #6
0
    def test_construction(self):
        """
        Tests get_cache_root
        """
        self.assertEqual(
            ShotgunPath.SHOTGUN_PATH_FIELDS,
            ["windows_path", "linux_path", "mac_path"]
        )

        sg = ShotgunPath.from_shotgun_dict(
            {"windows_path": "C:\\temp", "mac_path": "/tmp", "linux_path": "/tmp2", "foo": "bar"}
        )

        self.assertEqual(sg.windows, "C:\\temp")
        self.assertEqual(sg.macosx, "/tmp")
        self.assertEqual(sg.linux, "/tmp2")

        sg = ShotgunPath.from_shotgun_dict(
            {"windows_path": "C:\\temp", "mac_path": None, "foo": "bar"}
        )

        self.assertEqual(sg.windows, "C:\\temp")
        self.assertEqual(sg.macosx, None)
        self.assertEqual(sg.linux, None)

        sys_paths = ShotgunPath.from_system_dict(
            {"win32": "C:\\temp", "darwin": "/tmp", "linux2": "/tmp2", "foo": "bar"}
        )

        self.assertEqual(sys_paths.windows, "C:\\temp")
        self.assertEqual(sys_paths.macosx, "/tmp")
        self.assertEqual(sys_paths.linux, "/tmp2")

        sys_paths = ShotgunPath.from_system_dict(
            {"win32": "C:\\temp", "darwin": None, "foo": "bar"}
        )

        self.assertEqual(sys_paths.windows, "C:\\temp")
        self.assertEqual(sys_paths.macosx, None)
        self.assertEqual(sys_paths.linux, None)

        if sys.platform == "win32":
            curr = ShotgunPath.from_current_os_path("\\\\server\\mount\\path")
            self.assertEqual(curr.windows, "\\\\server\\mount\\path")
            self.assertEqual(curr.macosx, None)
            self.assertEqual(curr.linux, None)
            self.assertEqual(curr.current_os, curr.windows)

        if sys.platform == "linux2":
            curr = ShotgunPath.from_current_os_path("/tmp/foo/bar")
            self.assertEqual(curr.windows, None)
            self.assertEqual(curr.macosx, None)
            self.assertEqual(curr.linux, "/tmp/foo/bar")
            self.assertEqual(curr.current_os, curr.linux)

        if sys.platform == "darwin":
            curr = ShotgunPath.from_current_os_path("/tmp/foo/bar")
            self.assertEqual(curr.windows, None)
            self.assertEqual(curr.macosx, "/tmp/foo/bar")
            self.assertEqual(curr.linux, None)
            self.assertEqual(curr.current_os, curr.macosx)

        std_constructor = ShotgunPath("C:\\temp", "/tmp", "/tmp2")
        self.assertEqual(std_constructor.windows, "C:\\temp")
        self.assertEqual(std_constructor.macosx, "/tmp2")
        self.assertEqual(std_constructor.linux, "/tmp")