Ejemplo n.º 1
0
    def testFsPathGlob(self):
        """
        Test the glob functionality.
        """
        crawler = Crawler.create(PathHolder(self.__dir))
        crawlers = crawler.glob()
        result = glob.glob("{}/**".format(self.__dir), recursive=True)
        result = list(map(lambda x: x.rstrip("/"), result))
        crawlerPaths = list(map(lambda x: x.var("filePath"), crawlers))
        self.assertCountEqual(result, crawlerPaths)

        crawlers = crawler.glob(filterTypes=["turntable", "shotRender"])
        crawlerPaths = list(map(lambda x: x.var("filePath"), crawlers))
        self.assertCountEqual(crawlerPaths, [self.__turntableFile, self.__shotRenderFile])

        crawlers = crawler.glob(filterTypes=[ExrRender])
        crawlerPaths = list(map(lambda x: x.var("filePath"), crawlers))
        result = glob.glob("{}/**/RND**.exr".format(self.__dir), recursive=True)
        result = list(map(lambda x: x.rstrip("/"), result))
        self.assertCountEqual(result, crawlerPaths)

        crawlers = crawler.glob(filterTypes=['exr'])
        crawlerPaths = list(map(lambda x: x.var("filePath"), crawlers))
        result = glob.glob("{}/**/**.exr".format(self.__dir), recursive=True)
        result = list(map(lambda x: x.rstrip("/"), result))
        self.assertCountEqual(result, crawlerPaths)

        crawler = Crawler.create(PathHolder(self.__turntableFile))
        otherCrawlers = crawler.globFromParent(filterTypes=[ExrRender])
        crawlerPaths = list(map(lambda x: x.var("filePath"), crawlers))
        otherCrawlerPaths = list(map(lambda x: x.var("filePath"), otherCrawlers))
        self.assertCountEqual(crawlerPaths, otherCrawlerPaths)
Ejemplo n.º 2
0
 def testExrCrawler(self):
     """
     Test that the Exr crawler test works properly.
     """
     crawler = Crawler.create(PathHolder(self.__exrFile))
     self.assertIsInstance(crawler, Exr)
     crawler = Crawler.create(PathHolder(BaseTestCase.dataDirectory()))
     self.assertNotIsInstance(crawler, Exr)
Ejemplo n.º 3
0
 def testMayaSceneCrawler(self):
     """
     Test that the Maya Scene crawler test works properly.
     """
     crawler = Crawler.create(PathHolder(self.__maFile))
     self.assertIsInstance(crawler, MayaScene)
     crawler = Crawler.create(PathHolder(self.__mbFile))
     self.assertIsInstance(crawler, MayaScene)
Ejemplo n.º 4
0
 def testTextureCrawler(self):
     """
     Test that the Texture crawler test works properly.
     """
     crawler = Crawler.create(PathHolder(self.__exrFile))
     self.assertIsInstance(crawler, Texture)
     crawler = Crawler.create(PathHolder(self.__tifFile))
     self.assertIsInstance(crawler, Texture)
     crawler = Crawler.create(PathHolder(self.__badExrFile))
     self.assertNotIsInstance(crawler, Texture)
Ejemplo n.º 5
0
 def testPathHolder(self):
     """
     Test PathHolder functions.
     """
     pathHolder = PathHolder(self.__turntableFile)
     self.assertEqual(pathHolder.size(), 5430903)
     self.assertEqual(pathHolder.name(), "RND_ass_lookdev_default_beauty_tt.1001")
     self.assertTrue(pathHolder.exists())
     pathHolder = PathHolder("/")
     self.assertEqual(pathHolder.baseName(), os.sep)
Ejemplo n.º 6
0
 def testImageSequence(self):
     """
     Test that detection of an image sequence works properly.
     """
     crawler = Crawler.create(PathHolder(self.__exrFile))
     self.assertFalse(crawler.isSequence())
     crawler = Crawler.create(PathHolder(self.__exrSeq))
     self.assertTrue(crawler.isSequence())
     crawler = Crawler.create(PathHolder(self.__exrAmbiguousSeq))
     self.assertTrue(crawler.isSequence())
