def test_read(self): p = guerilla_parser.parse(default_gprojects[1]) self.assertIsInstance(p, guerilla_parser.GuerillaParser) self.assertEqual(p.doc_format_rev, 19) doc = p.root self.assertEqual(doc.id, 1) self.assertEqual(doc.name, 'LUIDocument') self.assertEqual(doc.type, 'GADocument') self.assertEqual(doc.get_plug('InternalDirectLighting').value, True) self.assertEqual(doc.get_plug('InvertT').value, False) self.assertEqual(doc.get_plug('LastFrame').value, 50) self.assertEqual(doc.get_plug('Membership').value, "All") self.assertEqual(doc.get_plug('CurveWidthShape').value, 1.5) pref = doc.get_child('Preferences') self.assertEqual(pref.id, 2) self.assertEqual(pref.name, 'Preferences') self.assertEqual(pref.type, 'Preferences') self.assertEqual(pref.get_plug('LightAmbient').value, [0, 0, 0, 1]) self.assertEqual(pref.get_plug('LightSpecular').value, [0.5, 0.5, 0.5, 1]) self.assertEqual(pref.get_plug('SearchPathTexture').value, "") for node in p.nodes: for child in node.children: self.assertIs(node.get_child(child.name), child) for plug in node.plugs: self.assertIs(node.get_plug(plug.name), plug)
def test_func(self): p = guerilla_parser.parse(path) node = p.path_to_node("|Preferences|RenderViewport") plug = node.get_plug("ColorMode") self.assertEqual(plug.value, 'multiply') p.set_plug_value([(plug, 'divide')]) self.assertEqual(plug.value, 'divide')
def test_func(self): _, tmp_file = tempfile.mkstemp() os.close(_) p = guerilla_parser.parse( path, diagnose=False) p.write(tmp_file) # no change self.assertFalse(p.has_changed) self.assertTrue(filecmp.cmp(path, tmp_file)) node = p.path_to_node("|Preferences|RenderViewport") # get value plug = node.get_plug("ColorMode") self.assertEqual(plug.value, 'multiply') # set value p.set_plug_value([(plug, 'divide')]) self.assertEqual(plug.value, 'divide') p.write(tmp_file) # has changed self.assertTrue(p.has_changed) self.assertFalse(filecmp.cmp(path, tmp_file)) # get diff old = [] new = [] for c in difflib.ndiff(p.original_content, p.modified_content): if c.startswith("- "): old.append(c[2:]) continue if c.startswith("+ "): new.append(c[2:]) continue old = "".join(old) new = "".join(new) # no typo here! "i" is just considered has haven't been moved self.assertEqual(old, 'multply') self.assertEqual(new, 'dvide') os.remove(tmp_file)
def test_types_multistrings(self): path = gproj_dir + '/2.3.0b16/texture_switch.gproject' p = guerilla_parser.parse(path) node = p.objs[53] plug = node.get_plug('Files') self.assertEqual(plug.name, 'Files') self.assertEqual(plug.flag, 4) self.assertEqual(plug.type, 'AttributeShaderPlug') self.assertEqual(plug.value, [ '$(SAMPLES)/sprite.1.png', '$(SAMPLES)/sprite.2.png', '$(SAMPLES)/sprite.3.png', '$(SAMPLES)/sprite.4.png' ])
def test_read(self): p = guerilla_parser.parse(gprojects[6]) self.assertIsInstance(p, guerilla_parser.GuerillaParser) self.assertEqual(p.doc_format_rev, 19) doc = p.root self.assertEqual(doc.id, 1) self.assertEqual(doc.name, 'LUIDocument') self.assertEqual(doc.type, 'GADocument') foo_node = doc.get_child('foo') self.assertEqual(foo_node.type, 'ArchReference') self.assertEqual(foo_node.get_plug('ReferenceFileName').value, '/path/to/file.abc')
def test_func(self): p = guerilla_parser.parse(path) g_parsed[path] = p