def test_TexProcessor_getTexNodes(self): tp = TexProcessor.TexProcessor() tp.texNodes.append(tex_node.TexNode('node', 'attr')) result = tp.getTexNodes() self.assertIsInstance(result, list) self.assertEqual(len(result), 1) self.assertIsInstance(result[0], tex_node.TexNode)
def test_TexNode_getAttrValue(self): setupScene() nodesAttrsValues = [ ('fileNodeWithProjPath', 'ftn', getFxptLocation() + '/fxpt/fx_texture_manager/tests/testMayaProject/sourceimages/testTex_exit.png' ), ('fileNodeWithAbsPath', 'ftn', getFxptLocation() + '/fxpt/fx_texture_manager/icons/filter_active.png'), ('fileNodeWithEnvVar', 'ftn', '%FXPT_LOCATION%/fxpt/fx_texture_manager/icons/copy.png'), ('fileNodeWithInvalidEnvVar', 'ftn', '%INVALID_ENV_VAR%/fxpt/fx_texture_manager/icons/copy.png'), ('fileNodeWithNetworkPath', 'ftn', '//BLACK/C$/GitHub/fxpt/fxpt/fx_texture_manager/icons/retarget.png' ), ('fileNodeWithInvalidPath', 'ftn', 'some/path/tex.png'), ('someNodeWithTextures1', 'texture', '%FXPT_LOCATION%/fxpt/fx_texture_manager/icons/copy.png'), ('someNodeWithTextures1', 'texture1', 'sourceimages/testTex_exit.png'), ('someNodeWithTextures1', 'texture2', '//BLACK/C$/GitHub/fxpt/fxpt/fx_texture_manager/icons/retarget.png' ), ('someNodeWithTextures2', 'texture', '%FXPT_LOCATION%/fxpt/fx_texture_manager/icons/copy.png'), ('someNodeWithTextures2', 'texture1', 'sourceimages/testTex_exit.png'), ('someNodeWithTextures2', 'texture2', '') ] for node, attr, value in nodesAttrsValues: tn = tex_node.TexNode(node, attr) self.assertEqual(tn.getAttrValue(), value)
def getTexNodes(self): texNodes = [] for nodeType in TEX_ATTRIBUTES: for node in m.ls(l=True, typ=nodeType): for attr in TEX_ATTRIBUTES[nodeType]: if m.objExists('{}.{}'.format(node, attr)): texNodes.append(tex_node.TexNode(node, attr)) return texNodes
def findTextureNodes(self, node): self.visited.add(node) res = [] nodeType = m.nodeType(node) if nodeType in TEX_ATTRIBUTES: for attr in TEX_ATTRIBUTES[nodeType]: if m.objExists('{}.{}'.format(node, attr)): res.append(tex_node.TexNode(node, attr)) inConnections = list( set(m.listConnections(node, d=False, s=True) or [])) for srcNode in inConnections: if (m.nodeType(srcNode) not in self.skipInRecursion) and (srcNode not in self.visited): res.extend(self.findTextureNodes(srcNode)) return res
def test_TexNode_fileExists(self): setupScene() nodesAttrsValues = [('fileNodeWithProjPath', 'ftn', True), ('fileNodeWithAbsPath', 'ftn', True), ('fileNodeWithEnvVar', 'ftn', True), ('fileNodeWithInvalidEnvVar', 'ftn', False), ('fileNodeWithNetworkPath', 'ftn', True), ('fileNodeWithInvalidPath', 'ftn', False), ('someNodeWithTextures1', 'texture', True), ('someNodeWithTextures1', 'texture1', False), ('someNodeWithTextures1', 'texture2', True), ('someNodeWithTextures2', 'texture', True), ('someNodeWithTextures2', 'texture1', False), ('someNodeWithTextures2', 'texture2', False)] for node, attr, value in nodesAttrsValues: tn = tex_node.TexNode(node, attr) self.assertEqual(tn.fileExists(), value)
def test_TexNode_getFullAttrName(self): tn = tex_node.TexNode('someNode', 'someAttr') self.assertEqual(tn.getFullAttrName(), '{}.{}'.format('someNode', 'someAttr'))
def test_TexNode_node_and_attr_setters_getters(self): tn = tex_node.TexNode('testNode', 'testAttr') self.assertEqual(tn.node, 'testNode') self.assertEqual(tn.attr, 'testAttr') self.assertEqual(tn.getNode(), 'testNode') self.assertEqual(tn.getAttr(), 'testAttr')
def test_TexNode_can_be_created(self): tex_node.TexNode('testNode', 'testAttr')