Ejemplo n.º 7
0
 def testImageSequenceVariables(self):
     """
     Test that the image sequence related variables are set properly.
     """
     crawler = Crawler.create(PathHolder(self.__exrSeq))
     self.assertEqual(crawler.var("imageType"), "sequence")
     self.assertEqual(crawler.var("name"), "testSeq")
     self.assertEqual(crawler.var("frame"), 1)
     self.assertEqual(crawler.var("padding"), 4)
     crawler = Crawler.create(PathHolder(self.__exrAmbiguousSeq))
     self.assertEqual(crawler.var("imageType"), "sequence")
     self.assertEqual(crawler.var("name"), "test")
     self.assertEqual(crawler.var("frame"), 1)
     self.assertEqual(crawler.var("padding"), 4)
Ejemplo n.º 8
0
    def testMovVariables(self):
        """
        Test that variables are set properly.
        """
        crawler = Crawler.create(PathHolder(self.__movFile))
        self.assertEqual(crawler.var("type"), "mov")
        self.assertEqual(crawler.var("category"), "video")
        self.assertEqual(crawler.var("width"), 1920)
        self.assertEqual(crawler.var("height"), 1080)
        self.assertEqual(crawler.var("firstFrame"), 1)
        self.assertEqual(crawler.var("lastFrame"), 12)

        crawler = Crawler.create(PathHolder(self.__movNoTimecodeFile))
        self.assertFalse("firstFrame" in crawler.varNames())
        self.assertFalse("lastFrame" in crawler.varNames())
Ejemplo n.º 9
0
 def testJsonVariables(self):
     """
     Test that variables are set properly.
     """
     crawler = Crawler.create(PathHolder(self.__jsonFile))
     self.assertEqual(crawler.var("type"), "json")
     self.assertEqual(crawler.var("category"), "ascii")
Ejemplo n.º 10
0
 def testMayaSceneVariables(self):
     """
     Test that variables are set properly.
     """
     crawler = Crawler.create(PathHolder(self.__maFile))
     self.assertEqual(crawler.var("type"), "mayaScene")
     self.assertEqual(crawler.var("category"), "scene")
Ejemplo n.º 11
0
 def testDirectoryVariables(self):
     """
     Test that the variables are set properly.
     """
     crawler = Crawler.create(PathHolder(self.__dir))
     self.assertEqual(crawler.var("width"), 640)
     self.assertEqual(crawler.var("height"), 480)
Ejemplo n.º 12
0
 def testTxtContents(self):
     """
     Test that txt files are parsed properly.
     """
     crawler = Crawler.create(PathHolder(self.__txtFile))
     testData = "testing txt file\nwith random data\n\n1 2 3\n"
     self.assertEqual(crawler.contents(), testData)
Ejemplo n.º 13
0
 def testBadFile(self):
     """
     Test to show that file names with illegal characters are skipped.
     """
     crawler = Crawler.create(PathHolder(self.dataDirectory()))
     crawlerPaths = map(lambda x: x.var("filePath"), crawler.children())
     self.assertNotIn(os.path.join(self.__dir, "bad file.txt"),
                      crawlerPaths)
Ejemplo n.º 14
0
 def testPngVariables(self):
     """
     Test that variables are set properly.
     """
     crawler = Crawler.create(PathHolder(self.__pngFile))
     self.assertEqual(crawler.var("type"), "png")
     self.assertEqual(crawler.var("category"), "image")
     self.assertEqual(crawler.var("imageType"), "single")
Ejemplo n.º 15
0
    def testTextureVariables(self):
        """
        Test that variables are set properly.
        """
        crawler = Crawler.create(PathHolder(self.__exrFile))
        self.assertEqual(crawler.var("type"), "texture")
        self.assertEqual(crawler.var("category"), "texture")
        self.assertEqual(crawler.var("assetName"), "test")
        self.assertEqual(crawler.var("mapType"), "DIFF")
        self.assertEqual(crawler.var("udim"), 1001)
        self.assertEqual(crawler.var("variant"), "default")

        crawler = Crawler.create(PathHolder(self.__tifFile))
        self.assertEqual(crawler.var("assetName"), "test")
        self.assertEqual(crawler.var("mapType"), "BUMP")
        self.assertEqual(crawler.var("udim"), 1002)
        self.assertEqual(crawler.var("variant"), "default")
