/[escript]/trunk/finley/test/python/run_visualization_interface.py
ViewVC logotype

Diff of /trunk/finley/test/python/run_visualization_interface.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2420 by gross, Wed May 13 06:03:59 2009 UTC revision 2421 by gross, Thu May 14 02:29:06 2009 UTC
# Line 23  import sys, math, re Line 23  import sys, math, re
23  import unittest  import unittest
24  from esys.escript import *  from esys.escript import *
25  from esys.finley import ReadMesh  from esys.finley import ReadMesh
26    from xml.dom import minidom
27    
28  try:  try:
29       FINLEY_TEST_DATA=os.environ['FINLEY_TEST_DATA']       FINLEY_TEST_DATA=os.environ['FINLEY_TEST_DATA']
# Line 239  class Test_VisualizationInterface(unitte Line 240  class Test_VisualizationInterface(unitte
240             c+=1             c+=1
241    
242  class Test_VTKFiles(Test_VisualizationInterface):  class Test_VTKFiles(Test_VisualizationInterface):
243      def test_metadata_0(self):
244         fn=os.path.join(FINLEY_WORKDIR_PATH,"metadata0.xml")
245         dom=ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"hex_2D_order2.msh"),optimize=False)
246         saveVTK(fn,x=dom.getX(), metadata_schema={"gml":"http://www.opengis.net/gml"}, metadata='<dummy>hello world</dummy><timeStamp uom="s">1234</timeStamp>')
247         # testing:
248         dummy=None
249         timeStamp=None
250         unstructured=None
251         dom=minidom.parseString(open("metadata0.xml",'r').read())
252         for node in dom.childNodes:
253            if isinstance(node, minidom.Element):
254               if node.tagName == 'VTKFile':
255                  type = node.getAttribute("type")
256                  version = node.getAttribute("version")
257                  ns = node.getAttribute("xmlns:gml")
258                  self.failUnless(type == "UnstructuredGrid","Type wrong")
259                  self.failUnless(version == "0.1", "wrong version")
260                  self.failUnless(ns == "http://www.opengis.net/gml", "wrong name space")
261                  for vtk_node in node.childNodes:
262                     if isinstance(vtk_node, minidom.Element):
263                        if vtk_node.tagName == 'MetaData':
264                           for meta_node in vtk_node.childNodes:
265                               if isinstance(meta_node, minidom.Element):
266                                   if meta_node.tagName == 'dummy':
267                                      for txt_node in meta_node.childNodes:
268                                         if isinstance(txt_node, minidom.Text):
269                                             dummy=txt_node.nodeValue.strip()
270                                             self.failUnless( dummy == "hello world","dummy is wrong")
271                                   if meta_node.tagName == 'timeStamp':
272                                      uom=meta_node.getAttribute("uom")
273                                      self.failUnless( uom == "s","uom is wrong")
274                                      for txt_node in meta_node.childNodes:
275                                         if isinstance(txt_node, minidom.Text):
276                                             timeStamp=txt_node.nodeValue.strip()
277                                             self.failUnless( timeStamp == "1234","dummy is wrong")
278                        if vtk_node.tagName == 'UnstructuredGrid': unstructured=True
279         self.failUnless( dummy !=None, "dummy is missing.")
280         self.failUnless( timeStamp !=None, "timeStamp is missing.")
281         self.failUnless( unstructured !=None, "dummy is missing.")
282      def test_metadata_1(self):
283         fn=os.path.join(FINLEY_WORKDIR_PATH,"metadata1.xml")
284         dom=ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"hex_2D_order2.msh"),optimize=False)
285         saveVTK(fn,x=dom.getX(), metadata='<dummy>hello world</dummy><timeStamp uom="s">1234</timeStamp>')
286         # testing:
287         dummy=None
288         timeStamp=None
289         unstructured=None
290         dom=minidom.parseString(open("metadata1.xml",'r').read())
291         for node in dom.childNodes:
292            if isinstance(node, minidom.Element):
293               if node.tagName == 'VTKFile':
294                  type = node.getAttribute("type")
295                  version = node.getAttribute("version")
296                  self.failUnless(type == "UnstructuredGrid","Type wrong")
297                  self.failUnless(version == "0.1", "wrong version")
298                  for vtk_node in node.childNodes:
299                     if isinstance(vtk_node, minidom.Element):
300                        if vtk_node.tagName == 'MetaData':
301                           for meta_node in vtk_node.childNodes:
302                               if isinstance(meta_node, minidom.Element):
303                                   if meta_node.tagName == 'dummy':
304                                      for txt_node in meta_node.childNodes:
305                                         if isinstance(txt_node, minidom.Text):
306                                             dummy=txt_node.nodeValue.strip()
307                                             self.failUnless( dummy == "hello world","dummy is wrong")
308                                   if meta_node.tagName == 'timeStamp':
309                                      uom=meta_node.getAttribute("uom")
310                                      self.failUnless( uom == "s","uom is wrong")
311                                      for txt_node in meta_node.childNodes:
312                                         if isinstance(txt_node, minidom.Text):
313                                             timeStamp=txt_node.nodeValue.strip()
314                                             self.failUnless( timeStamp == "1234","dummy is wrong")
315                        if vtk_node.tagName == 'UnstructuredGrid': unstructured=True
316         self.failUnless( dummy !=None, "dummy is missing.")
317         self.failUnless( timeStamp !=None, "timeStamp is missing.")
318         self.failUnless( unstructured !=None, "dummy is missing.")
319      def test_metadata_2(self):
320         fn=os.path.join(FINLEY_WORKDIR_PATH,"metadata2.xml")
321         dom=ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"hex_2D_order2.msh"),optimize=False)
322         saveVTK(fn,x=dom.getX(), metadata_schema={"gml":"http://www.opengis.net/gml"})
323         # testing:
324         unstructured=None
325         dom=minidom.parseString(open("metadata2.xml",'r').read())
326         for node in dom.childNodes:
327            if isinstance(node, minidom.Element):
328               if node.tagName == 'VTKFile':
329                  type = node.getAttribute("type")
330                  version = node.getAttribute("version")
331                  ns = node.getAttribute("xmlns:gml")
332                  self.failUnless(type == "UnstructuredGrid","Type wrong")
333                  self.failUnless(version == "0.1", "wrong version")
334                  self.failUnless(ns == "http://www.opengis.net/gml", "wrong name space")
335                  for vtk_node in node.childNodes:
336                     if isinstance(vtk_node, minidom.Element):
337                        if vtk_node.tagName == 'UnstructuredGrid': unstructured=True
338         self.failUnless( unstructured !=None, "dummy is missing.")
339      def test_metadata_3(self):
340         fn=os.path.join(FINLEY_WORKDIR_PATH,"metadata3.xml")
341         dom=ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"hex_2D_order2.msh"),optimize=False)
342         saveVTK(fn,x=dom.getX())
343         # testing:
344         unstructured=None
345         dom=minidom.parseString(open("metadata3.xml",'r').read())
346         for node in dom.childNodes:
347            if isinstance(node, minidom.Element):
348               if node.tagName == 'VTKFile':
349                  type = node.getAttribute("type")
350                  version = node.getAttribute("version")
351                  self.failUnless(type == "UnstructuredGrid","Type wrong")
352                  self.failUnless(version == "0.1", "wrong version")
353                  for vtk_node in node.childNodes:
354                     if isinstance(vtk_node, minidom.Element):
355                        if vtk_node.tagName == 'UnstructuredGrid': unstructured=True
356         self.failUnless( unstructured !=None, "dummy is missing.")
357          
358          
359    # ======================================================================================================================    # ======================================================================================================================
360    def test_hex_2D_order2_vtk(self):    def test_hex_2D_order2_vtk(self):
361       reference="hex_2D_o2.xml"       reference="hex_2D_o2.xml"
# Line 2977  class Test_DXFiles(Test_VisualizationInt Line 3094  class Test_DXFiles(Test_VisualizationInt
3094    
3095  if __name__ == '__main__':  if __name__ == '__main__':
3096     suite = unittest.TestSuite()     suite = unittest.TestSuite()
3097     # suite.addTest(Test_VTKFiles("test_hex_2D_order2_AllPoints_Scalar_vtk"))     #suite.addTest(Test_VTKFiles("test_metadata_3"))
3098     suite.addTest(unittest.makeSuite(Test_VTKFiles))     suite.addTest(unittest.makeSuite(Test_VTKFiles))
3099     # saveDX is not MPI parallel     # saveDX is not MPI parallel
3100     if getMPISizeWorld() == 1:     if getMPISizeWorld() == 1:

Legend:
Removed from v.2420  
changed lines
  Added in v.2421

  ViewVC Help
Powered by ViewVC 1.1.26