Exemple #1
0
    def testFsCrawlerGlob(self):
        """
        Test the glob functionality.
        """
        crawler = Crawler.create(PathHolder(self.__dir))
        crawlers = crawler.glob()
        result = self.collectFiles(self.__dir)
        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=[ExrRenderCrawler])
        crawlerPaths = list(map(lambda x: x.var("filePath"), crawlers))
        result = self.collectFiles(self.__dir, "RND*.exr")
        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 = self.collectFiles(self.__dir, "*.exr")
        result = list(map(lambda x: x.rstrip("/"), result))
        self.assertCountEqual(result, crawlerPaths)

        crawler = Crawler.create(PathHolder(self.__turntableFile))
        otherCrawlers = crawler.globFromParent(filterTypes=[ExrRenderCrawler])
        crawlerPaths = list(map(lambda x: x.var("filePath"), crawlers))
        otherCrawlerPaths = list(
            map(lambda x: x.var("filePath"), otherCrawlers))
        self.assertCountEqual(crawlerPaths, otherCrawlerPaths)
 def testMayaSceneCrawler(self):
     """
     Test that the Maya Scene crawler test works properly.
     """
     crawler = Crawler.create(PathHolder(self.__maFile))
     self.assertIsInstance(crawler, MayaSceneCrawler)
     crawler = Crawler.create(PathHolder(self.__mbFile))
     self.assertIsInstance(crawler, MayaSceneCrawler)
Exemple #3
0
 def testExrCrawler(self):
     """
     Test that the Exr crawler test works properly.
     """
     crawler = Crawler.create(PathHolder(self.__exrFile))
     self.assertIsInstance(crawler, ExrCrawler)
     crawler = Crawler.create(PathHolder(BaseTestCase.dataTestsDirectory()))
     self.assertNotIsInstance(crawler, ExrCrawler)
Exemple #4
0
 def testTextureCrawler(self):
     """
     Test that the Texture crawler test works properly.
     """
     crawler = Crawler.create(PathHolder(self.__exrFile))
     self.assertIsInstance(crawler, TextureCrawler)
     crawler = Crawler.create(PathHolder(self.__tifFile))
     self.assertIsInstance(crawler, TextureCrawler)
     crawler = Crawler.create(PathHolder(self.__badExrFile))
     self.assertNotIsInstance(crawler, TextureCrawler)
Exemple #5
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())
Exemple #6
0
    def testIsSequence(self):
        """
        Test if a crawler is a sequence.
        """
        singleCrawler = Crawler.create(PathHolder(self.__singleFile))
        sequenceCrawler = Crawler.create(PathHolder(self.__sequenceFile))

        self.assertEqual(singleCrawler.isSequence(), False)
        self.assertEqual(singleCrawler.var("imageType"), "single")
        self.assertEqual(sequenceCrawler.isSequence(), True)
        self.assertEqual(sequenceCrawler.var("imageType"), "sequence")
Exemple #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)
Exemple #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.assertEqual(crawler.var("firstFrame"), 0)
        self.assertEqual(crawler.var("lastFrame"), 23)
Exemple #9
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)
Exemple #10
0
 def testGroupSprintfTagSequence(self):
     """
     Test that the tag groupSprintf has been assigned to the image sequence crawler.
     """
     crawler = Crawler.create(PathHolder(self.__sequenceFile))
     self.assertIn('groupSprintf', crawler.tagNames())
     self.assertEqual(crawler.tag('groupSprintf'), "testSeq.%04d.exr")
Exemple #11
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")
 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")
Exemple #13
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)
Exemple #14
0
 def testBadFile(self):
     """
     Test to show that file names with illegal characters are skipped.
     """
     crawler = Crawler.create(PathHolder(self.dataTestsDirectory()))
     crawlerPaths = map(lambda x: x.var("filePath"), crawler.children())
     self.assertNotIn(os.path.join(self.__dir, "bad file.txt"), crawlerPaths)
Exemple #15
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")
Exemple #16
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")
Exemple #17
0
    def testFsCrawler(self):
        """
        Test that the fs crawler test works.
        """
        pathHolder = PathHolder(self.__dir)
        self.assertTrue(FsCrawler.test(pathHolder, None))

        notAPathHolder = {}
        self.assertFalse(FsCrawler.test(notAPathHolder, None))
Exemple #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"), 1920)
     self.assertEqual(crawler.var("height"), 1080)
Exemple #19
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)
Exemple #20
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())
Exemple #21
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)
Exemple #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"), 1920)
     self.assertEqual(crawler.var("height"), 1080)
Exemple #23
0
 def testCdlVariables(self):
     """
     Test that variables are set properly.
     """
     crawler = FsCrawler.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)
Exemple #24
0
 def testCcVariables(self):
     """
     Test that variables are set properly.
     """
     crawler = FsCrawler.create(PathHolder(self.__ccFile))
     self.assertEqual(crawler.var("type"), "cc")
     self.assertEqual(crawler.var("category"), "lut")
     self.assertEqual(crawler.var("slope"), [1.2, 1.3, 1.4])
     self.assertEqual(crawler.var("offset"), [0.2, 0.3, 0.4])
     self.assertEqual(crawler.var("power"), [1.5, 1.6, 1.7])
     self.assertEqual(crawler.var("saturation"), 1.0)
Exemple #25
0
 def testImageSequenceGroup(self):
     """
     Test that an image sequence is grouped properly.
     """
     paths = glob.glob("{}/testSeq.*.exr".format(self.dataTestsDirectory()))
     crawlers = list(map(lambda x: Crawler.create(PathHolder(x)), paths))
     crawlers.append(Crawler.create(PathHolder(self.__exrFile)))
     grouped = ExrCrawler.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 = ExrCrawler.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))
Exemple #26
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())
Exemple #27
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)
 def testTurntableCrawlerVariables(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")
Exemple #29
0
 def testShotRenderCrawlerVariables(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")
Exemple #30
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(CrawlerInvalidVarError, crawler.var, "dummyVar")