Ejemplo n.º 16
0
 def testCrawlerClone(self):
     """
     Test that cloning crawlers works.
     """
     crawler = Crawler.create(PathHolder(self.__turntableFile))
     clone = crawler.clone()
     self.assertCountEqual(crawler.varNames(), clone.varNames())
     self.assertCountEqual(crawler.contextVarNames(), clone.contextVarNames())
     self.assertCountEqual(crawler.tagNames(), clone.tagNames())
Ejemplo n.º 17
0
    def testFsCrawler(self):
        """
        Test that the fs crawler test works.
        """
        pathHolder = PathHolder(self.__dir)
        self.assertTrue(FsPath.test(pathHolder, None))

        notAPathHolder = {}
        self.assertFalse(FsPath.test(notAPathHolder, None))
Ejemplo n.º 18
0
 def testExrWidthHeight(self):
     """
     Test that width and height variables are processed properly.
     """
     crawler = Crawler.create(PathHolder(self.__exrFile))
     self.assertNotIn("width", crawler.varNames())
     self.assertNotIn("height", crawler.varNames())
     self.assertEqual(crawler.var("width"), 1828)
     self.assertEqual(crawler.var("height"), 1556)
Ejemplo n.º 19
0
 def testJpgVariables(self):
     """
     Test that variables are set properly.
     """
     crawler = Crawler.create(PathHolder(self.__jpgFile))
     self.assertEqual(crawler.var("type"), "jpg")
     self.assertEqual(crawler.var("category"), "image")
     self.assertEqual(crawler.var("imageType"), "single")
     self.assertEqual(crawler.var("width"), 512)
     self.assertEqual(crawler.var("height"), 512)
Ejemplo n.º 20
0
 def testCrawlerJson(self):
     """
     Test that you can convert a crawler to json and back.
     """
     crawler = Crawler.create(PathHolder(self.__turntableFile))
     jsonResult = crawler.toJson()
     crawlerResult = Crawler.createFromJson(jsonResult)
     self.assertCountEqual(crawler.varNames(), crawlerResult.varNames())
     self.assertCountEqual(crawler.contextVarNames(), crawlerResult.contextVarNames())
     self.assertCountEqual(crawler.tagNames(), crawlerResult.tagNames())
Ejemplo n.º 21
0
 def testImageSequenceGroup(self):
     """
     Test that an image sequence is grouped properly.
     """
     paths = glob.glob("{}/testSeq.*.exr".format(self.dataDirectory()))
     crawlers = list(map(lambda x: Crawler.create(PathHolder(x)), paths))
     crawlers.append(Crawler.create(PathHolder(self.__exrFile)))
     grouped = Exr.group(crawlers)
     self.assertEqual(len(grouped), 2)
     self.assertEqual(len(grouped[0]), len(paths))
     self.assertEqual(len(grouped[1]), 1)
     groupedPaths = list(map(lambda x: x.var("filePath"), grouped[0]))
     self.assertEqual(groupedPaths, sorted(paths))
     self.assertEqual(grouped[1][0].var("filePath"), self.__exrFile)
     reversedGrouped = Exr.sortGroup(grouped, lambda x: x.var('filePath'),
                                     True)
     reversedPaths = list(
         map(lambda x: x.var("filePath"), reversedGrouped[0]))
     self.assertEqual(reversedPaths, sorted(paths, reverse=True))
Ejemplo n.º 22
0
 def testDpxVariables(self):
     """
     Test that variables are set properly.
     """
     crawler = Crawler.create(PathHolder(self.__dpxFile))
     self.assertEqual(crawler.var("type"), "dpx")
     self.assertEqual(crawler.var("category"), "image")
     self.assertEqual(crawler.var("imageType"), "single")
     self.assertEqual(crawler.var("width"), 2048)
     self.assertEqual(crawler.var("height"), 1080)
Ejemplo n.º 23
0
 def testCdlVariables(self):
     """
     Test that variables are set properly.
     """
     crawler = FsPath.create(PathHolder(self.__cdlFile))
     self.assertEqual(crawler.var("type"), "cdl")
     self.assertEqual(crawler.var("category"), "lut")
     self.assertEqual(crawler.var("slope"), [1.014, 1.0104, 0.62])
     self.assertEqual(crawler.var("offset"), [-0.00315, -0.00124, 0.3103])
     self.assertEqual(crawler.var("power"), [1.0, 0.9983, 1.0])
     self.assertEqual(crawler.var("saturation"), 1.09)
