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 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.º 5
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.º 6
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.º 7
0
    def testCrawlerRegistration(self):
        """
        Test that you can register a new crawler.
        """
        class DummyCrawler(File):
            @classmethod
            def test(cls, pathHolder, parentCrawler):
                return False

        Crawler.register("dummy", DummyCrawler)
        self.assertIn("dummy", Crawler.registeredNames())
        self.assertIn(DummyCrawler, Crawler.registeredSubclasses("generic"))
        self.assertIn(DummyCrawler, Crawler.registeredSubclasses(FsPath))
Ejemplo n.º 8
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.º 9
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.º 10
0
 def testCreation(self):
     """
     Test hashmap creation.
     """
     hashmap = Crawler.create({})
     assert (isinstance(hashmap, Hashmap))
     self.assertEqual(len(hashmap), 0)
Ejemplo n.º 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")
Ejemplo n.º 12
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.º 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)
Ejemplo n.º 14
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.º 15
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.º 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")
Ejemplo n.º 17
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.º 18
0
 def testItemsData(self):
     """
     Test items, keys and values for the data.
     """
     hashmap = Crawler.create({"a": 1})
     self.assertEqual(list(hashmap.items()), [("a", 1)])
     self.assertEqual(list(hashmap.keys()), ["a"])
     self.assertEqual(list(hashmap.values()), [1])
Ejemplo n.º 19
0
    def testClearData(self):
        """
        Test clear the data in the hashmap.
        """
        hashmap = Crawler.create({"a": 1, "b": 2})
        hashmap.clear()

        self.assertEqual(len(hashmap), 0)
Ejemplo n.º 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())
Ejemplo n.º 21
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.º 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 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.º 24
0
    def testInsertData(self):
        """
        Test insert data in the hashmap.
        """
        hashmap = Crawler.create({})
        hashmap["a"] = 1

        self.assertEqual(len(hashmap), 1)
        self.assertIn('a', hashmap)
        self.assertEqual(hashmap['a'], 1)
Ejemplo n.º 25
0
    def testData(self):
        """
        Test data passed to the constructor.
        """
        data = {'a': 1, 'b': 2}

        hashmap = Crawler.create(data)
        self.assertEqual(len(hashmap), 2)
        self.assertEqual(hashmap['a'], 1)
        self.assertEqual(hashmap['b'], 2)
Ejemplo n.º 26
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.º 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)
Ejemplo n.º 28
0
    def testRemoveData(self):
        """
        Test removing data in the hashmap.
        """
        data = {"a": 1}

        hashmap = Crawler.create(data)
        self.assertIn('a', hashmap)

        del hashmap['a']
        self.assertEqual(len(hashmap), 0)
Ejemplo n.º 29
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.º 30
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")