Ejemplo n.º 24
0
 def testCccVariables(self):
     """
     Test that variables are set properly.
     """
     crawler = FsPath.create(PathHolder(self.__cccFile))
     self.assertEqual(crawler.var("type"), "cc")
     self.assertEqual(crawler.var("category"), "lut")
     self.assertEqual(crawler.var("slope"), [1.1, 1.2, 1.3])
     self.assertEqual(crawler.var("offset"), [0.1, 0.2, 0.3])
     self.assertEqual(crawler.var("power"), [1.4, 1.5, 1.6])
     self.assertEqual(crawler.var("saturation"), 1.0)
Ejemplo n.º 25
0
 def testJsonContents(self):
     """
     Test that json files are parsed properly.
     """
     crawler = Crawler.create(PathHolder(self.__jsonFile))
     testData = {
         "testList": [1, 1.2, "value"],
         "testDict": {"key": "value", "number": 1},
         "testString": "blah"
     }
     self.assertEqual(crawler.contents(), testData)
Ejemplo n.º 26
0
 def testPathVariables(self):
     """
     Test that the crawler variables are set properly.
     """
     crawler = Crawler.create(PathHolder(self.__turntableFile))
     name, ext = os.path.splitext(self.__turntableFile)
     self.assertEqual(crawler.var('filePath'), self.__turntableFile)
     self.assertEqual(crawler.var('ext'), ext.lstrip("."))
     self.assertEqual(crawler.var('baseName'), os.path.basename(self.__turntableFile))
     self.assertEqual(crawler.var('name'), os.path.basename(name).split(".")[0])
     self.assertEqual(crawler.var('sourceDirectory'), os.path.dirname(name))
     self.assertRaises(InvalidVarError, crawler.var, "dummyVar")
Ejemplo n.º 27
0
 def testTurntableVariables(self):
     """
     Test that variables are set properly.
     """
     crawler = Crawler.create(PathHolder(self.__exrFile))
     self.assertEqual(crawler.var("type"), "turntable")
     self.assertEqual(crawler.var("category"), "render")
     self.assertEqual(crawler.var("renderType"), "tt")
     self.assertEqual(crawler.var("assetName"), "ass")
     self.assertEqual(crawler.var("step"), "lookdev")
     self.assertEqual(crawler.var("pass"), "beauty")
     self.assertEqual(crawler.var("renderName"), "ass-default-beauty")
Ejemplo n.º 28
0
 def testShotRenderVariables(self):
     """
     Test that variables are set properly.
     """
     crawler = Crawler.create(PathHolder(self.__exrFile))
     self.assertEqual(crawler.var("type"), "shotRender")
     self.assertEqual(crawler.var("category"), "render")
     self.assertEqual(crawler.var("renderType"), "sr")
     self.assertEqual(crawler.var("seq"), "TST")
     self.assertEqual(crawler.var("shot"), "RND-TST-SHT")
     self.assertEqual(crawler.var("step"), "lighting")
     self.assertEqual(crawler.var("pass"), "beauty")
     self.assertEqual(crawler.var("renderName"), "lighting-beauty")
Ejemplo n.º 29
0
 def testNukeRenderVariables(self):
     """
     Test that variables are set properly.
     """
     crawler = Crawler.create(PathHolder(self.__exrFile))
     self.assertEqual(crawler.var("type"), "nukeRender")
     self.assertEqual(crawler.var("category"), "render")
     self.assertEqual(crawler.var("renderType"), "tk")
     self.assertEqual(crawler.var("seq"), "TST")
     self.assertEqual(crawler.var("shot"), "RND-TST-SHT")
     self.assertEqual(crawler.var("step"), "comp")
     self.assertEqual(crawler.var("renderName"), "compName")
     self.assertEqual(crawler.var("output"), "output")
     self.assertEqual(crawler.var("versionName"), "v010")
     self.assertEqual(crawler.var("version"), 10)
Ejemplo n.º 30
0
 def testIsLeaf(self):
     """
     Test to show directory crawler is not a leaf.
     """
     crawler = Crawler.create(PathHolder(self.__dir))
     self.assertFalse(crawler.isLeaf())